Overview

When a Series is exported, the X and Y values of all data points in the series are persisted to the in-memory cache (DataSet object), where they can easily be used for the following purposes:
- Data-binding.
- Saving into a file, or stream.
- Converting to a different format, like XML.
- Editing data.
Output Data Formats
One of the main classes of the ADO.NET architecture, the DataSet class, is used to store the exported data. First, a DataTable object is created for each series, then it is added to the Tables collection of the DataSet class. Each DataTable object has the same name as the series it represents. Each DataTable object will have two, or more, columns including one column for the X value, and one, or more, columns for the Y values. Columns of the DataTable are named after the values they are storing ("X", "Y", "Y2", "Y3", etc.).
The data type of each column depends on the data point type. Data point type of a column may be a DateTime, string, or double.
Note |
|---|
| The XValueType, and YValueType properties determine the data point type. If these properties are set to Auto, then the type is automatically determined by the control. |
Each data point of the series will be stored in the DataRow object, and will be inserted into the Rows collection of the DataTable.
Note |
|---|
|
A string value can be assigned to the X values of the points. In this case, the string is stored into the AxisLabel property, and the XAxisType property of the series is set to string. When exporting the X values of type string, the AxisLabel property must be used to access the value. |
Alternate Output Formats for Data
Using the DataSet object is the most generic and convenient way of storing structured data in memory, and you can easily convert data that is stored in a DataSet object into any format required.
Example
This example demonstrates how to convert a DataSet object into XML, and then write it to a file.
| Visual Basic | Copy Code |
|---|---|
| |
| C# | Copy Code |
|---|---|
| |
Exporting Series
The X and Y values of one or more series can be exported using the ExportSeriesValues method of the DataManipulator object. Calling this method without specifying one or more series will, by default, export all values from all series objects in the chart series collection. If you want to export the data from specific series you can specify them by name or by using a Series object.
Example
This example demonstrates how to export one, several, or all series.
| Visual Basic | Copy Code |
|---|---|
| |
| C# | Copy Code |
|---|---|
| |
Exporting Data
Data points in a series may be marked as Empty. This means that there is no real Y value assigned to the data point. While exporting the data the empty points can be either ignored or exported as DBNULL values, depending on the IgnoreEmptyPoints property of the DataManipulator object. If IgnoreEmptyPoints is set to true then empty points are not exported. If it is False the empty data points will be stored as DBNull objects in the DataRow object.
Example
This example demonstrates how to data-bind a DataGrid control to an exported series. We assume that a DataGrid object was added to the web page. Further, we assume that the DundasBlue template has been applied to the original chart for appearance purposes. The result of the data-binding operation is shown in Figure 1 below.

Figure 1: A databound chart.
| Visual Basic | Copy Code |
|---|---|
| |
| C# | Copy Code |
|---|---|
| |
Example
This example demonstrates how to display an exported series' data in a table. We assume that a DataTable named "Table1" has been added to the from. Further, we assume that the DundasBlue template has been applied to the original chart for appearance purposes. The result of displaying the series data in the table is shown in Figure 2 below.

Figure 2: The result of displaying the series data in the table.
| Visual Basic | Copy Code |
|---|---|
' <summary> ' Create a data series, and add points to it. Add the series ' into the Series collection, and export using the Series ' object. ' </summary> Protected Sub CreateSeries()
' Create new series and add data.
Dim mySeries As Series = New Series("MySeries")
Dim randomValue As Random = New Random
' Add points to the series.
Dim index As Integer = 1
Do While (index <= 11)
mySeries.Points.AddXY(index, randomValue.Next(1, 100))
index = (index + 1)
Loop
' Add series into the collection.
Chart1.Series.Add(mySeries)
' Exporting series using the Series object.
Dim seriesData As DataSet = Chart1.DataManipulator.ExportSeriesValues(mySeries)
' Populate table with the series data in the data set.
InitializeTable(Table1, seriesData, "MySeries")
End Sub
' <summary>
' Initialize table from the DataSet object.
' </summary>
' <param name="table">
' Table object to initialize.
' <param name="dataSet">
' Series data.
' <param name="tableName">
' Series name to be used.
Protected Sub InitializeTable(ByVal table As Table, ByVal dataSet As DataSet, ByVal tableName As String)
For Each column As DataColumn In dataSet.Tables(tableName).Columns
' Create new table row for each column.
Dim row As TableRow = New TableRow
' Add title cell.
Dim cell As TableCell = New TableCell
cell.Controls.Add(New LiteralControl((dataSet.Tables(tableName).TableName + (" - " + column.ColumnName))))
row.Cells.Add(cell)
' Add data cells.
For Each dataRow As DataRow In dataSet.Tables(tableName).Rows
Dim dataCell As TableCell = New TableCell
dataCell.Controls.Add(New LiteralControl(dataRow(column).ToString))
row.Cells.Add(dataCell)
Next
' Add row into the table.
table.Rows.Add(row)
Next
End Sub
| |
| C# | Copy Code |
|---|---|
| |
Example
This example demonstrates how to export series data, filter the data, and then bind the data to a DataView object. The result of data-binding to the filtered series data is shown in the Figure 3 below. Notice that the points at position 2 and 4 were removed.

Figure 3: The result of data-binding to the filtered series data.
| Visual Basic | Copy Code |
|---|---|
| |
| C# | Copy Code |
|---|---|
| |
Note