Dim Chart As WinForm.Chart = e.Form.Controls("Chart3") ' 引用窗口中的图表
Dim series As winform.ChartSeries
Chart.SeriesList.Clear() '清除图表原来的图系
Chart.AxisX.ClearValueLabel
Dim tp As DateGroupEnum = 0
For i As Integer = 111 To 115
Dim c As WinForm.RadioButton= e.Form.Controls("Chart3" & i)
If c.Checked Then
Select Case c.Text
Case "销售额"
tp = DateGroupEnum.Year
Case "利润"
tp = DateGroupEnum.Quarter
Case "合计成本"
tp = DateGroupEnum.month
Case "货物成本"
tp = DateGroupEnum.Week
Case "物流成本"
tp = DateGroupEnum.day
Case "其它成本"
tp = DateGroupEnum.day
End Select
Exit For
End If
Next
Dim g As New GroupTableBuilder("统计表1", DataTables("表A"))
g.Groups.AddDef("回款日期", tp, "日期")
g.Totals.AddDef("销售额")
g.Totals.AddDef("货物成本")
g.Totals.AddDef("物流成本")
g.Totals.AddDef("其它成本")
g.Totals.AddDef("合计成本")
g.Totals.AddDef("利润")
g.Build()
Dim t As Table = Tables("统计表1")
t.Sort = "日期"
For i As Integer = 111 To 116
Dim c As WinForm.CheckBox = e.Form.Controls("CheckBox" & i)
If c.Checked Then
Series = Chart.SeriesList.Add() '增加一个图系
Series.Length = t.Rows.Count
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 '图列显示在南方(底端)