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设置的数值字符标示
Dim td As Date = new Date(Date.Today.Year, Date.Today.Month, 1)
Dim lst As List(Of String) = tb.SQLGetValues("类型", "类型 is not null")
For Each s As String In lst
series = Chart.SeriesList.Add
series.text = s
series.Length = 6
For i As Integer = 0 To 5
Dim d As Date= td.AddMonths(-i)
Series.X(i) = i
Series.Y(i) = val(tb.SQLCompute("Sum(数量)","日期 >= #" & d & "# and 日期 < #" & d.AddMonths(1) & "# and 类型 = '" & s & "'"))
Chart.AxisX.SetValueLabel(i, Format(d, "yyyy-MM"))
Series.DataLabelText = "{#YVAL}" '图中显示数据
Next
Next
Chart.HeaderText="数量(件)" '设置图表的上标题
Chart.AxisX.AnnoWithLabels = True '启用字符标示
Chart.VisualEffect = True '加上这一行,让你的图表更漂亮
Chart.LegendVisible = True '显示图列
Chart.LegendCompass= CompassEnum.South '图列显示在南方(底端)