open-flash-chart多bar
今天在做项目时需要用到多组bar的比较,以前都是用单个的。突然脑筋转不过弯了,不知道所措。网上搜了老半天也没有结果。
最后只能自己去摸索了。不过最后还算成功了,但是bar.Alpha的值没有设置,所以浪费了我不少时间,还以为一直没有显示出来呢。
原来char默认值是完全透明的啊,以前从来不知道哦。
下面粘出最后实现代码及效果
string year = DateTime.Now.Year.ToString();
string month = DateTime.Now.Month.ToString();
string strWhere = " cs_year='"+year+"' and cs_month='"+month+"'";//查询条件/
PMSTASK.Business.CITCPMS_SQA bSqa = new PMSTASK.Business.CITCPMS_SQA();
DataTable dt = bSqa.GetChartData(strWhere).Tables[0]; ;
if (dt.Rows.Count > 0)
{
OpenFlashChart.OpenFlashChart chart = new OpenFlashChart.OpenFlashChart();
chart.Title = new Title("SQA检查报告图");
#region 柱状图 yohen 2010-03-24
Bar bar1 = new OpenFlashChart.Bar();
bar1.BarType = BarType.BAR_GLASS;
bar1.Alpha = 0.8;
bar1.Set_Key("不符合项报告", 12);
bar1.Colour = "#0072E3";
Bar bar2 = new Bar();
bar2.BarType = BarType.BAR_GLASS;
bar2.Alpha = 0.8;
bar2.Set_Key("同行评审报告", 12);
bar2.Colour = "#AE0000";
Bar bar3 = new Bar();
bar3.BarType = BarType.BAR_GLASS;
bar3.Alpha = 0.8;
bar3.Set_Key("质量保证计划", 12);
bar3.Colour = "#64A600";
List<object> values1 = new List<object>();
List<object> values2 = new List<object>();
List<object> values3 = new List<object>();
List<string> labels = new List<string>();
foreach (DataRow dr in dt.Rows)
{
string dept = dr["dept_name"].ToString();
double money1 = double.Parse(dr["cs_tracksheet"].ToString());
double money2 = double.Parse(dr["cs_pinshen"].ToString());
double money3 = double.Parse(dr["cs_zhiliang"].ToString());
labels.Add(dept);
BarValue barValue1 = new BarValue(money1);
values1.Add(barValue1);
values2.Add(money2);
values3.Add(money3);
}
bar1.Values = values1;
bar2.Values = values2;
bar3.Values = values3;
chart.AddElement(bar3);
chart.AddElement(bar2);
chart.AddElement(bar1);
XAxis xaxis = new XAxis();
xaxis.Labels.SetLabels(labels);
//xaxis.Steps = 1;
xaxis.Offset = true;
//xaxis.SetRange(-2, 15);
xaxis.Labels.FontSize = 12;
chart.X_Axis = xaxis;
//YAxis yaxis = new YAxis();
//yaxis.Steps = 2;
//yaxis.SetRange(0, 20);
//chart.Y_Axis = yaxis;
//chart.Y_Axis.SetRange(0, max);
bar1.Tooltip = "温馨提示:"+year+"年"+month+"月#key#:#val#份";
bar2.Tooltip = "温馨提示:" + year + "年" + month + "月#key#:#val#份";
bar3.Tooltip = "温馨提示:" + year + "年" + month + "月#key#:#val#份";
string s = chart.ToPrettyString();
Response.Clear();
Response.CacheControl = "no-cache";
Response.Write(s);
Response.End();
#endregion
}