使用open flash chart的BarGlass时遇到的问题
在使用BarGlass(玻璃柱状图)时要注意在chart.AddElement(bar);之后设置chart.Y_Axis属性若不设置图表什么都不会显示。
如下是正确的调用代码:
BarGlass bar = new BarGlass();
XAxisLabels xLabels = new XAxisLabels();
List<string> xLabelTexts = new List<string>();
List<BarGlassValue> values = new List<BarGlassValue>();
for (int i = 0; i < 20; i++)
{
BarGlassValue bgv = new BarGlassValue(1+random.Next(0,i+5));
bgv.Colour = "#ff0000";
xLabelTexts.Add("第" + i + "个");
values.Add(bgv);
}
bar.Values = values;
xLabels.Values = xLabelTexts;
XAxis xAxis = new XAxis();
xAxis.Labels = xLabels;
chart.X_Axis = xAxis;
chart.AddElement(bar);
YAxis yaxis = new YAxis();
chart.Y_Axis = yaxis;
chart.Y_Axis.SetRange(0, 24, 3);
e.Graph = chart;
XAxisLabels xLabels = new XAxisLabels();
List<string> xLabelTexts = new List<string>();
List<BarGlassValue> values = new List<BarGlassValue>();
for (int i = 0; i < 20; i++)
{
BarGlassValue bgv = new BarGlassValue(1+random.Next(0,i+5));
bgv.Colour = "#ff0000";
xLabelTexts.Add("第" + i + "个");
values.Add(bgv);
}
bar.Values = values;
xLabels.Values = xLabelTexts;
XAxis xAxis = new XAxis();
xAxis.Labels = xLabels;
chart.X_Axis = xAxis;
chart.AddElement(bar);
YAxis yaxis = new YAxis();
chart.Y_Axis = yaxis;
chart.Y_Axis.SetRange(0, 24, 3);
e.Graph = chart;
相关资源: