Articles in this section
Category / Section

How to define ticker labels of custom axis in WPF Chart (SfChart)?

2 mins read

You can define custom axis ticker label in WPF Chart (SfChart) by the following two ways:

1. You 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:NumericalAxis>
</Syncfusion:SfChart.SecondaryAxis>

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:NumericalAxis>
</Syncfusion:SfChart.SecondaryAxis>

 

WPF Chart with custom Axis Labels

Conclusion

I hope you enjoyed learning about how to define ticker labels of custom axis in WPF Chart (SfChart).

You can refer to our  WPF Chart feature tour page to know about its other groundbreaking feature representations. You can also explore our WPF Chart documentation 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 forumsDirect-Trac, or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments
Please sign in to leave a comment
Access denied
Access denied