Exporting in Xamarin Charts (SfChart)
12 May 20211 minute to read
Export as an image
You can export the Chart as a JPG image using
SaveAsImage method of
SfChart chart = new SfChart(); ... chart.SaveAsImage("ChartSample.jpg");
The exported image will be saved in the different location across the platforms.
Android – The image will be saved inside the Pictures directory.
iOS – The image will be saved inside the “Photos/Album” directory.
Windows Phone – The image will be saved inside the “/Pictures/ Saved Pictures” directory.
In order to save the image in Android and Windows Phone, you have to enable the permission to write the file in device storage.
Get the stream of Chart
‘SfChart’ contains the following methods to get the chart stream.
GetStream method of SfChart is used to get the chart as stream. The output stream can be passed as an input of any other components which accept the stream such as pdf, excel, word etc. This method is only applicable for Android and iOS platforms only.
SfChart chart = new SfChart(); ... chart.GetStream();
GetStreamAsync method of SfChart is used to get the chart as stream asynchronously.
This method will work only when the SfChart view in UI.
The following code snippet demonstrates the usage of this method:
SfChart chart = new SfChart(); ... var stream = await chart.GetStreamAsync();
You can refer to our Xamarin Charts feature tour page for its groundbreaking feature representations. You can also explore our Xamarin.Forms Charts example to knows various chart types and how to easily configured with built-in support for creating stunning visual effects.
How to export the Chart to the PDF document in Xamarin.Forms