Click here to Skip to main content
15,878,809 members
Articles / Web Development / ASP.NET
Tip/Trick

How to draw charts in asp.net using MS chart

Rate me:
Please Sign up or sign in to vote.
4.50/5 (9 votes)
19 Oct 2011CPOL 46K   8   5

CHARTS in ASP.NET


This article describes you about how to draw a chart in asp.net using MS chart. First we need to install MS chart Software in our system. Here is a link for downloading MSChart. Microsoft Chart Controls for Microsoft .NET Framework 3.5[^]

Refer following link for Installing MS chart adding into vs 2008 toolbox and using MS chart with sample code http://aspnetnova.blogspot.com/2009/01/installing-ms-chart-adding-into-vs-2008.html[^]

After adding ms chart into toolbox Double click on chart control in your toolbox.Chart will be added in your web page like the following.
XML
<asp:Chart ID="Chart1" runat="server">
    <Series>
        <asp:Series Name="Series1">
        </asp:Series>
    </Series>
    <ChartAreas>
        <asp:ChartArea Name="ChartArea1">
        </asp:ChartArea>
    </ChartAreas>
</asp:Chart>

If we wanted to represent more than one attribute then we need to add
XML
<asp:Series Name="Series2" ChartArea="ChartArea1"  Color="#000066">                 
</asp:Series>

in <Series> </Series> tag

Function for creating a chart :
C#
private void fillTempPulseEtc()
        {
                double[] temp = { 0.0, 111.0 };
                double[] time = { -23.0, 23.59 };
                for (int i = 0;i <= 2; i++)
                {
                    Chart1.Series[0].Points.DataBindXY(time, temp);
                }
                Chart1.Series[0].ChartType = System.Web.UI.DataVisualization.Charting.SeriesChartType.Column;

            }

In page load call fillTempPulseEtc() We can select Pie, Point, Area, Doughnut etc charts using
C#
System.Web.UI.DataVisualization.Charting.SeriesChartType.Column;

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
India India
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
QuestionCharts can be created by using chart control and Series Pin
venki Livestrong15-Oct-14 20:47
venki Livestrong15-Oct-14 20:47 
GeneralVery good reference. Pin
Dj Gueds2-Jan-13 1:37
Dj Gueds2-Jan-13 1:37 
GeneralMy vote of 4 Pin
Tareq Newaz Shahriar19-Apr-12 14:49
Tareq Newaz Shahriar19-Apr-12 14:49 
GeneralRe: My vote of 4 Pin
raj ch19-Apr-12 21:34
raj ch19-Apr-12 21:34 
Thank u
GeneralReason for my vote of 4 nothing Pin
MB Seifollahi24-Oct-11 20:31
professionalMB Seifollahi24-Oct-11 20:31 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.