Thursday, February 25, 2010

Technical: Visualizations using ASP.NET Charting controls.

Hi Friends,

I have a good news for you. Now showing a chart in our ASP.NET page or in our Windows Application is as easy as showing a datagrid or a table.

Microsoft had given us a visualization toolkit which gives us a facility to just drag & drop a chart control on our page & show our data in a chart format.

.NET Visualization toolkit gives us a dlls: System.Web.DataVisualization.dll and System.Web.DataVisualization.Design.dll. Add reference to these dlls in your application.

Write an import statement in your code behind:
using System.Web.UI.DataVisualization.Charting;

Now, drag & drop chart control to your page.
Please find below some basic settings of chart:

Title -
You can set the title of chart
chart.Titles.Add(title);

ChartType -
You can set ChartType as-
chart.Series[0].ChartType = SeriesChartType.Column;

Data -
You can set data of the chart using method-
chart.Series[0].Points.Add(DataPoint);

Legend -
You can set legend as-
chart.Series[0].LegendText= LegendText;

Thankas for reading my post.

Happy Coding..!!

1 comment: