datacolchanged事件,写代码
If Forms("窗口1").opened Then
Dim Chart As WinForm.Chart '定义一个图表变量
Dim Series As WinForm.ChartSeries '定义一个图系变量
Chart= forms("窗口1").Controls("Chart1") ' 引用窗口中的图表
Chart.DataSource = "物料检验合格率" '设置绑定表
Chart.SeriesList.Clear() '清除图表原来的图系
Chart.AxisX.Major = 2
Series = Chart.SeriesList.Add() '增加一个图系
Series.Text = "合格率基准"
Series.X.DataField = "月份" 'X轴绑定到产品列
Series.Y.DataField = "合格率基准" 'Y轴绑定到数量列
Dim c1Chart1 = Chart.basecontrol
Dim lbls = c1Chart1.ChartLabels
lbls.LabelsCollection.clear
For i As Integer = 0 To Tables("物料检验合格率").Rows.Count-1
Dim lbl As C1.Win.C1Chart.Label = lbls.LabelsCollection.AddNewLabel()
lbl.Text = Format(val(series.y(i)), "0.00%")
lbl.AttachMethod = C1.Win.C1Chart.AttachMethodEnum.DataIndex
lbl.AttachMethodData.GroupIndex = 0
lbl.AttachMethodData.SeriesIndex = 0
lbl.AttachMethodData.PointIndex = i
lbl.style.font = new font("宋体", 10)
lbl.Compass = LabelCompassEnum.south
lbl.Visible = True
Next
Series = Chart.SeriesList.Add() '增加一个图系
Series.Text = "月合格率_18年"
Series.X.DataField = "月份" 'X轴绑定到产品列
Series.Y.DataField = "月合格率_18年" 'Y轴绑定到数量列
Dim c1Chart2 = Chart.basecontrol
Dim lbls1 = c1Chart2.ChartLabels
For i As Integer = 0 To Tables("物料检验合格率").Rows.Count-1
Dim lbl1 As C1.Win.C1Chart.Label = lbls1.LabelsCollection.AddNewLabel()
lbl1.Text = Format(val(series.y(i)), "0.00%")
lbl1.AttachMethod = C1.Win.C1Chart.AttachMethodEnum.DataIndex
lbl1.AttachMethodData.GroupIndex = 0
lbl1.AttachMethodData.SeriesIndex = 1
lbl1.AttachMethodData.PointIndex = i
lbl1.Style.ForeColor = Color.Red
lbl1.style.font = new font("宋体", 10)
lbl1.Compass = LabelCompassEnum.north
lbl1.Visible = True
Next
Series = Chart.SeriesList.Add() '增加一个图系
Series.Text = "月合格率_19年"
Series.X.DataField = "月份" 'X轴绑定到产品列
Series.Y.DataField = "月合格率_19年" 'Y轴绑定到数量列Chart.LegendVisible = True '显示图列
Dim c1Chart3 = Chart.basecontrol
Dim lbls2 = c1Chart3.ChartLabels
For i As Integer = 0 To Tables("物料检验合格率").Rows.Count-1
Dim lbl2 As C1.Win.C1Chart.Label = lbls2.LabelsCollection.AddNewLabel()
lbl2.Text = Format(val(series.y(i)), "0.00%")
lbl2.AttachMethod = C1.Win.C1Chart.AttachMethodEnum.DataIndex
lbl2.AttachMethodData.GroupIndex = 0
lbl2.AttachMethodData.SeriesIndex = 2
lbl2.AttachMethodData.PointIndex = i
lbl2.Style.ForeColor = Color.Red
lbl2.style.font = new font("宋体", 10)
lbl2.Compass = LabelCompassEnum.north
lbl2.Visible = True
Next
Chart.LegendVisible = True '显示图列
Chart.LegendCompass= CompassEnum.South '图列显示在南方(底端)
End If