此主题相关图片如下:分布图.jpg
代码如下:
Dim Chart2 As WinForm.Chart '定义一个图表变量
Dim Series2 As WinForm.ChartSeries '定义一个图系变量
Chart2 = e.Form.Controls("Chart2") ' 引用窗口中的图表
Chart2.SeriesList.Clear() '清除图表原来的图系
Chart2.VisualEffect = True '加上这一行,让你的图表更漂亮
Chart2.ChartType = ChartTypeEnum.Pie '图表1类型改为Bar(条形)
Dim total As Double = DataTables(tbl.name).Compute("Sum(金额)") '计算总金额
For Each s1 As String In DataTables(tbl.name).GetValues(s)
Series2 = Chart2.SeriesList.Add() '每年一个图系
Dim sum As Double = DataTables(tbl.name).Compute("Sum(金额)",s & " = '" & s1 & "'")
Series2.Length = 1 '一个系列只能包括一个值
Series2.Text = s1 & "(" & sum & ")" '设置图系的标题
Series2.Y(0) = sum '指定扇形值
Series2.DataLabelText = Math.Round(sum *100/Total,2) & "%" '计算百分比
Next
Chart2.LegendVisible = True '显示图例
Chart2.LegendCompass= CompassEnum.East '图列显示位置(底端)
上面的代码执行后生成的图表如上所示,但为何右边是七个力例,但左边只显示5个百分比?
谢谢!