OpenFlashChart之柱状图(Bar)
今天用到OpenFlashChart,作个记录:
首先到官网下载需要引入的相关文件,比如OpenFlashChart.dll和flash文件open-flash-chart-SimplifiedChinese.swf或者open-flash-chart.swf。
Code
1 //设置图表
2 var chart = new OpenFlashChart.OpenFlashChart
3 {
4 Title = { Text = "test", Style = "color:#9ACD32;font-weight:bold;font-size:20px;" },
5 X_Axis = { GridColour = "#ffffff", Colour = "#9ACD32", Labels = { Color = "#708090" } },
6 Y_Axis = { GridColour = "#ffffff", Colour = "#9ACD32", Labels = { Color = "#708090" } },
7 Bgcolor = "#ffffff",
8 };
9 chart.X_Axis.SetLabels(data2);
10 chart.Y_Axis.SetRange(0,100,5);
11
12 //柱状
13 var bar = new OpenFlashChart.Bar
14 {
15 Values = data,
16 DotStyleType =
17 {
18 Tip = "#x_label#<br>#val#",
19 DotSize = 5,
20 Colour = "#9ACD32"
21 },
22 Colour = "#9ACD32"
23 };
24 bar.Text = "最小值";
25 chart.AddElement(bar);
26
27 var bar1 = new OpenFlashChart.Bar
28 {
29 Values = data1,
30 DotStyleType =
31 {
32 Tip = "#x_label#<br>#val#",
33 DotSize = 5,
34 Colour = "#ff0000"
35 },
36 Colour = "#ff0000"
37 };
38 bar1.Text = "最大值";
39
40 chart.AddElement(bar1);
41
42 //返回响应
43 Response.Clear();
44 Response.CacheControl = "no-cache";
45 Response.Write(chart.ToPrettyString());
JS代码:
swfobject.embedSWF("../flash/open-flash-chart-SimplifiedChinese.swf", "chartBydate", "60%", "200", "9.0.0", "expressInstall.swf", { "data-file": "chartFile/ChartByArea.aspx?param=" + param });
其他图表的使用可参见这篇:http://blog.csdn.net/liaolian9948/archive/2009/11/23/4857302.aspx