Dim Chart As WinForm.Chart = e.Form.Controls("Chart1") ' 引用窗口中的图表
Dim series As winform.ChartSeries
Chart.SeriesList.Clear() '清除图表原来的图系
Chart.AxisX.ClearValueLabel
Dim tp As DateGroupEnum = 0
Dim cbx = e.Form.Controls("ComboBox11")
Select Case cbx.Text
Case "年"
tp = DateGroupEnum.Year
Case "季"
tp = DateGroupEnum.Quarter
Case "月"
tp = DateGroupEnum.month
Case "周"
tp = DateGroupEnum.Week
Case "天"
tp = DateGroupEnum.None
Case Else
tp = DateGroupEnum.None
End Select
Dim g As New GroupTableBuilder("临时统计表", DataTables("表B"))
g.Groups.AddDef("出单日期", tp, "日期")
g.Totals.AddDef("销售合计")
g.Totals.AddDef("采购价")
g.Totals.AddDef("税价")
g.Totals.AddDef("返点")
g.Totals.AddDef("利润和")
g.Build()
Dim t As Table = Tables("临时统计表")
t.Sort = "日期"
For i As Integer = 1 To 6
Dim c As WinForm.CheckBox = e.Form.Controls("CheckBox" & i)
If c.Checked Then
Series = Chart.SeriesList.Add() '增加一个图系
Series.Length = t.Rows.Count
Series.TooltipText = c.Text & " : {#YVAL}"
Series.Text = c.Text
For r As Integer = 0 To t.Rows.Count - 1
Series.X(r) = r
Series.Y(r) = t.Rows(r)(c.Text)
Next
End If
Next
For r As Integer = 0 To t.Rows.Count - 1
Chart.AxisX.SetValueLabel(r, t.Rows(r)("日期")) '指定字符表示
Next
Chart.AxisX.AnnoWithLabels = True '启用字符标示
Chart.VisualEffect = True '加上这一行,让你的图表更漂亮
Chart.LegendVisible = True '显示图列
Chart.AxisX.AnnoRotation = - 45 'X轴标示逆时针旋转45度
Chart.LegendCompass= CompassEnum.South '图列显示在南方(底端)