Dim Filter As String
With e.Form.Controls("ComboBox线路名称")
If .Value IsNot Nothing Then
Filter = "线路名称 in ('" & .Value.replace(",", "','") & "')"
End If
End With
Dim b As New GroupTableBuilder("按月份统计",DataTables("故障明细"))
b.Groups.AddDef("月份") '根据所属10千伏线路分组
b.Totals.AddDef("计数") '对数量进行统计
b.Filter = Filter
Dim dt As DataTable = b.Build(True) '生成统计表
Dim Chart As WinForm.Chart '定义一个图表变量
Dim Series As WinForm.ChartSeries '定义一个图系变量
Chart= Forms("单线分析").Controls("Chart故障时间") ' 引用窗口中的图表
Chart.ChartType = ChartTypeEnum.Bar '图表类型该为Bar(条形)
Chart.SeriesList.Clear() '清除图表原来的图系
Series = Chart.SeriesList.Add() '增加一个图系
Series.Length = dt.dataRows.Count '设置图系的长度
For i As Integer = 0 To dt.dataRows.Count - 1 '指定每个数据点的位置
Series.X(i) = i '指定水平坐标
Series.Y(i) = dt.dataRows(i)("计数") '指定垂直坐标
Chart.AxisX.SetValueLabel(i, dt.dataRows(i)("月份") & "月") '指定字符表示
Next
Chart.AxisX.AnnoRotation = - 45 'X轴标示逆时针旋转45度
Chart.AxisX.AnnoWithLabels = True '启用字符标示
b = new GroupTableBuilder("按月份统计",DataTables("故障明细"))
b.Groups.AddDef("故障原因一级") '根据所属10千伏线路分组
b.Totals.AddDef("计数") '对数量进行统计
b.Filter = Filter
dt = b.Build(True) '生成统计表
Chart= e.Form.Controls("Chart故障原因一级") ' 引用窗口中的图表
Chart.ChartType = ChartTypeEnum.Bar '图表类型该为Bar(条形)
Chart.SeriesList.Clear() '清除图表原来的图系
Chart.DataTable = dt
Series = Chart.SeriesList.Add() '增加一个图系
Series.X.DataField = "故障原因一级" 'X轴绑定到月份列
Series.Y.DataField = "计数" 'Y轴绑定到数量列
Chart.AxisX.AnnoRotation = - 45 'X轴标示逆时针旋转45度