Dim Chart As WinForm.Chart '定义一个图表变量
Dim Series As WinForm.ChartSeries '定义一个图系变量
Dim t As Table = Tables("历史数据3") '定义一个变量t引用数据表
Chart = Forms("窗口2").Controls("Chart2") ' 引用窗口中的图表
Chart.ChartType = ChartTypeEnum.XYPlot '图表类型改为Bar(条形)
Chart.DataSource = "历史数据3" '设置绑定表
Dim max As Single = t.Compute("Max(MA5)")
Dim min As Single = t.Compute("Min(MA5)")
chart.AxisX.ClearValueLabel
Chart.AxisX.Text = "日期"
Chart.AxisY.Text = "MA值"
Chart.AxisY.Min = min '指定Y轴的最小值
Chart.AxisY.Max = max '指定Y轴的最大值
Chart.SeriesList.Clear() '清除图表原来的图系
For Each c As Col In t.Cols
If c.Name <> "日期" Then
If c.Name <> "序号" Then
Series = Chart.SeriesList.Add() '增加一个图系
Series.Text = c.Name '设置图系的标题
Series.X.DataField = "序号" 'X轴绑定到产品列
Series.Y.DataField = c.Name '设置Y轴的绑定列
End If
End If
Next
For i As Integer = 0 To nn2
If i Mod 5 = 0 Then
Chart.AxisX.SetValueLabel(i, t.Rows(i)("日期"))
End If
Next
Chart.AxisX.AnnoWithLabels = True
Chart.LegendVisible = True '显示图列
Chart.LegendCompass= CompassEnum.South '图列显示在南方(底端)
Chart.SeriesList(0).LineColor = Color.Red '设置连线的颜色
Chart.SeriesList(1).LineColor = Color.Cyan
Chart.SeriesList(2).LineColor = Color.Green
Chart.SeriesList(3).LineColor = Color.DarkOrange
Chart.SeriesList(4).LineColor = Color.Blue
Series.MarkShape = MarkShapeEnum.None '数据点标记的形状