Dim Chart As WinForm.Chart '定义一个图表变量
Dim Series As WinForm.ChartSeries '定义一个图系变量
Dim t As Table = Tables("利润表附表") '定义一个变量t引用数据表
Dim sm As Double = t.Compute("Sum(dic(主营业务收入))")
Chart= Forms("终端状态占比分析").Controls("占比1") ' 引用窗口中的图表
Chart.ChartType = ChartTypeEnum.Pie '图表1类型改为Bar(条形)
For Each r As Row In t.Rows
Series = Chart.SeriesList.Add() '增加一个图系
Series.Length = 1 '一个系列只能包括一个值
Series.Text = r("店铺状态") & "(" & r(dic("主营业务收入")) & ")" '设置图系的标题
Series.Y(0) = r(dic("主营业务收入")) '指定值
Series.DataLabelText = Math.Round(r(dic("主营业务收入"))*100/sm,2) & "%" '计算百分比
Next
Chart.LegendVisible = True '显示图列
Chart.VisualEffect = True '加上这一行,让你的图表更漂亮
Chart.LegendCompass= CompassEnum.East '图列显示在东方(右方)
貌似标颜色的这句代码计算不出来
此主题相关图片如下:2.png