2X faster development
The ultimate WPF UI toolkit to boost your development speed.
You cannot set the custom labels for axis without specify the range explicitly in WPF Chart (SfChart). It can be achieved by adding custom labels based on the position of visible labels in ActualRangeChanged event. XAML <!--Hooked ActualRangeChangedEvent--> <chart:SfChart.SecondaryAxis> <chart:NumericalAxis ActualRangeChanged="NumericalAxis_ActualRangeChanged"/> </chart:SfChart.SecondaryAxis> C# private void NumericalAxis_ActualRangeChanged(object sender, Syncfusion.UI.Xaml.Charts.ActualRangeChangedEventArgs e) { var axis = sender as NumericalAxis; //Gets the collection of visible labels. var labels = axis.VisibleLabels; if (labels != null) { if (axis.CustomLabels.Count > 0) axis.CustomLabels.Clear(); //To add the custom labels based on the position of visible labels. for (int index = 0; index < labels.Count; index++) { var axisLabel = new ChartAxisLabel() { Position = labels[index].Position,//To set the position where the custom label should be placed. LabelContent = "Item" + index //To set the content from which labels are to be taken. }; axis.CustomLabels.Add(axisLabel); } } } The following screenshot illustrates the custom labels based on the range in y-axis.
|
2X faster development
The ultimate WPF UI toolkit to boost your development speed.
This page will automatically be redirected to the sign-in page in 10 seconds.