How to customize the appearance of axis labels in WPF Chart (SfChart)?
This article explains how to customize the appearance of the axis labels in WPF Chart.
WPF SfChart supports customizing the appearance of the axis labels using the LabelTemplate property of the Chart axis as per the following code samples.
[Xaml]
<Grid>
<Grid.DataContext>
<local:ViewModel />
</Grid.DataContext>
<chart:SfChart>
<chart:SfChart.PrimaryAxis>
<chart:CategoryAxis ShowGridLines="False">
<chart:CategoryAxis.LabelTemplate>
<DataTemplate>
<Border Padding="3" Background="LightGreen" CornerRadius="4" >
<TextBlock Text="{Binding LabelContent}"
FontWeight="Bold" Foreground="Black"/>
</Border>
</DataTemplate>
</chart:CategoryAxis.LabelTemplate>
</chart:CategoryAxis>
</chart:SfChart.PrimaryAxis>
<chart:SfChart.SecondaryAxis>
<chart:NumericalAxis Maximum="2500">
<chart:NumericalAxis.LabelTemplate>
<DataTemplate>
<Border Padding="3" Background="LightGreen" CornerRadius="4" >
<TextBlock Text="{Binding LabelContent}"
FontWeight="Bold" Foreground="Black"/>
</Border>
</DataTemplate>
</chart:NumericalAxis.LabelTemplate>
</chart:NumericalAxis>
</chart:SfChart.SecondaryAxis>
<chart:ColumnSeries ItemsSource="{Binding Data}"
XBindingPath="XValue"
YBindingPath="YValue"
Palette="Metro">
<chart:ColumnSeries.AdornmentsInfo>
<chart:ChartAdornmentInfo ShowLabel="True" />
</chart:ColumnSeries.AdornmentsInfo>
</chart:ColumnSeries>
</chart:SfChart>
</Grid>
Download the complete sample on GitHub
Output:
See Also,
How to display the axis labels in a particular format of WPF Chart (SfChart)?
How to display the axis labels for all datapoints in WPF Chart (SfChart)?
How to set the custom labels with auto range for axis in WPF Chart (SfChart)?
I hope you enjoyed learning about h ow to customize the appearance of axis labels in WPF Chart (SfChart
You can refer to our WPF Chart’s feature tour page to know about its other groundbreaking feature representations. You can also explore our WPF Chart documentation to understand how to present and manipulate data.
For current customers, you can check out our WinForms components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our WPF Chart and other WPF components.
If you have any queries or require clarifications, please let us know in comments below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!