'--------定义图表1
Dim g As New GroupTableBuilder("统计表3", DataTables("站日耗电量统计"))
g.Groups.AddDef("时间", DateGroupEnum.Year, "年")
g.Totals.AddDef("一号站")
g.Totals.AddDef("二号站")
g.Totals.AddDef("三号站")
g.Totals.AddDef("四号站")
g.Totals.AddDef("五号站")
g.Totals.AddDef("六号站")
g.Totals.AddDef("七号站")
g.Totals.AddDef("八号站")
g.Totals.AddDef("九号站")
g.Build()
MainTable = Tables("统计表3")
Dim zd As String = e.Form.Controls("站点").Text
'----------------------------生成图表------------------------
Dim Chart As WinForm.Chart '定义一个图表变量
Dim Series As WinForm.ChartSeries '定义一个图系变量
Dim t As Table = Tables("统计表3") '定义一个变量t引用数据表
Chart= e.Form.Controls("Chart1") ' 引用窗口中的图表
Chart.AxisX.AnnoFormatString = "0年"
Chart.LegendVisible = True '显示图例
Chart.SeriesList.Clear() '清除图表原来的图系
Chart.AxisX.Major = 1
Chart.AxisY.Major = 1
Chart.ChartType = ChartTypeEnum.Bar '图表类型改为Bar(条形)
Dim n As Integer = 0
For Each z As String In zd.Split(",")
Series = Chart.SeriesList.Add() '增加一个图系
Series.Length = t.Rows.Count '图系的数据点数等于表的行数
Series.Text = "热力站" & (n + 1)
For i As Integer = 0 To t.Rows.Count - 1 '指定每个数据点的位置
Series.X(i) = t.Rows(i)("年") '指定水平坐标
Series.Y(i) = t.Rows(i)(z.replace("热力", "")) '指定垂直坐标
Series.DataLabelText = "{#YVAL}"
Next
n += 1
Next