.Net Chart Control     A powerful component for convenient charting. 

More convenience more functionality in Ver. 3.5

Home

Chart Gallery

Chart Decoration

Download

Pricing

How To

FAQ

Load Chart Data from Data Table

Click here to get sample solution for .NET Framework 1.1 (VS 2003).
Click here to get sample solution for .NET Framework 2.0 (VS 2005).

Probably it’s a most common use of the chart component. There are 2 different ways how you can use data from the DataTable object with the chart control:

  1. Using Chart Data Binding object.
  2. Using XSLT transformation. This is the only way was available till version 3.3. You can use it if you'd like, but we suggest the first method for thouse who uses Chart Control .NET v3.3 and upper.

In case you are using Chart Data Binding object chart XML document should contain only layout description. Data section shouldn’t exist or should be empty. The chart XML document can be as easy as the following:

<?xml version="1.0" encoding="utf-8" ?> 
<Charts> 
	<ComponentLayout> 
	</ComponentLayout> 
	<Chart> 
		<Layout Type="Bar"> 
		</Layout> 
	</Chart> 
</Charts>

Or it can contain total layout definition. Of cause, you can use themes to decorate chart. In that case you should apply theme before data would be loaded or reload data after theme would be applied.

To load data from the Chart Data Binding object you should do the following:

  1. Prepare somehow XML document that will contain chart Layout.
  2. Assign this document to the Manco.Chart control.
  3. Apply any themes. (Optional)
  4. Prepare Chart Data Binding object (it’s easy as 1-2-3).
    // Prepare chart data binding object.
    // m_dsTestUI.FoodSales - data table that contains chart data
    // DataOrientation.CategoryInColumn - it menas that chart categories are located in columns
    //		and series are located in rows of the data table.
    m_ChartDataBinding = new ChartDataBinding(m_dsTestUI.FoodSales, DataOrientation.CategoryInColumn);
    // Sets name of the column that contains titles for the category or series depends on the data orientation.
    m_ChartDataBinding.AxisTitleColumnName = "Year";
  5. Fill somehow DataTable with data.
  6. Load data from the array Chart Data Binding object to the chart control (call LoadData method on chart layout).
    // Load chart data from the chart data binding object
    Manco.Chart.Layouts.Layout loLayout = (Manco.Chart.Layouts.Layout)chartControl.ComponentLayout.LayoutList[0];
    loLayout.LoadData(m_ChartDataBinding, false, true);
  7. Call Draw method of the chart control.
    // Draw chart
    chartControl.Draw();

If you’d like to use XSLT transformation you should perform the following steps:

  1. Create XSLT file that will perform transformation of the data set XML in to the chart XML format.
  2. Fill somehow the DataSet table with data you’d like to show in the chart.
  3. Obtain XML from the data set.
  4. Load transformation file and apply it to the XML data you’ve got from the data set.
  5. Assign transformation result document to the Manco.Chart control.
  6. Call Draw method of the chart control.

                                                                                                                                     Back to main page of .Net Chart

Click here to get sample solution for .NET Framework 1.1 (VS 2003).
Click here to get sample solution for .NET Framework 2.0 (VS 2005).
Copyright © 1994-2005 .Net Charting Software Inc. | Division of ASE        |  contact us  |  about us  |  clients  |  privacy policy  |  Add link  |  .Net resources   |  Free services