Create a Statistical Chart using ASP. NET

Source: Internet
Author: User

Yesterday, I played a league of legends. When I saw this chart, I used it as an example to create a demo of chart statistics.

 

 

Select chart controls:

The first thing that comes to mind is the Chartlet chart control, which is a free chart control designed for ASP. NET. It is used to dynamically convert database data into statistical charts on the ASP. NET page.

Open the dll that VS references the control, and then follow the steps to introduce the control.

After the introduction, a chart item is added to the toolbox and the control is directly dragged into the page.

 

It automatically registers the control:

<% @ Register assembly = "Chartlet" namespace = "FanG" tagprefix = "PC3" %>

 

Database Design:

The table fields are as follows:

Then add the corresponding data

 

Page design:

Add several simple buttons

<Input id = "a" type = "checkbox" value = ", struck as kill" runat = "server"/> kill a hero <br/>
<Input id = "B" type = "checkbox" value = ", dead as death" runat = "server"/> death <br/>
<Input id = "c" type = "checkbox" value = ", assists as assists" runat = "server"/> assists <br/>

 

Set control properties and bind data:

 

Private void BindChartlet ()
{
Bool flag = true;
Chartlet1.ChartTitle. Text = "";
Chartlet1.MaxValueY = 25;
Chartlet1.MinValueY = 0;
Chartlet1.ChartType = FanG. Chartlet. ChartTypes. HBar; // convert the image to a horizontal layout.
Chartlet1.Tips. Show = true;
Chartlet1.AppearanceStyle = FanG. Chartlet. AppearanceStyles. HBar_2D_Breeze_FlatCrystal_NoGlow_NoBorder;
Chartlet1.Crystal. Contraction = 2;
StringBuilder SQL = new StringBuilder ();
SQL. Append ("select Player as Hero ");
Foreach (Control c in this. form1.Controls)
{
If (c. GetType (). ToString () = "System. Web. UI. HtmlControls. HtmlInputCheckBox ")
{
If (HtmlInputCheckBox) FindControl (c. ID). Checked = true ){
SQL. Append (HtmlInputCheckBox) FindControl (c. ID). Value );
Flag = false;
}
}
}
If (flag)
{
SQL. Append (", struck as kill, dead as death, assists as assists from dbo. PlayerData ");
}
Else
{
SQL. Append ("from dbo. PlayerData ");
}
Chartlet1.BindChartData (DAL. DbHelperSQL. Query (SQL. ToString ()));
}

 

 

Final effect:

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.