Click here to Skip to main content
13,861,088 members
Click here to Skip to main content
Add your own
alternative version

Tagged as


57 bookmarked
Posted 1 Apr 2009
Licenced CPOL

Microsoft Chart Controls for the .Net Framework

, 2 Apr 2009
Rate this:
Please Sign up or sign in to vote.
I haven't been impressed by any new technology in a long time…until I downloaded and tried out the new Microsoft Chart Controls for the .Net Framework. It contains charts for both Forms and Asp.Net applications.

I haven't been impressed by any new technology in a long time…until I downloaded and tried out the new Microsoft Chart Controls for the .NET Framework. It contains charts for both Forms and Asp.Net applications. It was easy to put this chart in an Asp.Net page:

The Charts home page is here:

If you want to try it, you need to download these:

Chart Controls for .NET Framework

Chart Controls Add-on for Visual Studio 2008

Chart Controls for .NET Framework Documentation (optional)

To build the chart, I started with an SQLDataSource connected to the NorthWind database. I used a custom SQL String to sum up the sales for each week (7 days) given a beginning OrderDate. For the OrderDate parameter, I used a Calendar control.

I dropped a GridView onto the form and fired it up to make sure the data connectivity was working. Clicking dates on the Calendar, causes the GridView to update immediately.

Next, I dropped the Chart control from the Data tab of the ToolBox. I set the DataSourceID to be the same as the GridView's DataSourceID.

The number of settings in the Chart control can be a bit overwhelming at first but if you dig around and drill down, you will eventually find what you need: With power and flexibility comes complexity.

The final Asp markup code was surprisingly short:

<asp:Chart ID="Chart1" runat="server" 



    BackSecondaryColor="128, 128, 255" 





    Width="400px" Height="300px"

    Style=": 337px; : 18px; position: absolute">
        <asp:Title Name="Title1" 

            Text="Weekly Sales by Day" 

            Font="Times New Roman, 12pt, style=Bold">
        <asp:Series Name="Series1"  


        <asp:ChartArea Name="ChartArea1">
            <Area3DStyle Enable3D="True" />
            <AxisY Title="Dollars">
                <MinorGrid Enabled="True" />
                <LabelStyle Format="{0:C}" />

Of course, I should remove the .00 from the Y Axis, increase the font size of the Y Axis Title, change the format of the X Axis labels to show the day of week, etc. There are tons (and I mean tons) of features with this control….you could spend hours tweaking this thing. But it sure looks good.

I hope you find this useful.

<asp:SqlDataSource ID="SqlDataSource1" runat="server" 

    ConnectionString="<%$ ConnectionStrings:NorthWind %>"

    SELECT OrderDate, Sum(Quantity * Unitprice) as OrdersTotal 
    FROM Orders, [Order Details] 
    WHERE Orders.OrderID = [Order Details].OrderID AND 
       OrderDate BETWEEN @OrderDate AND dateadd(day, 7, @OrderDate) 
    GROUP BY OrderDate  
    ORDER BY OrderDate">





            PropertyName="SelectedDate" />



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


About the Author

Steve Wellens
EndWell Software, Inc.
United States United States
I am an independent contractor/consultant working in the Twin Cities area in Minnesota. I work in .Net, Asp.Net, C#, C++, XML, SQL, Windows Forms, HTML, CSS, etc., etc., etc.

You may also be interested in...


Comments and Discussions

GeneralMy vote of 4 Pin
Supriya Srivastav28-Nov-11 19:57
memberSupriya Srivastav28-Nov-11 19:57 
QuestionHow export chart to power point? Pin
celsoalejo26-Apr-10 6:43
membercelsoalejo26-Apr-10 6:43 
GeneralSilverlight Charting Pin
YuvalKaplan16-Apr-09 19:44
memberYuvalKaplan16-Apr-09 19:44 
GeneralRe: Silverlight Charting Pin
Moodyz19-Aug-09 13:23
memberMoodyz19-Aug-09 13:23 
GeneralNote Pin
Angelo Cresta1-Apr-09 22:28
professionalAngelo Cresta1-Apr-09 22:28 
GeneralRe: Note Pin
Steve Wellens2-Apr-09 2:39
memberSteve Wellens2-Apr-09 2:39 
GeneralRe: Note Pin
David Cunningham2-Apr-09 4:21
adminDavid Cunningham2-Apr-09 4:21 
GeneralRe: Note Pin
mohit.raghav6-Apr-09 14:33
membermohit.raghav6-Apr-09 14:33 

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.

Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web06 | 2.8.190214.1 | Last Updated 2 Apr 2009
Article Copyright 2009 by Steve Wellens
Everything else Copyright © CodeProject, 1999-2019
Layout: fixed | fluid