How to get Axis Range in UWP chart?
The UWP Chart provides two important properties for managing axis ranges: ActualRange and VisibleRange. The ActualRange consistently holds the complete data range of the axis, while the VisibleRange dynamically reflects the currently displayed range, especially during zooming, panning, or scrolling interactions. This article will guide you on how to access both of these range types.
Step 1: To retrieve the VisibleRange of a ChartAxis, access its VisibleRange property. This can be done, within the LayoutUpdated event of the chart to get the current visible range.
<chart:SfChart x:Name="chart" LayoutUpdated="chart_LayoutUpdated">
<chart:SfChart.PrimaryAxis>
<chart:CategoryAxis Interval="2" x:Name="primaryAxis" />
</chart:SfChart.PrimaryAxis>
. . .
</chart:SfChart>private void chart_LayoutUpdated(object sender, EventArgs e)
{
var visibleRange = primaryAxis.VisibleRange;
}Step 2: To obtain the ActualRange of a ChartAxis, handle the ActualRangeChanged event. This event provides the ActualMinimum and ActualMaximum values in its event arguments, representing the start and end of the entire axis range.
<chart:SfChart x:Name="chart" >
<chart:SfChart.PrimaryAxis>
<chart:CategoryAxis Interval="2" x:Name="primary" ActualRangeChanged="primary_ActualRangeChanged"/>
</chart:SfChart.PrimaryAxis>
. . .
</chart:SfChart>private void primary_ActualRangeChanged(object sender, ActualRangeChangedEventArgs e)
{
var primaryActualMin = e.ActualMinimum;
var primaryActualMax = e.ActualMaximum;
}Conclusion
I hope you enjoyed learning about how to get axis range of chart in UWP.
You can refer to our UWP Chart feature tour page to know about its other groundbreaking feature representations. You can also explore our UWP Chart documentation to understand how to present and manipulate data.
For current customers, you can check out our UWP 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 UWP Chart and other UWP components.
If you have any queries or require clarifications, please let us know in comments below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!