Dim b1 As New SQLCrossTableBuilder("统计表1","项目信息主表")
b1.C
b1.HGroups.AddDef("获取方式") '根据获取方式分组
b1.VGroups.AddDef("电压等级")'"心理价位_{0}")
b1.Totals.AddDef("项目编号",AggregateEnum.Count)
b1.Filter = "获取日期 >= #" & e.Form.Controls("DateTimePicker1").Value & "# And 获取日期 <= #" & e.Form.Controls("DateTimePicker2").Value & "#"
b1.HorizontalTotal = True
b1.VerticalTotal = True
b1.HorizontalProportion = True '水平份额
'b1.VerticalProportion = True
Tables("主窗口_Table1").DataSource = b1.BuildDataSource()
For Each da As DataCol In Tables("主窗口_Table1").DataTable.DataCols '设置份额0.00格式
If da.Caption.Contains("份额") Then
da.SetFormat("#0.00%")
End If
Next
Tables("主窗口_Table1").SetHeaderRowHeight(40) '设置表头高度,放在自动列宽之前,放在按钮控件上
Tables("主窗口_Table1").Cols.Frozen = 1
Tables("主窗口_Table1").AutoSizeCols()
For Each cl As Col In Tables("主窗口_Table1").Cols '整表居中
cl.TextAlign = TextAlignEnum.Center
Next
Dim Chart As WinForm.Chart '定义一个图表变量
Dim Series As WinForm.ChartSeries '定义一个图系变量
Dim t As Table = Tables("主窗口_Table1") '定义一个变量t引用数据表
Chart = e.Form.Controls("Chart1") ' 引用窗口中的图表
Chart.VisualEffect = True '加上这一行,让你的图表更漂亮
Chart.ChartType = ChartTypeEnum.Bar '图表类型该为Bar(条形)
'Chart.DataSource = "统计表1" '设置绑定表
Chart.AxisY.Text = "数量(个)"
Chart.SeriesList.Clear() '清除图表原来的图系
Series = Chart.SeriesList.Add() '增加一个图系
Series.Length = t.Rows.Count '图系的数据点数等于表的行数
Series.Text = "110kV"
For i As Integer = 0 To t.Rows.Count - 1 '指定每个数据点的位置
Series.X(i) = i '指定水平坐标
Series.Y(i) = t.Rows(i)("项目编号_1") '指定垂直坐标
Chart.AxisX.SetValueLabel(i, t.Rows(i)("获取方式"))
Next
Series = Chart.SeriesList.Add() '增加第二个图系
Series.Text = "220kV"
Series.Length = t.Rows.Count '图系的数据点数等于表的行数
For i As Integer = 0 To t.Rows.Count - 1 '指定每个数据点的位置
Series.X(i) = i '指定水平坐标
Series.Y(i) = t.Rows(i)("项目编号_2") '指定垂直坐标
Chart.AxisX.SetValueLabel(i, t.Rows(i)("获取方式"))
Next
Chart.AxisX.AnnoWithLabels = True '启用字符标示
Chart.LegendVisible = True '显示图列
Chart.LegendCompass= CompassEnum.South '图列显示在南方(底端)
'Series.DataLabelText = "{#YVAL}"
Chart.AxisX.AnnoRotation = 0 'X轴标示逆时针旋转45度