Dim Chart As WinForm.Chart '定义一个图表变量
Dim Series As WinForm.ChartSeries '定义一个图系变量
Dim dt1 As DataTable = DataTables("表A") '定义一个变量t引用数据表
Dim dt2 As DataTable = DataTables("表B")
Chart = e.Form.Controls("Chart1") ' 引用窗口中的图表
Chart.ChartType = ChartTypeEnum.XYPlot
Chart.SeriesList.Clear() '清除图表原来的图系
Dim filter As String = "日期 >= #" & Date.Today & "# and 日期 <= #" & Date.Today.AddMonths(1) & "#"
For Each dr As DataRow In dt1.Select("选择 = true")
Series = Chart.SeriesList.Add() '增加一个图系
series.Text = dr("成员")
Dim drs As List(Of DataRow) = dt2.Select("成员 = '" & dr("成员") & "' and " & filter)
series.Length = drs.Count
For i As Integer = 0 To drs.Count - 1
Series.X(i) = i
Series.Y(i) = drs(i)("体重")
Next
Next
Dim r As Integer = 0
Do
Chart.AxisX.SetValueLabel(r, Format(Date.Today.AddDays(r),"dd")) '指定字符表示
r+=1
Loop While Date.Today.AddDays(r) <= Date.Today.AddMonths(1)
Chart.AxisX.AnnoWithLabels = True '启用字符标示
Chart.VisualEffect = True '加上这一行,让你的图表更漂亮
Chart.LegendVisible = True '显示图列
Chart.LegendCompass= CompassEnum.South '图列显示在南方(底端)