Dim Chart As WinForm.Chart '定义一个图表变量
Dim Series As WinForm.ChartSeries '定义一个图系变量
Chart = e.Form.Controls("Chart1") ' 引用窗口中的图表
Chart.VisualEffect = True '加上这一行,让你的图表更漂亮
Chart.ChartType = ChartTypeEnum.Bar '图表类型该为Bar(条形)
Chart.DataSource = "Sheet2" '设置绑定表
Chart.SeriesList.Clear() '清除图表原来的图系
Chart.SeriesList2.Clear()
Series = Chart.SeriesList.Add() '增加第一个图系
Series.Text = "计划上旬"
Series.X.DataField = "产品号" 'X轴绑定到产品列
Series.Y.DataField = "计划上旬" 'Y轴绑定到数量列
Series = Chart.SeriesList.Add() '增加第二个图系
Series.Text = "计划中旬"
Series.X.DataField = "产品号" 'X轴绑定到产品列
Series.Y.DataField = "计划中旬" 'Y轴绑定到数量列
Series = Chart.SeriesList.Add() '增加第二个图系
Series.Text = "计划下旬"
Series.X.DataField = "产品号" 'X轴绑定到产品列
Series.Y.DataField = "计划下旬" 'Y轴绑定到数量列
Chart.AxisY.text = "计划"
Chart.ChartType2 = ChartTypeEnum.Bar
Series = Chart.SeriesList2.Add() '增加第一个图系
Series.Text = "完成上旬"
Series.X.DataField = "产品号" 'X轴绑定到产品列
Series.Y.DataField = "完成上旬" 'Y轴绑定到数量列
Series = Chart.SeriesList2.Add() '增加第二个图系
Series.Text = "完成中旬"
Series.X.DataField = "产品号" 'X轴绑定到产品列
Series.Y.DataField = "完成中旬" 'Y轴绑定到数量列
Series = Chart.SeriesList2.Add() '增加第二个图系
Series.Text = "完成下旬"
Series.X.DataField = "产品号" 'X轴绑定到产品列
Series.Y.DataField = "完成下旬" 'Y轴绑定到数量列
Chart.AxisY2.text = "完成"
Chart.AxisY.Min = 0 '指定Y轴的最小值
Chart.AxisY.Max =200 '指定Y轴的最大值
Chart.AxisY2.Min = 0 '指定Y轴的最小值
Chart.AxisY2.Max =200 '指定Y轴的最大值
Chart.BarClusterWidth = 80
Chart.BarClusterWidth = 20
Chart.LegendVisible = True '显示图列
Chart.Stacked = True
Chart.Stacked2 = True
Chart.LegendCompass= CompassEnum.South '图列显示在南方(底端)