Skip to content

Commit 4111985

Browse files
Export chart sample updated for the Winui KB
1 parent c82e6de commit 4111985

23 files changed

+135
-125
lines changed

README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,27 @@
11
# How to Export Chart as Image in WinUI Chart
22
This article provides a detailed walkthrough on how to export a [WinUI Cartesian Chart](https://www.syncfusion.com/winui-controls/cartesian-charts) as an image. You can export the chart view in your desired file format, with supported formats being **JPEG** and **PNG.**
33

4+
The Syncfusion WinUI Chart control supports exporting rendered charts to image formats, enabling developers to preserve visual data for reporting, sharing, or archival purposes.
5+
6+
## Overview
7+
8+
The chart export functionality is exposed via the ExportToImage method in the SfCartesianChart and SfCircularChart classes. This method allows you to capture the current visual state of the chart and save it to a file or stream in various image formats.
9+
10+
## Supported Image Formats
11+
You can export charts to the following formats:
12+
- PNG (lossless, widely supported)
13+
- JPEG (compressed, suitable for web)
14+
15+
## Use Cases
16+
17+
- Business Reporting: Export charts to image files for embedding in PDF or Word documents used in financial or operational reports.
18+
- Data Sharing: Share chart visuals with stakeholders via email, chat, or collaboration platforms without requiring access to the application.
19+
- Archival and Compliance: Save chart snapshots as part of audit trails or historical data records for regulatory compliance.
20+
- Presentation Materials: Include exported chart images in PowerPoint slides or dashboards for meetings and presentations.
21+
- Offline Access: Provide users with downloadable chart images for viewing when internet or application access is unavailable.
22+
- Documentation and Tutorials: Use chart images in technical documentation, user guides, or training materials to illustrate data insights.
23+
- Social Media and Marketing: Share chart visuals on social platforms to highlight trends, performance metrics, or product analytics.
24+
425
### Initialize SfCartesianChart:
526

627
Set up the **SfCartesianChart** following the [ Syncfusion WinUI Cartesian Chart documentation.](https://help.syncfusion.com/winui/cartesian-charts/getting-started)
@@ -83,6 +104,10 @@ private async void Button_Click(object sender, RoutedEventArgs e)
83104

84105
![chart.png](https://support.syncfusion.com/kb/agent/attachment/article/18644/inline?token=eyJhbGciOiJodHRwOi8vd3d3LnczLm9yZy8yMDAxLzA0L3htbGRzaWctbW9yZSNobWFjLXNoYTI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjM0MjMyIiwib3JnaWQiOiIzIiwiaXNzIjoic3VwcG9ydC5zeW5jZnVzaW9uLmNvbSJ9.VhSO304zS7VSvBDSySJWOBxdySgRK0LWuAdmx3Vl4No)
85106

107+
## Troubleshooting
108+
109+
If you are facing a path too long exception when building this example project, close Visual Studio and rename the repository to short and build the project.
110+
86111
### KB link
87112
For a more detailed, refer to the [Export Chart View as Image KB.](https://support.syncfusion.com/kb/article/18644/how-to-export-chart-as-image-in-winui-chart-sfcartesianchart)
88113

WinUISampleDemo/WinUISampleDemo/App.xaml renamed to WinUIExportSample/App.xaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Application
3-
x:Class="WinUISampleDemo.App"
3+
x:Class="WinUIExportSample.App"
44
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
55
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
6-
xmlns:local="using:WinUISampleDemo">
6+
xmlns:local="using:WinUIExportSample">
77
<Application.Resources>
88
<ResourceDictionary>
99
<ResourceDictionary.MergedDictionaries>

WinUISampleDemo/WinUISampleDemo/App.xaml.cs renamed to WinUIExportSample/App.xaml.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,22 @@
1919
// To learn more about WinUI, the WinUI project structure,
2020
// and more about our project templates, see: http://aka.ms/winui-project-info.
2121

22-
namespace WinUISampleDemo
22+
namespace WinUIExportSample
2323
{
2424
/// <summary>
2525
/// Provides application-specific behavior to supplement the default Application class.
2626
/// </summary>
2727
public partial class App : Application
2828
{
29+
private Window? _window;
30+
2931
/// <summary>
3032
/// Initializes the singleton application object. This is the first line of authored code
3133
/// executed, and as such is the logical equivalent of main() or WinMain().
3234
/// </summary>
3335
public App()
3436
{
35-
this.InitializeComponent();
37+
InitializeComponent();
3638
}
3739

3840
/// <summary>
@@ -41,10 +43,8 @@ public App()
4143
/// <param name="args">Details about the launch request and process.</param>
4244
protected override void OnLaunched(Microsoft.UI.Xaml.LaunchActivatedEventArgs args)
4345
{
44-
m_window = new MainWindow();
45-
m_window.Activate();
46+
_window = new MainWindow();
47+
_window.Activate();
4648
}
47-
48-
private Window? m_window;
4949
}
5050
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)