asp.net Chart 条形柱状图

DataSet ds = DbHelperOleDb.Query(sbSql.ToString());//获取数据源

Chart1.Series.Clear();//清空Series集合,自我感觉显示用例的时候清空下,重新添加容易控制
            foreach (DataRow item in ds.Tables[0].Rows)//添加设置用例图标
            {
                Chart1.Series.Add(item["fund_code"].ToString());//添加一个Series
                Chart1.Series[item["fund_code"].ToString()].Legend = "Legend1";//设置Legend的名称
                Chart1.Series[item["fund_code"].ToString()].LegendText = item["fund_Name"].ToString() + " " + item["total_share"] + "亿份";//设置在用例中显示的内容
                Chart1.Series[item["fund_code"].ToString()].Font = new Font("Microsoft Sans Serif", 6.75f);//设置用例的字体样式
                Chart1.Series[item["fund_code"].ToString()].Palette = ChartColorPalette.BrightPastel;//设置调色板,
                Chart1.Series[item["fund_code"].ToString()].ChartType = SeriesChartType.Bar;//设置图标显示的类型,此处为条形柱状图
                Chart1.Series[item["fund_code"].ToString()].ToolTip = item["fund_Name"].ToString() + " #VAL 亿份";//工具提示
            }
            Chart1.Legends[0].Font = new Font("Microsoft Sans Serif", 6.75f);
            Chart1.DataSource = ds;//设置数据源
            if (Chart1.Series.Count > 0)
            {

      //绑定
                Chart1.Series[0].XValueMember = "fund_code";
                Chart1.Series[0].YValueMembers = "total_share";
            }
            Chart1.DataBind();
            Chart1.ChartAreas[0].AxisX.Interval = 1;//设置轴的间隔

posted @ 2012-07-19 12:45  刘满意  阅读(2257)  评论(0编辑  收藏  举报