Dim Chart As WinForm.Chart '定义一个图表变量
Dim Series As WinForm.ChartSeries '定义一个图系变量
Chart=e.form.Controls("Chart1") ' 引用窗口中的图表
Chart.SeriesList.Clear() '清除图表原来的图系
Chart.VisualEffect = True '加上这一行,让你的图表更漂亮
Chart.ChartType = ChartTypeEnum.Pie '图表1类型改为Bar(条形)
Dim nms1() As String = {"经营汇总","支出汇总"}
Dim nms2() As String = {"变动金额","支出金额"}
Dim nms3() As String = {"经营日期","支持日期"}
Dim nms4() As String = {"经营项目","支出项目"}
Dim cls() = {Color.red, Color.blue}
For i As Integer = 0 To nms1.Length - 1
Dim d As Date = new Date(Date.Today.Year, Date.Today.Month, 1)
For Each s As String In DataTables(nms1(i)).GetValues(nms4(i), nms4(i) & " Is not null And " & nms3(i) & " >= #" & d & "# and " & nms3(i) & " < #" & d.AddMonths(1) & "#")
Dim sum As Double = DataTables(nms1(i)).compute("sum(" & nms2(i) & ")", nms4(i) & "='" & s & "' and " & nms3(i) & " >= #" & d & "# and " & nms3(i) & " < #" & d.AddMonths(1) & "#")
Series = Chart.SeriesList.Add() '增加一个图系
Series.Length = 1 '一个系列只能包括一个值
Series.Text = s & "(" & sum & ")" '设置图系的标题
Series.Y(0) = sum
Series.TooltipText = s & " : {#YVAL}" '显示数据
Series.DataLabelText = sum
Series.FillColor = cls(i)
Next
Next
For Each s As String In DataTables("负载汇总").GetValues("欠款名称", "欠款名称 Is not null And 欠款日期 >= #" & d & "# and 欠款日期 < #" & d.AddMonths(1) & "#")
Dim dr As DataRow = DataTables("负载汇总").Find("欠款名称 ='" & s & "' And 欠款日期 >= #" & d & "# and 欠款日期 < #" & d.AddMonths(1) & "#","欠款日期 desc")
Series = Chart.SeriesList.Add() '增加一个图系
Series.Length = 1 '一个系列只能包括一个值
Series.Text = s & "(" & dr("欠款金额") & ")" '设置图系的标题
Series.Y(0) = sum
Series.TooltipText = s & " : {#YVAL}" '显示数据
Series.DataLabelText = dr("欠款金额")
'Series.FillColor = cls(i)
Next
Chart.LegendVisible = True '显示图列