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 ChartAxis 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>
Output:
For more details, please refer to the project on GitHub.
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)?
Conclusion
I hope you enjoyed learning how to customize the appearance of axis labels in WPF Chart.
You can refer to our WPF Chart feature tour page know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications. You can also explore our WPF Chart Examples to understand how to create and manipulate data.
For current customers, you can check out our 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 other controls.
If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!