In my WinForms application, I have to display line graphs.
One feature which I need to implement in my application is saving the chart to a file. Once the chart is save
You have a couple of options:
Save as Jpg or Png in a size large enough to zoom in. To do so you would enlarge the chart before saving and then shrink it again.
Save in one of the emf formats. This saves a vector format, so zooming in works very well, even at large zoom factors. ((erroneous rant omitted))
Save to XML. This means serializing, either using the standard options or by marking certain properties as serializable or non-serializable. See here for more info! This code is straight from the link:
string yourChartDataFile = "d:\\SavedChartData.xml";
private void saveButton_Click(object sender, EventArgs e)
{
chart1.Serializer.Save(yourChartDataFile);
}
private void loadButton_Click(object sender, EventArgs e)
{
chart1.Serializer.Load(yourChartDataFile);
}
To display the resulting file you need another chart control, obviously.
I found the two-liner above to work pretty well without adding frills, but you may need or want to save things like current zoom state or annotation states; I'm not sure just what does get serialized out of the box and what does not..
Update Actually you can view and work with emf by loading them into a Metafile, which can be loaded into a PictureBox or drawn in a suitable size with Graphics.DrawImage..