Looking for a contract position
in Toronto area as a Senior .NET Developer
Toronto, ON, M6P 2P2
Tel: 647.328.3809
Email: 

ASP.NET Charting Control

Not a long time ago Microsoft charting controls was announced. It's a great controls. I used Syncfusion to make graphics, but it was too expensive. But now anybody can create graphics for free.

After installation this files there are new item in Data page in Visual studio toolbox.

image 
You need drag and drop it on the web page.

image

<asp:Chart ID="Chart1" runat="server">
            <series>
                <asp:Series Name="NumberOfEmployees" XValueMember="Year" YValueMembers="NumberOfPeople">
                </asp:Series>
            </series>
            <chartareas>
                <asp:ChartArea Name="ChartArea1">
                <AxisX LineColor = "Blue"></AxisX> 
                <AxisY LineColor = "Purple"></AxisY> 
                </asp:ChartArea>
            </chartareas>
        </asp:Chart>

As a DataSource it was used DataTable. Just add this code to Page_Load

                var table = new DataTable();
                table.Columns.Add("Year", typeof(int));
                table.Columns.Add("NumberOfPeople", typeof(long));
                table.Columns.Add("Lbl");
                var row = table.NewRow();
                row["Year"] = 2000;
                row["NumberOfPeople"] = 15;
                table.Rows.Add(row);
                row = table.NewRow();
                row["Year"] = 2001;
                row["NumberOfPeople"] = 35;
                table.Rows.Add(row);
               .......
                row = table.NewRow();
                row["Year"] = 2008;
                row["NumberOfPeople"] = 1390;
                table.Rows.Add(row);
                Chart1.DataSource = table;
                Chart1.DataBind(); 

After run the page you get this graphic.

image

To change the style you can add this code to the page load method

Chart1.Series["NumberOfEmployees"]["DrawingStyle"] = cbCilinder.Checked ? "Cylinder" : "Default"; 

And appearance for the graphic will be much more better.

image

 
Powered by AtomicCms content management system