码迷,mamicode.com
首页 > 其他好文 > 详细

BarChart控件的使用

时间:2014-12-29 18:04:28      阅读:176      评论:0      收藏:0      [点我收藏+]

标签:

The HTML Markup

<asp:BarChart ID="BarChart1" runat="server" ChartHeight="300" ChartWidth="450" ChartType="Column"
                ChartTitle="United States versus European,England Widget Production"
                ChartTitleColor="#0E426C" CategoryAxisLineColor="#D08AD9"
                ValueAxisLineColor="#D08AD9" BaseLineColor="#A156AB" >
            <Series>
                 <asp:BarChartSeries Name="United States" BarColor="#6C1E83" />
                <asp:BarChartSeries Name="Europe" BarColor="#D08AD9"/>
                <asp:BarChartSeries Name="England" BarColor="Bule"/>
            </Series>
        </asp:BarChart>

The code behind page

  System.Data.DataTable dt = new System.Data.DataTable();
            dt.Columns.Add("Date");
            dt.Columns.Add("UnitedStates");
            dt.Columns.Add("Europe");
            dt.Columns.Add("England");
            dt.Rows.Add("2007", "20", "24", "56");
            dt.Rows.Add("2008", "47", "67", "39");
            dt.Rows.Add("2009", "55", "16", "78");
            string[] x = new string[dt.Rows.Count];
            decimal[] y1 = new decimal[dt.Rows.Count];
            decimal[] y2 = new decimal[dt.Rows.Count];
            decimal[] y3 = new decimal[dt.Rows.Count];
            for (int i = 0; i < dt.Rows.Count; i++)
            {

                x[i] = dt.Rows[i]["Date"].ToString();
                y1[i] = Convert.ToDecimal(dt.Rows[i]["UnitedStates"]);
                y2[i] = Convert.ToDecimal(dt.Rows[i]["Europe"]);
                y3[i] = Convert.ToDecimal(dt.Rows[i]["England"]);

            }
            BarChart1.CategoriesAxis = String.Join(",", x);
            BarChart1.Series[0].Data = y1;
            BarChart1.Series[1].Data = y2;
            BarChart1.Series[2].Data = y3;

 

BarChart控件的使用

标签:

原文地址:http://www.cnblogs.com/songxia/p/4192129.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!