Dim Chart As WinForm.Chart '定义一个图表变量
Dim Chart2 As WinForm.Chart
Dim Series As WinForm.ChartSeries '定义一个图系变量
Dim Series2 As WinForm.ChartSeries
Dim t As Table = Tables("表B") '定义一个变量t引用数据表
Dim money As Table=Tables("表A")
Dim tclist As new List(of String)
tclist.AddRange(e.sender.Text.split(","))
Dim sm As Integer = DataTables("表A").Compute("Sum(收入)")',"套餐名称 in ('" & e.Sender.Text.replace(",","','") & "')") '计算收入
Chart= Forms("窗口1").Controls("Chart1") ' 引用窗口中的图表
Chart.VisualEffect = True '加上这一行,让你的图表更漂亮
Chart.ChartType = ChartTypeEnum.Pie '图表1类型改为pie
Chart.SeriesList.Clear()'清除
Chart2=Forms("窗口1").Controls("Chart2") ' 引用窗口中的图表
Chart2.VisualEffect = True '加上这一行,让你的图表更漂亮
Chart2.ChartType = ChartTypeEnum.Bar '图表1类型改为pie
Chart2.SeriesList.Clear()'清除
Series2=Chart2.SeriesList.Add()
For Each r As Row In t.Rows
If tclist.Contains(r("套餐名称")) Then
Series = Chart.SeriesList.Add() '增加一个图系
Series.Length = 1 '一个系列只能包括一个值
Series.Text = r("套餐名称") & "(" & r("套餐金额") & ")" '设置图系的标题
Series.Y(0) = r("套餐金额") '指定值
Series.DataLabelText = Math.Round(r("套餐金额")*100/sm,2) & "%" '计算百分比
series2.Length += 1
Series2.X(series2.Length-1) = series2.Length
Series2.Y(series2.Length-1) = r("套餐数量")
Chart2.AxisX.SetValueLabel(series2.Length, r("套餐名称") & "(" & r("套餐数量") & ")") '指定字符表示
End If
Next
Chart.LegendVisible = True '显示图列
Chart.LegendCompass= CompassEnum.East '图列显示在东方(右方)
Chart2.AxisX.AnnoWithLabels = True '启用字符标示