How to display a fixed number of data points in .NET MAUI Chart (SfCartesianChart)?
The auto-scrolling delta feature in the .NET MAUI Cartesian Chart ensures that a specified range of data is always visible. This allows you to view remaining data points by scrolling, with the most recent points displayed last. This guide shows how to implement this feature using the AutoScrollingDelta property for various axis types.
Category axis
To use the category axis, the AutoScrollingDelta property of ChartAxis can be used to customize the number of visible points displayed on the chart.
[XAML]
<chart:SfCartesianChart.XAxes>
<chart:CategoryAxis AutoScrollingDelta="3">
</chart:CategoryAxis>
</chart:SfCartesianChart.XAxes>
[C#]
CategoryAxis primaryAxis = new CategoryAxis();
primaryAxis.AutoScrollingDelta = 3;
Numerical axis
To use the numerical axis, the AutoScrollingDelta property of ChartAxis can be used to customize the visible range displayed on the chart.
[XAML]
<chart:SfCartesianChart.XAxes>
<chart:NumericalAxis AutoScrollingDelta="50">
</chart:NumericalAxis></chart:SfCartesianChart.XAxes>
[C#]
NumericalAxis primaryAxis = new NumericalAxis();
primaryAxis.AutoScrollingDelta = 50;
Date-Time axis
To use date-time axes, the AutoScrollingDelta property of ChartAxis can be used to specify the visible range to be loaded, while the AutoScrollingDeltaType property of DateTimeAxis can be used to specify the date-time component for the AutoScrollingDelta value. These properties can be customized to meet your specific charting needs.
[XAML]
<chart:SfCartesianChart.XAxes>
<chart:DateTimeAxis AutoScrollingDelta="3" AutoScrollingDeltaType="Months">
</chart:DateTimeAxis></chart:SfCartesianChart.XAxes>
[C#]
DateTimeAxis primaryAxis = new DateTimeAxis();
primaryAxis.AutoScrollingDelta = 3;
primaryAxis.AutoScrollingDeltaType = DateTimeIntervalType.Months;
Note:
AutoScrollingDeltaMode property can be used to determine whether the axis should be scrolled from the start position or end position. The default value of AutoScrollingMode is End.
Conclusion
I hope you enjoyed learning to display a Fixed Number of Data Points in .NET MAUI Charts.
You can refer to our .NET MAUI Charts feature tour page to learn about its other groundbreaking feature representations. Explore our .NET MAUI Charts documentation to understand how to present and manipulate data.
For current customers, check out our .NET MAUI components from the Licence and Downloads page. If you are new to Syncfusion®, try our 30-day free trial to check out our .NET MAUI Charts and other .NET MAUI components.
Please let us know in the comments section if you have any queries or require clarification. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!