For i As Integer = 1 To 12
Dim d1 As Date = new Date(1999, i, 1)
Dim d2 As Date = d1.AddMonths(1)
Dim filter As String = "日期 >= '" & Format(d1, "MM.dd") & "' and 日期 < '" & Format(d2, "MM.dd") & "'"
Dim Chart As New ChartBuilder '定义一个图表变量
Dim Series As WinForm.ChartSeries '定义一个图系变量
Dim tbl As DataTable = DataTables("月报表") '定义一个变量tbl引用数据表
Dim lst As List(Of String) = tbl.GetValues("供应商", filter) '获得产品名称集合
Dim sm As Integer = tbl.Compute("count(供应商)", filter) '计算总数量
Chart.VisualEffect = True
Chart.ChartType = ChartTypeEnum.pie '设置图表类型
Chart.HeaderText = i & "月"
For Each gys As String In lst
Series = Chart.SeriesList.Add() '增加一个图系
Series.Length = 1 '一个系列只能包括一个值
Series.Text = gys
Series.Y(0) = tbl.Compute("count(供应商)", "供应商='" & gys & "' and " & filter)
Series.DataLabelText = Math.Round(Series.Y(0)*100/sm,2) & "%" '计算百分比
Next
Chart.LegendVisible = True '显示图列
Chart.LegendCompass= CompassEnum.East '图列显示在东方(右方)
chart.width = 300
Chart.left = 300*(i-1)
Chart.height = 300
e.Form.AddControl(Chart)
Next
e.Form.panel.autoscroll = True