We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to export the charts in Xamarin.Android

Platform: Xamarin.Android |
Control: SfChart

This article explains how to export the Syncfusion Xamarin.Android SfChart as an image.


SfChart has been saved as image and stored in the picture directory of the deployed device as shown in the following code sample.



public void SaveAsImage(string filename) 
    // create bitmap screen capture
    chart.DrawingCacheEnabled = true; 
   // view will save its state
    chart.SaveEnabled = true; 
    Bitmap bitmap = null; 
    using (bitmap = chart.DrawingCache) 
        var extension = filename.Split('.'); 
       // create an image path with existing environment with the provided file name without having the extension
        var imagePath = 
            new Java.IO.File(Android.OS.Environment.ExternalStorageDirectory + "/Pictures/" + filename); 
        using (Stream fileStream = new FileStream(imagePath.AbsolutePath, System.IO.FileMode.OpenOrCreate)) 
               //Compressed bitmap to get needed format
                string imageExtension = extension.Length > 1 ? extension[1].Trim().ToLower() : "jpg"; 
                switch (imageExtension) 
                    case "png": 
                        bitmap.Compress(Bitmap.CompressFormat.Png, 100, fileStream); 
                    case "jpg":  case "jpeg": default: 
                        bitmap.Compress(Bitmap.CompressFormat.Jpeg, 100, fileStream); 
              //Closing stream and disabled drawing cache.
                chart.DrawingCacheEnabled = false; 


In order to save the image, you have to enable the permission in the Android.Manifest file for device storage and also enable the storage permission in your device.


<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
 <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />



View the sample in GitHub.


See also


How to export chart to PDF in Xamarin.Android


What are the types of SfChart



2X faster development

The ultimate Xamarin UI toolkit to boost your development speed.
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile