Hi Witond,
Thanks for contacting Syncfusion support.
By default, we will be rotating the axis labels with center
of the label and it is the default behavior. In order to
customize the position we can set LabelTemplate property of CharAxis and set
margin for the labels accordingly as shown in below code snippet,
Code Snippet:
<chart:SfChart.PrimaryAxis>
<chart:CategoryAxis LabelRotationAngle="-60" LabelTemplate="{StaticResource transform}"/>
</chart:SfChart.PrimaryAxis>
Resource Template:
<DataTemplate x:Key="transform">
<TextBlock Margin="0,0,0,60" Text="{Binding LabelContent}"/>
</DataTemplate>
Please let us know in case of any query.
Regards,
Suresh S
Thank you for your help.
To fix this issue when the text is too long, I used a converter to calculate the best Margin value depending on the length of the label
<DataTemplate>
<TextBlock Text="{Binding LabelContent}" FontSize="10" Margin="{Binding RelativeSource={RelativeSource Self}, Path=ActualWidth, Converter={StaticResource LabelContentMarginConverter}}"/>
</DataTemplate>
public class LabelContentMarginConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
var rightValue = System.Convert.ToDouble(value) / (-3);
var bottomValue = System.Convert.ToDouble(value) / 2;
return new Thickness(0, 0, rightValue, bottomValue);
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return null;
}
}