Dim Chart As WinForm.Chart '定义一个图表变量 Dim Series As WinForm.ChartSeries '定义一个图系变量
Dim t As Table = Tables(e.Form.Controls("Cmb姓名1").value & e.Form.Controls("Cmb一级技法").value & "技能方法未达标统计") '定义一个变量t引用数据表
Chart = e.Form.Controls("Chart2") ' 引用窗口中的图表
Chart.SeriesList.Clear() '清除图表原来的图系
Chart.ChartType = ChartTypeEnum.Bar '图表类型改为Bar(条形)
For Each c As Col In t.Cols
If c.Name <> "技能方法" And c.Name <> "已考" And c.Name <> "未达成" And c.Name <> "未参考" Then
Series = Chart.SeriesList.Add() '增加一个图系
'Series.Text = c.Name '设置图系的标题
Series.Length = t.Rows.Count '设置图系的长度
For r As Integer = 0 To t.Rows.Count - 1
Series.X(r) = r
If t.Rows(r)(c.Name) > 0 Then
Series.Y(r) = t.Rows(r)(c.Name)
End If
Series.DataLabelText = c.name
Series.TooltipText = "X = " & c.name & ", Y = {#YVAL}"
Next
End If
Next
For r As Integer = 0 To t.Rows.Count - 1
Chart.AxisX.SetValueLabel(r, t.Rows(r)("技能方法")) '指定字符表示
Next
Chart.Stacked = True
Chart.Inverted = True
Chart.AxisX.AnnoWithLabels = True '启用字符标示
Chart.VisualEffect = True '加上这一行,让你的图表更漂亮