Export Chart as Image in WPF Chart

11 Aug 20221 minute to read

In order to export the Chart control as an image, the Save method needs to be called. Two overload methods are available to export the Chart:

  • Save(Stream stream)
  • Save(string fileName)
  • Save(Stream stream, BitmapEncoder encoder)
  • Save(Stream stream, Rect saveArea)
  • Save(string fileName, BitmapEncoder encoder)
  • Save(string fileName, Rect saveArea)
  • Save(Stream stream, Rect saveArea, BitmapEncoder encoder)
  • Save(string fileName, Rect saveArea, BitmapEncoder encoder)

The following code examples can be used to export the Chart as an image:

  • C#
  • SaveFileDialog saveFileDialog = new SaveFileDialog();
    string C_imageFilesFilter = "Bitmap(*.bmp)|*.bmp|JPEG(*.jpg,*.jpeg)|*.jpg;*.jpeg|Gif (*.gif)|*.gif|TIFF(*.tiff)|*.tiff|PNG(*.png)|*.png|WDP(*.wdp)|*.wdp|Xps file (*.xps)|*.xps|All files (*.*)|*.*";
     saveFileDialog.Filter = C_imageFilesFilter;
    
    if (saveFileDialog.ShowDialog() == true)
    {             
    Chart1.Save(saveFileDialog.FileName);
    }