Dim Chart As WinForm.Chart
Dim Series As WinForm.ChartSeries
Dim y As Integer = Date.Today.Year
Dim m As Integer = Date.Today.Month
Dim tb As DataTable = DataTables("表A")
Chart = e.Form.Controls("Chart1")
Chart.ChartType = ChartTypeEnum.Bar
Chart.SeriesList.Clear()
Chart.AxisX.ClearValueLabel '清除所有通过SetValueLabel设置的数值字符标示
Series = Chart.SeriesList.Add()
Series.Length = 6
Dim td As Date = new Date(Date.Today.Year, Date.Today.Month, 1)
For i As Integer = 0 To 5
Dim d As Date= td.AddMonths(-i)
Dim lst As List(Of String) = tb.SQLGetValues("列1","日期 >= '" & d & "' and 日期 < '"
& d.AddMonths(1) & "'")
Series.X(i) = i
Series.Y(i) = val(tb.SQLCompute("Sum(列2)","日期 >= '" & d & "' and 日期 < '"
& d.AddMonths(1) & "' and [列1] = '"
& lst(i) & "'"))
Chart.AxisX.SetValueLabel(i, Format(d, "yyyy-MM"))
Chart.HeaderText="数量(件)" '设置图表的上标题
Chart.AxisX.AnnoWithLabels = True
'启用字符标示
'Chart.LegendVisible = True
'Chart.LegendCompass= CompassEnum.South
Series.DataLabelText
= "{#YVAL}" '图中显示数据
Chart.VisualEffect = True '图更漂亮
Chart.SeriesList(0).LineColor= Color.GreenYellow
Next