参考代码
Dim cmd As new SQLCommand
cmd.CommandText = "select top 20 format(抄表时间, 'yyyy-MM-dd') As 日期, hour(抄表时间)*3600+minute(抄表时间)*60+second(抄表时间) As 抄表时间, 总功率 from {表A}"
Dim Chart As WinForm.Chart '定义一个图表变量
Dim Series As WinForm.ChartSeries '定义一个图系变量
Dim dt As DataTable = cmd.ExecuteReader
Chart= Forms("窗口1").Controls("Chart1") ' 引用窗口中的图表
Chart.ChartType = ChartTypeEnum.XYPlot
Chart.SeriesList.Clear() '清除图表原来的图系
Chart.AxisX.ClearValueLabel
Chart.AxisX.Major = 3600
For Each rq As String In dt.GetValues("日期")
Series = Chart.SeriesList.Add() '增加一个图系
Series.Length = 86400 '图系的数据点数等于表的行数
series.Text = rq
Dim drs = dt.Select("日期 = '" & rq & "'", "抄表时间")
For i As Integer = 0 To drs.count-1
Series.X(i) = drs(i)("抄表时间") '指定水平坐标
Series.Y(i) = drs(i)("总功率") '指定垂直坐标
Next
Next
For i As Integer = 3600 To 86400 Step 3600
Chart.AxisX.SetValueLabel(i, i / 3600) '指定字符表示
Next
Chart.AxisX.AnnoWithLabels = True '启用字符标示
Chart.LegendVisible = True '显示图列
Chart.LegendCompass= CompassEnum.South '图列显示在南方(底端)