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 define ticker labels of custom axis ?

Platform: WinRT |
Control: SfChart |
Published Date: September 3, 2014 |
Last Revised Date: June 27, 2019 |
.NET Framework: 4.5 |
Product Version: 12.1.0.43

How to define custom axis ticker labels?

In SfChart, we can define custom axis ticker label in following two ways:

1)We can define the ticker label by using the LabelsSource, ContentPath, and PositionPath properties of a chart axis. In the following sample, DataValues is the observablecollection, which contains the label content and position values of chart axes. The LabelsSource property binds the collection of DataValues. The ContentPath property is to specify the collection, and the PositionPath property defines the position of the chart axis.

XAML

 
 <!—Custom x-axis ticker labels -->
            <Syncfusion:SfChart.PrimaryAxis>
                <Syncfusion:CategoryAxis FontSize="12" LabelsSource="{Binding DataValues}" ContentPath="ContentX" PositionPath="PositionX">
                </Syncfusion:CategoryAxis>
            </Syncfusion:SfChart.PrimaryAxis>
 
<!—Custom y-axis ticker labels -->
<Syncfusion:SfChart.SecondaryAxis>
                <Syncfusion:NumericalAxis FontSize="12" LabelsSource="{Binding DataValues}" ContentPath=" ContentY" PositionPath=" PositionY">
                </Syncfusion:CategoryAxis>
            </Syncfusion:SfChart.PrimaryAxis>
 
 

2)Using chart axis CustomLabels, we can define the ticker label of custom x-axis and y-axis as shown in the following code.

XAML

 
 <!—Custom x-axis ticker labels -->
            <Syncfusion:SfChart.PrimaryAxis>
                <Syncfusion:CategoryAxis FontSize="12" >
                    < Syncfusion:CategoryAxis.CustomLabels>
                        < Syncfusion:ChartAxisLabel LabelContent="Sonata" Position="0" />
                        < Syncfusion:ChartAxisLabel LabelContent="Titan" Position="1" />
                        < Syncfusion:ChartAxisLabel LabelContent="Fastrack" Position="2" />
                        < Syncfusion:ChartAxisLabel LabelContent="Timex" Position="3" />
                        < Syncfusion:ChartAxisLabel LabelContent="Rolex" Position="4" />
                        < Syncfusion:ChartAxisLabel LabelContent="Omega" Position="5" />
                        < Syncfusion:ChartAxisLabel LabelContent="Maruti" Position="6" />
 
                    </ Syncfusion:CategoryAxis.CustomLabels>
                </Syncfusion:CategoryAxis>
            </Syncfusion:SfChart.PrimaryAxis>
 
<!—Custom y-axis ticker labels -->
< Syncfusion:SfChart.SecondaryAxis>
        < Syncfusion:NumericalAxis  FontSize="12" >
           < Syncfusion:NumericalAxis.CustomLabels>
              < Syncfusion:ChartAxisLabel Position="0" LabelContent="Item 0"/>
              < Syncfusion:ChartAxisLabel Position="500" LabelContent="Item 1"/>
              < Syncfusion:ChartAxisLabel Position="1000" LabelContent="Item 2"/>
              < Syncfusion:ChartAxisLabel Position="1500" LabelContent="Item 3"/>
              < Syncfusion:ChartAxisLabel Position="2000" LabelContent="Item 4"/>
              < Syncfusion:ChartAxisLabel Position="2500" LabelContent="Item 5"/>
          </ Syncfusion:NumericalAxis.CustomLabels>
  </ Syncfusion:SfChart.SecondaryAxis>

Output

Chart with custom axis labels in WPF

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.

Up arrow icon

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