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. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Xamafin Forms SfChart saveAsImage

Thread ID:

Created:

Updated:

Platform:

Replies:

132670 Sep 14,2017 07:48 PM UTC Dec 5,2017 01:02 PM UTC Xamarin.Forms 5
loading
Tags: SfChart
Vaibhavi
Asked On September 14, 2017 07:48 PM UTC

Hi,


I am trying to export syncfusion chart using saveAsImage method and it works well in Android. But I am developeing a xamarin forms app in visual studio which also requires it to run for ios but somehow it stops functioning and crashes my application. Can anyone suggest any solution for that?


Thanks.

Saravana Pandian Murugan [Syncfusion]
Replied On September 15, 2017 10:39 AM UTC

Hi Giatec, 
  
You can save SfChart as an image by using the below two solutions. 
  
Solution 1:   Generating chart image without adding it to the page 
  
you can save chart image without adding it to the page by using GetStream method of SfChart. Please find the code snippet below. 
  
Code Example: 
  
 
Stream chartStream = chart.GetStream(); 
  
  
Solution 2:  Generating chart image after adding it to the page. 
  
After chart is added in view, you can save chart as an image by using SaveAsImage method of SfChart. 
  
Also, we have attached sample for your reference which can be downloaded from the following location. 
  
  
Please check the attached sample and let us know if you need further assistance on this. 
  
Regards, 
Saravana Pandian M. 


Vaibhavi
Replied On September 15, 2017 01:21 PM UTC

Thank you so much for your help.


It did generate a pdf report with image of the chart but when I clicked the button ,SaveAsImage still does not work in iphone.


System.NullReferenceException: Object reference not set to an instance of an object

  at Syncfusion.SfChart.iOS.SFChart.UpdateChart () [0x00355] in <3fdf6077fdd84dac9a287c18a745308e>:0

  at Syncfusion.SfChart.iOS.SFChart.LayoutSubviews () [0x00006] in <3fdf6077fdd84dac9a287c18a745308e>:0

  at at (wrapper managed-to-native) ObjCRuntime.Messaging:void_objc_msgSend_IntPtr (intptr,intptr,intptr)

  at CoreAnimation.CALayer.RenderInContext (CoreGraphics.CGContext ctx) [0x0001c] in /Users/builder/data/lanes/4991/80b8487d/source/xamarin-macios/src/build/ios/native/CoreAnimation/CALayer.g.cs:599

  at Syncfusion.SfChart.XForms.iOS.ChartDependencyService.SaveAsImage (System.String filename, System.Object obj) [0x00029] in <3fdf6077fdd84dac9a287c18a745308e>:0

  at Syncfusion.SfChart.XForms.SfChart.SaveAsImage (System.String filename) [0x00015] in :0

  at ImageDrawing.TabbedPage1.Button_Clicked (System.Object sender, System.EventArgs e) [0x00001] in /Users/Giatec_user/Downloads/Sample 3/ImageDrawing/ImageDrawing/TabbedPage1.xaml.cs:48

  at Xamarin.Forms.Button.Xamarin.Forms.IButtonController.SendClicked () [0x00020] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\Button.cs:125

  at Xamarin.Forms.Platform.iOS.ButtonRenderer.OnButtonTouchUpInside (System.Object sender, System.EventArgs eventArgs) [0x00000] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Platform.iOS\Renderers\ButtonRenderer.cs:91

  at UIKit.UIControlEventProxy.Activated () [0x00007] in /Users/builder/data/lanes/4991/80b8487d/source/xamarin-macios/src/UIKit/UIControl.cs:38

  at at (wrapper managed-to-native) UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)

  at UIKit.UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate) [0x00005] in /Users/builder/data/lanes/4991/80b8487d/source/xamarin-macios/src/UIKit/UIApplication.cs:79

  at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x00038] in /Users/builder/data/lanes/4991/80b8487d/source/xamarin-macios/src/UIKit/UIApplication.cs:63

  at ImageDrawing.iOS.Application.Main (System.String[] args) [0x00001] in /Users/Giatec_user/Downloads/Sample 3/ImageDrawing/ImageDrawing.iOS/Main.cs:17

This is the error I get.


I had one more question. Is it possible to have a dashed striplines in chart?


Parthiban Sundaram [Syncfusion]
Replied On September 18, 2017 01:00 PM UTC

Hi Giatec, 
  
  
Thanks for the update. 
  
As we have analyzed the issue which is occurred due to denial the access permission in photo albums. So, please include permission for accessing photo albums in your application. This can be done by adding following code in info.plist file in iOS project.  
 
Code snippet:  
 
  
<dict> ?xml:namespace prefix = "o" /   
    <key>NSPhotoLibraryUsageDescription</key>  
    <string>This app uses photos</string>  
…..  
….  
</dict> 
 
  
  
Please download the sample from following location. 
 
 
Please let us know, if you need further assistance on this. 
 
Regards,
Parthiban S
 
  
  



ahraza
Replied On December 4, 2017 11:54 AM UTC

Hi,

I am having trouble saving the graph as image. I believe i have added the correct permissions on both iOS and Android.

I also tried using your sample on both iOS and Android simulators and on Android phone also:
http://www.syncfusion.com/downloads/support/forum/132670/ze/ImageChart-1700900634

But when i go to SFChart page and click on the "CLICK ME" button nothing happens.

Thanks,
Adil

Lakshmi Radha Krishnan [Syncfusion]
Replied On December 5, 2017 01:02 PM UTC

Hi Adil, 
  
The current Chart image will be exposed and saved in below location for each platform. 
  
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. 
  
Please refer the following link for more details. 
  
  
Please let us know, if you need further assistance on this. 
  
Regards, 
Lakshmi R. 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

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

;