How to Display Fixed Number of Data Points in Chart of Xamarin.Forms?
Auto scrolling delta feature in SfChart is used to ensure that the specified range of data is always visible in the chart. You can view the remaining data points by scrolling. It always shows the recently added data points at the end, and scrolling will be reset to the end of the range whenever a new point is added. The following code examples illustrate how to specify the auto scrolling delta value for different axis types Xamarin Charts.
Category axis
The AutoScrollingDelta property of ChartAxis is used to customize the number of visible points to be displayed in chart when using the category axis.
XAML:
<chart:SfChart.PrimaryAxis> <chart:CategoryAxis AutoScrollingDelta="3"/> </chart:SfChart.PrimaryAxis>
C#:
chart.PrimaryAxis = new CategoryAxis { AutoScrollingDelta = 3 };
Screenshot:
Numerical axis
The AutoScrollingDelta property of ChartAxis is used to customize the visible range to be displayed in chart when using the numerical axis.
XAML:
<chart:SfChart.PrimaryAxis> <chart:NumericalAxis AutoScrollingDelta="10"/> </chart:SfChart.PrimaryAxis>
C#:
chart.PrimaryAxis = new NumericalAxis { AutoScrollingDelta = 10 };
Screenshot:
Date-Time axis
The AutoScrollingDelta property of ChartAxis is used to customize the visible range to be loaded in chart when using the date-time axis, and the AutoScrollingDeltaType property of DateTimeAxis is used to specify the date-time component for AutoScrollingDelta value.
XAML:
<chart:SfChart.PrimaryAxis> <chart:DateTimeAxis AutoScrollingDelta="3" AutoScrollingDeltaType="Months"/> </chart:SfChart.PrimaryAxis>
C#:
chart.PrimaryAxis = new DateTimeAxis { AutoScrollingDelta = 3, AutoScrollingDeltaType = DateTimeDeltaType.Months };
Screenshot:
Conclusion
I hope you enjoyed learning about how to display fixed number of data points in Chart of Xamarin.Forms.
You can refer to our Xamarin Charts page to know about its other groundbreaking feature representations. You can also explore our Xamarin.Forms Chart Documentation to understand how to manipulate data.
For current customers you can check out on our Xamarin.Forms components from the License and Download page. If you are new to Syncfusion, you can try our 30-day free trial to check out our Xamarin.Forms Chart and other Xamarin.Forms components.
If you have any queries or require clarifications, please let us know in the comment section below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!