Dim tx As Integer
Dim Chart As WinForm.Chart '定义一个图表变量
Dim Series As WinForm.ChartSeries '定义一个图系变量
Dim t As Table = dt.Table '定义一个变量t引用数据表
Chart = e.Form.Controls("Chart2") ' 引用窗口中的图表
Select Case comb11.Text
Case "趋势线型"
tx = ChartTypeEnum.XYPlot
Case "直方条型"
tx = ChartTypeEnum.bar
Case "饼型"
tx = ChartTypeEnum.pie
End Select
Chart.ChartType = tx
Chart.SeriesList.Clear() '清除图表原来的图系
For Each r As Row In t.Rows
Series = Chart.SeriesList.Add() '增加一个图系
Series.Text = r("分析指标") '设置图系的标题
Series.Length = t.Cols.count - 1 '设置图系的长度
For c As Integer = 1 To t.Cols.Count -1
Series.X(c-1) = c
Series.Y(c-1) = r(c)
Next
Next
For c As Integer = 1 To t.Cols.Count -1
Chart.AxisX.SetValueLabel(c, t.Cols(c).name) '指定字符表示
Next
Chart.AxisX.AnnoWithLabels = True '启用字符标示
Chart.VisualEffect = True '加上这一行,让你的图表更漂亮
Chart.LegendVisible = True '显示图列
Chart.LegendCompass = CompassEnum.south
For ts As Integer = 0 To t.rows.count -1
Select Case ts
Case 0,3,7,11,15
Series.marksize = 1
series.LineThickNess = 0.2
Series.FitType = FitTypeEnum.Line
Series.LineColor= Color.Red
Series.MarkColor = Color.Green
Series.MarkShape = MarkShapeEnum.Dot
Series.MarkSize = 1
Case 1,4,8,12,16
Series.marksize = 1
series.LineThickNess = 0.2
Series.FitType = FitTypeEnum.Line
Series.LineColor= Color.blue
Series.MarkColor = Color.Green
Series.MarkShape = MarkShapeEnum.Dot
Series.MarkSize = 1
Case 2,5,9,13
Series.marksize = 1
series.LineThickNess = 0.2
Series.FitType = FitTypeEnum.Line
Series.LineColor= Color.green
Series.MarkColor = Color.red
Series.MarkShape = MarkShapeEnum.Dot
Series.MarkSize = 1
Case Else
Series.marksize = 1
series.LineThickNess = 0.2
Series.FitType = FitTypeEnum.Line
Series.LineColor= Color.black
Series.MarkColor = Color.Green
Series.MarkShape = MarkShapeEnum.Dot
Series.MarkSize = 1
End Select
Next