Exporting Series Data with Chart Controls
You can export series data to a DataSet control, and then do one of the following:
Bind data to another control.
Save into a file or stream.
Convert into a different format, such as XML.
Edit data.
To do this, use the Chart.DataManipulator.ExportSeriesValues method.
Exported Data Format
Each series is represented as a DataTable object in the Tables collection property. The DataTable objects have the same name as the series they represent. Each DataTable object has two or more columns in the following order of column names: "X", "Y1", "Y2", …. The number of table columns depends on the number of Y values in the series the DataTable object represents.
The data type of each column is determined by the series' Series.XValueType and Series.YValueType properties.
Each data point in the series is represented by a DataRow object in the Rows collection property.
Example
The following example demonstrates how to export series data to a DataGrid control in your ASP.NET application. You can do similarly with a DataGridView control in a Windows Forms application.
' Add data to series
Chart1.Series("Series1").Points.AddY(7.785)
Chart1.Series("Series1").Points.AddY(15.534)
Chart1.Series("Series1").Points.AddY(45.569)
Chart1.Series("Series1").Points.AddY(12.356)
Chart1.Series("Series1").Points.AddY(25.567)
' Export series values into a DataSet object
Dim dataset As System.Data.DataSet = Chart1.DataManipulator.ExportSeriesValues()
' Data-bind to the DataGrid control
DataGrid1.DataSource = dataset
DataGrid1.DataMember = "Series1"
DataGrid1.DataBind()
// Add data to series
Chart1.Series["Series1"].Points.AddY(7.785)
Chart1.Series["Series1"].Points.AddY(15.534);
Chart1.Series["Series1"].Points.AddY(45.569);
Chart1.Series["Series1"].Points.AddY(12.356);
Chart1.Series["Series1"].Points.AddY(25.567);
// Export series values into a DataSet object
System.Data.DataSet dataset = Chart1.DataManipulator.ExportSeriesValues();
// Data-bind to the DataGrid control
DataGrid1.DataSource = dataset;
DataGrid1.DataMember = "Series1";
DataGrid1.DataBind();
See Also
Reference
System.Windows.Forms.DataVisualization.Charting
System.Web.UI.DataVisualization.Charting