We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to customize the labels in chart axis?

Platform: WPF |
Control: Chart |
Published Date: April 30, 2011 |
Last Revised Date: March 14, 2018
Tags:

 

A label's border, font family, font size, foreground, font weight etc., in a chart axis can be customized to add good look and feel to the chart.

Chart axis labels can be easily customized by applying data templates to the labels in the chart axis.

The following code is the data template for labels.

<DataTemplate x:Key="LabelsTemplate">
<Border BorderBrush="#C6C6C6" BorderThickness="0.75" Padding="3">
<TextBlock Name="TB1" Text="{Binding Content}" Foreground="Black" Background="White">
</TextBlock>
</Border> </DataTemplate>

The LabelTemplate property of the ChartAxis can be used to set the template for the labels in the ChartAxis.

<syncfusion:ChartArea>
<syncfusion:ChartArea.PrimaryAxis>
<syncfusion:ChartAxis RangePadding="None" LabelTemplate="{StaticResource LabelsTemplate}" syncfusion:ChartArea.ShowGridLines="True">
<syncfusion:ChartAxis.Header>
<TextBlock Text="X - Axis" FontFamily="Arial" FontSize="11" Foreground="Black" FontWeight="Bold"/>
</syncfusion:ChartAxis.Header>
</syncfusion:ChartAxis>
</syncfusion:ChartArea.PrimaryAxis> </syncfusion:ChartArea>

ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon