结合Bindows生成折线图[代码]
还是用mshtml的那个项目中……
Bindows还不是很熟,使用的是ChartTest.xml Sample
用字符串构造的,高手勿笑
代码如下:
1
/// <summary>
2
/// 生成当前系统时间TimeStamp,作为输出文件名的一部分使用
3
/// </summary>
4
/// <returns>格式如"20050421123120"的字符串</returns>
5
private string CurTimeStamp()
6
{
7
System.Text.StringBuilder sbCN = new System.Text.StringBuilder(20);
8
9
sbCN.Append(System.DateTime.Now.ToShortDateString());
10
11
sbCN.Replace("-", "");
12
13
sbCN.Append(System.DateTime.Now.ToShortTimeString());
14
15
sbCN.Replace(":", "");
16
17
sbCN.Append(System.DateTime.Now.Millisecond.ToString());
18
19
return sbCN.ToString();
20
}
21
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
2
![](/Images/OutliningIndicators/InBlock.gif)
3
![](/Images/OutliningIndicators/InBlock.gif)
4
![](/Images/OutliningIndicators/ExpandedBlockEnd.gif)
5
![](/Images/OutliningIndicators/None.gif)
6
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
7
![](/Images/OutliningIndicators/InBlock.gif)
8
![](/Images/OutliningIndicators/InBlock.gif)
9
![](/Images/OutliningIndicators/InBlock.gif)
10
![](/Images/OutliningIndicators/InBlock.gif)
11
![](/Images/OutliningIndicators/InBlock.gif)
12
![](/Images/OutliningIndicators/InBlock.gif)
13
![](/Images/OutliningIndicators/InBlock.gif)
14
![](/Images/OutliningIndicators/InBlock.gif)
15
![](/Images/OutliningIndicators/InBlock.gif)
16
![](/Images/OutliningIndicators/InBlock.gif)
17
![](/Images/OutliningIndicators/InBlock.gif)
18
![](/Images/OutliningIndicators/InBlock.gif)
19
![](/Images/OutliningIndicators/InBlock.gif)
20
![](/Images/OutliningIndicators/ExpandedBlockEnd.gif)
21
![](/Images/OutliningIndicators/None.gif)
1
/// <summary>
2
/// 折线图,要求视图的第一个字段为横坐标的值(Series),从中间字段开始的其余字段为指标的值(Categories)
3
/// </summary>
4
/// <param name="标题">Bidows窗体显示的标题</param>
5
/// <param name="文件名">保存的文件名</param>
6
/// <param name="宽度">Bindows窗体的宽度</param>
7
/// <param name="高度">Bindows窗体的高度</param>
8
/// <param name="视图">使用的视图</param>
9
/// <param name="中间字段">构造的视图可能要包含多余的字段,设定此值介定</param>
10
/// <param name="查询条件">视图的筛选条件</param>
11
private void LineChart(string 标题, string 文件名, int 宽度, int 高度, string 视图, int 中间字段, string 查询条件)
12
{
13
//当前TimeStamp
14
string sbCN = this.CurTimeStamp();
15
16
mshtml.IHTMLWindow2 win2 = this.doc.parentWindow;
17
18
System.Text.StringBuilder sbContent = new System.Text.StringBuilder(100);
19
20
sbContent.Append("<?xml version=\"1.0\" ?>\n");
21
22
sbContent.Append("<application>\n");
23
24
sbContent.Append("<window caption=\"" + 标题 + "\" width=\"" + 宽度.ToString() + "\" height=\"" + 高度.ToString() + "\" centered=\"true\"/>\n");
25
26
sbContent.Append("<resources>\n");
27
28
sbContent.Append("<script>\n");
29
30
sbContent.Append("<![CDATA[\n");
31
32
sbContent.Append("function " + 文件名 + sbCN.ToString() + "() {\n");
33
34
sbContent.Append("var win = application.getWindow();\n");
35
36
sbContent.Append("var g = new BiGraph;\n");
37
38
string strSQL = "SELECT * FROM " + 视图 + " WHERE " + 查询条件;
39
40
System.Data.DataSet dsResult = HEWin.Sys.sysDb.GetDataSetBySql(strSQL, "Result");
41
42
sbContent.Append("g.setCategories([\n");
43
44
//Series
45
for (int loop = 0; loop < dsResult.Tables["Result"].Rows.Count; loop ++)
46
sbContent.Append("new BiChartCategory(g, \"c" + System.Convert.ToString(loop + 1) + "\", \"" + dsResult.Tables["Result"].Rows[loop][0].ToString() + "\"),");
47
48
sbContent.Remove(sbContent.Length - 1, 1);
49
50
sbContent.Append("]);\n");
51
52
strSQL = "SELECT syscolumns.name, syscolumns.colid FROM syscolumns INNER JOIN sysobjects ON syscolumns.id = sysobjects.id WHERE (sysobjects.name = N'" + 视图 + "') ORDER BY syscolumns.colid";
53
54
System.Data.DataSet dsTable = HEWin.Sys.sysDb.GetDataSetBySql(strSQL, "Table");
55
56
int intStart = 1;
57
58
//Categories
59
for (int i = 中间字段; i < dsTable.Tables["Table"].Rows.Count; i ++)
60
{
61
sbContent.Append("g.addSeries( new BiChartSeries(g, \"s" + intStart.ToString() + "\", \"" + dsTable.Tables["Table"].Rows[i]["name"].ToString() + "\", [");
62
63
for (int j = 0; j < dsResult.Tables["Result"].Rows.Count; j ++)
64
sbContent.Append(dsResult.Tables["Result"].Rows[j][i].ToString() + ",");
65
66
sbContent.Remove(sbContent.Length - 1, 1);
67
68
sbContent.Append("]) );\n");
69
70
intStart ++;
71
}
72
73
sbContent.Append("win.add(g);\n");
74
75
sbContent.Append("g.update();\n");
76
77
sbContent.Append("g.setLocation(0, 0);\n");
78
79
sbContent.Append("g.setRight(0);\n");
80
81
sbContent.Append("g.setBottom(0);\n");
82
83
sbContent.Append("}\n");
84
85
sbContent.Append(文件名 + sbCN + ".main = function () { new " + 文件名 + sbCN.ToString() + "; };\n");
86
87
sbContent.Append("]]>\n");
88
89
sbContent.Append("</script>\n");
90
91
sbContent.Append("</resources>\n");
92
93
sbContent.Append("</application>\n");
94
95
string strFileName = 文件名 + sbCN + ".xml";
96
97
string strRet = System.IO.Path.Combine(System.IO.Directory.GetCurrentDirectory(), @"html\html\bindows\launcher\" + strFileName);
98
99
System.IO.StreamWriter swResult = new System.IO.StreamWriter(strRet, false, System.Text.Encoding.UTF8);
100
101
swResult.Write(sbContent.ToString());
102
103
swResult.Close();
104
105
win2.execScript("biExec('../html', '" + strFileName + "', false, 0, 'one', true);", "JavaScript");
106
107
win2 = null;
108
109
dsResult.Dispose();
110
111
}
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
2
![](/Images/OutliningIndicators/InBlock.gif)
3
![](/Images/OutliningIndicators/InBlock.gif)
4
![](/Images/OutliningIndicators/InBlock.gif)
5
![](/Images/OutliningIndicators/InBlock.gif)
6
![](/Images/OutliningIndicators/InBlock.gif)
7
![](/Images/OutliningIndicators/InBlock.gif)
8
![](/Images/OutliningIndicators/InBlock.gif)
9
![](/Images/OutliningIndicators/InBlock.gif)
10
![](/Images/OutliningIndicators/ExpandedBlockEnd.gif)
11
![](/Images/OutliningIndicators/None.gif)
12
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
13
![](/Images/OutliningIndicators/InBlock.gif)
14
![](/Images/OutliningIndicators/InBlock.gif)
15
![](/Images/OutliningIndicators/InBlock.gif)
16
![](/Images/OutliningIndicators/InBlock.gif)
17
![](/Images/OutliningIndicators/InBlock.gif)
18
![](/Images/OutliningIndicators/InBlock.gif)
19
![](/Images/OutliningIndicators/InBlock.gif)
20
![](/Images/OutliningIndicators/InBlock.gif)
21
![](/Images/OutliningIndicators/InBlock.gif)
22
![](/Images/OutliningIndicators/InBlock.gif)
23
![](/Images/OutliningIndicators/InBlock.gif)
24
![](/Images/OutliningIndicators/InBlock.gif)
25
![](/Images/OutliningIndicators/InBlock.gif)
26
![](/Images/OutliningIndicators/InBlock.gif)
27
![](/Images/OutliningIndicators/InBlock.gif)
28
![](/Images/OutliningIndicators/InBlock.gif)
29
![](/Images/OutliningIndicators/InBlock.gif)
30
![](/Images/OutliningIndicators/InBlock.gif)
31
![](/Images/OutliningIndicators/InBlock.gif)
32
![](/Images/OutliningIndicators/InBlock.gif)
33
![](/Images/OutliningIndicators/InBlock.gif)
34
![](/Images/OutliningIndicators/InBlock.gif)
35
![](/Images/OutliningIndicators/InBlock.gif)
36
![](/Images/OutliningIndicators/InBlock.gif)
37
![](/Images/OutliningIndicators/InBlock.gif)
38
![](/Images/OutliningIndicators/InBlock.gif)
39
![](/Images/OutliningIndicators/InBlock.gif)
40
![](/Images/OutliningIndicators/InBlock.gif)
41
![](/Images/OutliningIndicators/InBlock.gif)
42
![](/Images/OutliningIndicators/InBlock.gif)
43
![](/Images/OutliningIndicators/InBlock.gif)
44
![](/Images/OutliningIndicators/InBlock.gif)
45
![](/Images/OutliningIndicators/InBlock.gif)
46
![](/Images/OutliningIndicators/InBlock.gif)
47
![](/Images/OutliningIndicators/InBlock.gif)
48
![](/Images/OutliningIndicators/InBlock.gif)
49
![](/Images/OutliningIndicators/InBlock.gif)
50
![](/Images/OutliningIndicators/InBlock.gif)
51
![](/Images/OutliningIndicators/InBlock.gif)
52
![](/Images/OutliningIndicators/InBlock.gif)
53
![](/Images/OutliningIndicators/InBlock.gif)
54
![](/Images/OutliningIndicators/InBlock.gif)
55
![](/Images/OutliningIndicators/InBlock.gif)
56
![](/Images/OutliningIndicators/InBlock.gif)
57
![](/Images/OutliningIndicators/InBlock.gif)
58
![](/Images/OutliningIndicators/InBlock.gif)
59
![](/Images/OutliningIndicators/InBlock.gif)
60
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
61
![](/Images/OutliningIndicators/InBlock.gif)
62
![](/Images/OutliningIndicators/InBlock.gif)
63
![](/Images/OutliningIndicators/InBlock.gif)
64
![](/Images/OutliningIndicators/InBlock.gif)
65
![](/Images/OutliningIndicators/InBlock.gif)
66
![](/Images/OutliningIndicators/InBlock.gif)
67
![](/Images/OutliningIndicators/InBlock.gif)
68
![](/Images/OutliningIndicators/InBlock.gif)
69
![](/Images/OutliningIndicators/InBlock.gif)
70
![](/Images/OutliningIndicators/InBlock.gif)
71
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
72
![](/Images/OutliningIndicators/InBlock.gif)
73
![](/Images/OutliningIndicators/InBlock.gif)
74
![](/Images/OutliningIndicators/InBlock.gif)
75
![](/Images/OutliningIndicators/InBlock.gif)
76
![](/Images/OutliningIndicators/InBlock.gif)
77
![](/Images/OutliningIndicators/InBlock.gif)
78
![](/Images/OutliningIndicators/InBlock.gif)
79
![](/Images/OutliningIndicators/InBlock.gif)
80
![](/Images/OutliningIndicators/InBlock.gif)
81
![](/Images/OutliningIndicators/InBlock.gif)
82
![](/Images/OutliningIndicators/InBlock.gif)
83
![](/Images/OutliningIndicators/InBlock.gif)
84
![](/Images/OutliningIndicators/InBlock.gif)
85
![](/Images/OutliningIndicators/InBlock.gif)
86
![](/Images/OutliningIndicators/InBlock.gif)
87
![](/Images/OutliningIndicators/InBlock.gif)
88
![](/Images/OutliningIndicators/InBlock.gif)
89
![](/Images/OutliningIndicators/InBlock.gif)
90
![](/Images/OutliningIndicators/InBlock.gif)
91
![](/Images/OutliningIndicators/InBlock.gif)
92
![](/Images/OutliningIndicators/InBlock.gif)
93
![](/Images/OutliningIndicators/InBlock.gif)
94
![](/Images/OutliningIndicators/InBlock.gif)
95
![](/Images/OutliningIndicators/InBlock.gif)
96
![](/Images/OutliningIndicators/InBlock.gif)
97
![](/Images/OutliningIndicators/InBlock.gif)
98
![](/Images/OutliningIndicators/InBlock.gif)
99
![](/Images/OutliningIndicators/InBlock.gif)
100
![](/Images/OutliningIndicators/InBlock.gif)
101
![](/Images/OutliningIndicators/InBlock.gif)
102
![](/Images/OutliningIndicators/InBlock.gif)
103
![](/Images/OutliningIndicators/InBlock.gif)
104
![](/Images/OutliningIndicators/InBlock.gif)
105
![](/Images/OutliningIndicators/InBlock.gif)
106
![](/Images/OutliningIndicators/InBlock.gif)
107
![](/Images/OutliningIndicators/InBlock.gif)
108
![](/Images/OutliningIndicators/InBlock.gif)
109
![](/Images/OutliningIndicators/InBlock.gif)
110
![](/Images/OutliningIndicators/InBlock.gif)
111
![](/Images/OutliningIndicators/ExpandedBlockEnd.gif)
Life is like a boat, and I'm at sea.