14

Having a chart displayed with a System.Windows.Forms.DataVisualization.Charting.Chart control in a .Net 4.0 WinForms application, can I save its render into a picture file?

CodeCaster
  • 139,522
  • 20
  • 204
  • 252
Ivan
  • 61,237
  • 94
  • 244
  • 376

2 Answers2

24

How about the Chart.SaveImage() method?

CodeCaster
  • 139,522
  • 20
  • 204
  • 252
  • 1
    Thanks. I haven't ever been using the Chart control before and have somehow missed the method while searching. – Ivan Jun 02 '12 at 18:56
23

You can use the code below by passing proper ChartImageFormat.*:

this.chart1.SaveImage("C:\\mycode\\mychart.png", ChartImageFormat.Png);

Also look this SO if you met any problem: Save Image Using .net Chart and Saving higher resolution charts without messing up the appearance

Community
  • 1
  • 1
AvkashChauhan
  • 20,355
  • 3
  • 32
  • 64