Dim Chart As WinForm.Chart '定义一个图表变量
Dim Series As WinForm.ChartSeries '定义一个图系变量
Dim t As Table = Tables("顾客类别人数统计") '定义一个变量tbl引用数据表
Dim sm As Integer = t.Compute("Sum(人数)") '计算总数量
'Dim lst As List(Of String) = t.GetValues("顾客类别一") '获得产品名称集合
Chart= e.Form.Controls("Chart1") ' 引用窗口中的图表
Chart.ChartType = ChartTypeEnum.Bar '设置图表类型
'Chart.DataSource = "顾客类别人数统计" '设置绑定表
Chart.SeriesList.Clear() '清除图表原来的图系
Series = Chart.SeriesList.Add() '增加一个图系
'Series.X.DataField = "顾客类别一" 'X轴绑定到月份列
'Series.Y.DataField = "人数" 'Y轴绑定到数量列
'Chart.AxisX.AnnoRotation = - 20 'X轴标示逆时针旋转45度
Series.Length = t.Rows.Count '设置图系的长度
For i As Integer = 0 To t.Rows.Count - 1 '指定每个数据点的位置
Series.X(i) = i '指定水平坐标
Series.Y(i) = t.Rows(i)("人数") '指定垂直坐标
Chart.AxisX.SetValueLabel(i, t.Rows(i)("顾客类别一")) '指定字符表示
Series.DataLabelText = t.Rows(i)("人数") & vbcrlf & Math.Round(t.Rows(i)("人数")*100/sm,2) & "%" '计算百分
Next
Chart.AxisX.AnnoWithLabels = True '启用字符标示
'For Each r As Row In t.Rows
'Series.DataLabelText = Math.Round(r("人数")*100/sm,2) & "%" '计算百分比
'Next
'Series.DataLabelText = "{#YVAL}" & "(" & 占比 & ")"