Overview of Chart in Xamarin.Forms Part 2 | Syncfusion Blogs
Live Chat Icon For mobile
Live Chat Icon
Popular Categories.NET  (180).NET Core  (28).NET MAUI  (224)Angular  (113)ASP.NET  (49)ASP.NET Core  (81)ASP.NET MVC  (87)Azure  (41)Black Friday Deal  (1)Blazor  (234)BoldSign  (14)DocIO  (24)Essential JS 2  (110)Essential Studio  (199)File Formats  (72)Flutter  (135)JavaScript  (226)Microsoft  (121)PDF  (83)Python  (1)React  (105)Streamlit  (1)Succinctly series  (131)Syncfusion  (960)TypeScript  (33)Uno Platform  (3)UWP  (3)Vue  (46)Webinar  (53)Windows Forms  (59)WinUI  (72)WPF  (162)Xamarin  (159)XlsIO  (38)Other CategoriesBarcode  (5)BI  (29)Bold BI  (8)Bold Reports  (2)Build conference  (10)Business intelligence  (55)Button  (4)C#  (163)Chart  (145)Chart of the week  (57)Cloud  (15)Company  (440)Dashboard  (8)Data Science  (3)Data Validation  (8)DataGrid  (73)Development  (676)Doc  (7)DockingManager  (1)eBook  (99)Enterprise  (22)Entity Framework  (7)Essential Tools  (13)Excel  (43)Extensions  (23)File Manager  (7)Gantt  (20)Gauge  (12)Git  (5)Grid  (31)HTML  (13)Installer  (2)Knockout  (2)Language  (1)LINQPad  (1)Linux  (2)M-Commerce  (1)Metro Studio  (11)Mobile  (519)Mobile MVC  (9)OLAP server  (2)Open source  (1)Orubase  (12)Partners  (21)PDF viewer  (45)Performance  (13)PHP  (2)PivotGrid  (5)Predictive Analytics  (6)Report Server  (3)Reporting  (8)Reporting / Back Office  (9)Rich Text Editor  (12)Road Map  (12)Scheduler  (54)Security  (5)SfDataGrid  (9)Silverlight  (21)Sneak Peek  (32)Solution Services  (4)Spreadsheet  (11)SQL  (15)Stock Chart  (1)Surface  (4)Tablets  (5)Theme  (12)Tips and Tricks  (113)UI  (400)Uncategorized  (68)Unix  (2)User interface  (68)Visual State Manager  (2)Visual Studio  (31)Visual Studio Code  (19)Web  (624)What's new  (337)Windows 8  (19)Windows App  (2)Windows Phone  (15)Windows Phone 7  (9)WinRT  (26)

Overview of Chart in Xamarin.Forms Part 2

This is the continuation of my previous blog “Overview of Chart in Xamarin.Forms Part 1“. Hope you enjoyed it and have gained some basic knowledge about to configure the chart in a cross platform Xamarin application. In this blog, we are going to explain about some advanced features that are used for any application requirement. It includes configuring multiple series, annotation, zooming and scrolling, tracking data point, selection, auto scrolling and strip lines.

Adding multiple chart types

Adding multiple types of charts is a typical requirement when you need to plot different units of data to compare trends across a timeline. Let’s move forward with an example. I’m going to plot the Target vs Sale of each month using a column chart and show the percentage of achievement using a line chart so that I can display clear information about the trend across six months.
      <chart:ColumnSeries ItemsSource="{Binding Data}" XBindingPath="Date" YBindingPath="Target" Label="Target"> </chart:ColumnSeries>
      <chart:ColumnSeries ItemsSource="{Binding Data}" XBindingPath="Date" YBindingPath="Sale" Label="Sale"> </chart:ColumnSeries>
      <chart:LineSeries ItemsSource="{Binding Data}" XBindingPath="Date" YBindingPath="Percentage" Label="Percentage"> </chart:LineSeries>

Note: The transposed series (such as bar, stacked bar, and stacked bar 100) cannot be combined with other normal cartesian series and any cartesian series type cannot be combined with accumulation series (pie, doughnut, funnel, and pyramid).

Configuring annotations

Annotations are commonly used to display metadata about a chart or series at a specific point of interest in the plotting area. The control allows you to position them on a chart based on the screen point (pixel coordinate) or chart data. This feature includes functionality like built-in shapes, custom view support, text support to describe an annotation, axis-based plotting, and UI customization. Multiple annotations can be added to a single chart using the Annotations property of chart. In the following example, the top among six students is annotated with view annotation above the column segment.
      <chart:ViewAnnotation CoordinateUnit="Axis" X1="{Binding AnnotationX}" Y1="{Binding AnnotationY}">
                 <Image Source="Topper.png" ZoomMode="X"/> 

Enable zooming and scrolling

Zooming and scrolling are useful when you need to visualize large amounts of data. Zooming is performed by pinching, selecting the region, and double tapping at the required position. You can also restrict the zooming and scrolling actions to happen only in a vertical or horizontal direction.
      <chart:ChartZoomPanBehavior ZoomMode="X"> </chart:ChartZoomPanBehavior>

Tracking data point

When there are so many data points plotted in a chart that you cannot enable data markers due to space constraints, you would generally seek an alternate way to view the data values. That is where trackball and tooltip come into play for tracking the data point values.
The trackball feature is used to track a data point close to the touch contact point. It enables on long press, is draggable across the chart, and will be deactivated with one touch of the finger.
On the other hand, we have the tooltip feature that displays a pop-up with additional information when the mouse pointer is touching a data point. It is your choice to configure the most suitable feature between trackball and tooltip, or both in the same chart.
Following is the example code of trackball and its output.
     <chart:ChartTrackballBehavior> </chart:ChartTrackballBehavior>

Following is the example code of tooltip and its output.

 <chart:LineSeries EnableTooltip="true" ItemsSource="{Binding Data}" XBindingPath="X" YBindingPath="Y"> </chart:LineSeries>

Enable data point selection

Interactively select and highlight a data point. This is widely used to navigate to another page with the information of a selected data point or to update the other components in the same page based on the selected data point in a chart.
 <chart:LineSeries EnableDataPointSelection="true" ItemsSource="{Binding Data}" XBindingPath="X" YBindingPath="Y"> </chart:LineSeries>

Configuring autoscrolling

You can configure the autoscrolling feature to focus on a minimal set of data points by visualizing only a few items in the UI and viewing the remaining data points by scrolling. This is typically used in real-time updates to view recently added data points. You need to specify the autoscrolling delta to display a fixed number of points and set the mode to define the position where it should show, the start or end.
     <chart:ChartZoomPanBehavior ZoomMode="X"> </chart:chartZoomPanBehavior>
     <chart:DateTimeAxis AutoScrollingDelta="5" AutoScrollingDeltaType="Months"> </chart:DateTimeAxis>

Configuring strip lines

Strip lines are used to shade different ranges in a plot area with different colors to improve the readability of a chart. You can annotate them with text to indicate what a particular region indicates. You can also enable the strip lines to be drawn repeatedly at regular intervals—this is useful when you want to mark an event that occurs recursively along the timeline of the chart.
     <chart:NumericalAxis Minimum="980" Maximum="1030">
                <chart:NumericalStripLine Start="980" Width="10" RepeatEvery="20" RepeatUntil="1030" FillColor="#EBECF0"> </chart:NumericalStripLine>

Download the complete sample from here. You can change the MainPage of this sample to the required page to switch between features.


In this blog post, you learned about advanced features available in the Syncfusion chart control for the Xamarin.Forms platform. But there are still a few more features that have not been discussed in this blog. Take look at our documentation to learn about all the features with example codes, or download our sample browser app from Google Play, Windows Store or the iOS App Store to explore all the samples.
If you have any questions or require clarification on these features, please let us know in the comments below. You can also contact us through our support forum or Direct-Trac. We are happy to assist you!


Share this post:

Popular Now

Be the first to get updates

Subscribe RSS feed