Articles in this section
Category / Section

How to customize the axis range based on condition

1 min read

In SfChart, the minimum and maximum ranges of an axis are calculated automatically based on the provided data. You can also set its range explicitly using the Minimum and Maximum properties of the respective axis.

There might be situation in which you need to have the control over the auto-calculated range. At this situation, you can subscribe the ActualRangechanged event of the respective axis and modify the auto-calculated minimum and maximum values that you got in the event arguments. This event will be fired whenever the actual range of the corresponding axis changes.

In the following code example, the maximum visible range is always kept to 80 whenever the overall range of the axis exceeds 80,

[C#]

chart.PrimaryAxis.ActualRangeChanged += PrimaryAxis_ActualRangeChanged;

 

[XAML]

<chart:SfChart.PrimaryAxis>
      <chart:NumericalAxis ActualRangeChanged = “PrimaryAxis_ActualRangeChanged “>
</chart:SfChart.PrimaryAxis>

 

[C#]

void PrimaryAxis_ActualRangeChanged(object sender, ActualRangeChangedEventArgs e)
{
       if (Convert.ToDouble(e.ActualMaximum) > 80)
       {
            e.VisibleMaximum = 80;
       }
}

 

 

                                                          

Output:

C:\Users\yuvaraj.palanisamy\Pictures\android1.png

 

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