How can I help you?
Export Chart to Image (Windows 8.1) in WPF Charts
27 Apr 20261 minute to read
The export chart to image feature in the SfChart control enables the user to export the image of the chart in different image file formats.
Supported Formats
- JPG or JPEG
- JPG-XR
- GIF
- TIFF
- PNG
- BMP
Method Table
| Method | Prototype | Description |
|---|---|---|
| Save | Save(string fileName, StorageFolder folderLocation) | Export the chart image with the given file name to the mentioned location.If folderLocation is null then it exports the image to the app installed location. |
| Save | Save(IRandomAccessStream stream, Guid bitmapEncoderID) | Export the chart image using the stream and its corresponding encoder. |
Method 1
chart.Save("sfchart.jpg", KnownFolders.PicturesLibrary);Method 2
var memoryStream = new InMemoryRandomAccessStream();
chart.Save(memoryStream, BitmapEncoder.BmpEncoderId);
StorageFolder storageFolder = Windows.ApplicationModel.Package.Current.InstalledLocation;
var file = await storageFolder.CreateFileAsync("chartwithstream.jpg", CreationCollisionOption.GenerateUniqueName);
var stream = await file.OpenAsync(Windows.Storage.FileAccessMode.ReadWrite);
{
chart.Save(stream, BitmapEncoder.BmpEncoderId);
}