|
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. You need drag and drop it on the web page. <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.
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.

|