Dim sql As String
sql="”
Dim cmd As new SQLCommand
cmd.ConnectionName=Functions.Execute("返回数据源")
cmd.CommandText=sql
Dim dt As DataTable
dt=cmd.ExecuteReader
Dim s As String="月销售统计"
Dim g As New GroupTableBuilder(s, dt)
g.Groups.AddDef("制单日期", "月")
g.Groups.AddDef("制单日期", DateGroupEnum.Day, "日")
g.Totals.AddDef("金额")
g.Build()
Tables(s).Sort="金额 desc "
Dim Chart As WinForm.Chart '定义一个图表变量
Dim Series As WinForm.ChartSeries '定义一个图系变量
Dim t As Table = Tables(s) '定义一个变量t引用数据表
Chart= e.Form.Controls("Chart2") ' 引用窗口中的图表
Dim c1Chart1 = Chart.basecontrol
Dim lbls = c1Chart1.ChartLabels
lbls.LabelsCollection.Clear()
Chart.AxisX.ClearValueLabel()
Chart.AxisY.ClearValueLabel()
Chart.ChartType = ChartTypeEnum.bar '图表1类型改为Bar(条形)
Chart.SeriesList.Clear
Chart.SeriesList2.Clear
Chart.Axisx.Text=""
Chart.AxisX.AnnoWithLabels = False
Series = Chart.SeriesList.Add()
Series.Length = 31
''Dim lst As List(of DataRow)=DataTables(s).Select("金额>=0","金额 desc")
Chart.AxisX.Min = 1 '指定X轴的最小值,也就是从1月开始
Chart.AxisX.Max = 31 ''指定X轴的最大值,一年只有12个月
For day As Integer = 1 To 31 '逐月设置坐标
Series.X(day-1) = day
Chart.Axisx.SetValueLabel(day, day) '指定水平坐标为月份
Dim r As DataRow = DataTables(s).Find("月 = " & Date.today.Month & " and 日=" & day)'找出对应年月的行
If r IsNot Nothing '如果找到对应年月的行
Series.Y(day-1) = math.round(r("金额")/10000,2) '指定数量作为垂直坐标
End If
Next
series.TooltipText="{#YVAL}"