注意,请将配置销售人员表的"北京"、"南京"、"重庆"等列改为整数型。
Dim Chart As WinForm.Chart '定义一个图表变量
Dim Series As WinForm.ChartSeries '定义一个图系变量
Chart= e.Form.Controls("Chart1") ' 引用窗口中的图表
Chart.SeriesList.Clear() '清除图表原来的图系
Dim nms() As String = {"北京","南京","重庆"}
Dim drs As List(of DataRow) = DataTables("配置销售人员").Select("代理商编号 = '100001'")
Chart.ChartType = ChartTypeEnum.Bar
chart.Stacked = True
For Each nm As String In nms
Series = Chart.SeriesList.Add() '增加一个图系
Series.Length = drs.Count '设置图系的长度
For i As Integer = 0 To drs.Count - 1 '指定每个数据点的位置
Series.X(i) = i '指定水平坐标
Series.Y(i) = drs(i)(nm) '指定垂直坐标
Dim d As Date = drs(i)("登记日期")
Chart.AxisX.SetValueLabel(i, d.Month & "月") '指定字符表示
Series.Text = nm
Next
Next
Chart.LegendVisible = True '显示图列
Chart.AxisX.AnnoWithLabels = True '启用字符标示