This project is read-only.

Single Series Chart, adding data from a datasource.

 

Supose your data is comming from a database in the following way:

 

In your ASPX page you simply need to add a FChart control. It just acts as a place holder for the chart.
Here you’ll also define the width and height of your chart.

 

<%@ Register Assembly="Libero.FusionCharts" Namespace="Libero.FusionCharts.Control" TagPrefix="fcl" %>
 <fcl:FChart runat="server" ID="chtTopSalles" Width="530" Height="300" />

 

In your code behind you will define:

  • The type of chart you want (see supported charts).
  • All appearence properties, as backgroung color, titles, and so on.
  • And the data. Here using the DataSource property.

When you call ShowChart it automatically calls DataBind to parse your data source
to chart's properties, and then, it calls ApplyTemplate to load template's definitions to your chart.

 

// Create a chart
Pie2DChart oChart = new Pie2DChart();
 
// Set properties
oChart.Background.BgColor = "ffffff";
oChart.Background.BgAlpha = 50;
oChart.ChartTitles.Caption = "Top seller (%)";
oChart.ChartTitles.SubCaption = "November";
 
// Set a template
oChart.Template = new Libero.FusionCharts.Template.OfficeTemplate();
 
// Set data
DataTable dtSample = GetSalesDataTable();
oChart.DataSource = dtSample;
oChart.DataTextField = "SallesmanName";
oChart.DataValueField = "PercentTotalSell";
 
// Link the WebControl and the Chart
chtTopSalles.ShowChart(oChart);

Last edited Feb 27, 2011 at 1:13 PM by robertobarbedo, version 13

Comments

No comments yet.