Dim dt1 As Date = Vars("Stime")
Dim dt2 As Date = Vars("Etime")
Dim FT, FTT As String
If Vars("CNUM") = "全部车辆" Then
FT = "日期 >= #" & dt1 & "# and 日期 < #" & dt2 & "# "
Else
FT = "日期 >= #" & dt1 & "# and 日期 < #" & dt2 & "# and 车牌号 = '" & Vars("CNUM") & "'"
End If
Vars("TXT1")=CCNumber(dt1)
Vars("TXT2")=CCNumber(dt2)
MainTable=Tables("记录资料_Table4")
Tables("记录资料_Table4").Filter = FT
Tables("记录资料_Table4").openview("3")
With Tables("记录资料_Table4")
.Position = .Rows.Count - 1
End With
Dim k As New CrossTableBuilder("年费用", DataTables("记录明细表"),FT)
k.HGroups.AddDef("类别")
k.VGroups.AddDef("车牌号")
k.Totals.AddDef("金额", "金额")
Tables("记录资料_TableA").DataSource = k.BuildDataSource()
DataTables("记录资料_TableA").SysStyles("Alternate").BackColor = Color.FromARGB(255,228,181)
DataTables("记录资料_TableA").SysStyles("Normal").BorderColor = Color.FromARGB(119,136,153)
Tables("记录资料_TableA").AutoSizeCols()
Dim Chart As WinForm.Chart '定义一个图表变量
Dim Series As WinForm.ChartSeries '定义一个图系变量
Dim t As Table = Tables("记录资料_TableA") '定义一个变量t引用数据表
Chart = e.Form.Controls("Chart2") ' 引用窗口中的图表
Chart.ChartType = ChartTypeEnum.Bar '图表类型改为Bar(条形)
Chart.DataSource = "记录资料_TableA" '设置绑定表
Chart.SeriesList.Clear() '清除图表原来的图系
For Each c As Col In t.Cols
If c.Name <> "类别" Then
Series = Chart.SeriesList.Add() '增加一个图系
Series.Text = c.Name '设置图系的标题
Series.X.DataField = "类别" 'X轴绑定到产品列
Series.Y.DataField = c.Name '设置Y轴的绑定列
Series.DataLabelText = "{#YVAL}"
End If
Next
Chart.HeaderText = Vars("TXT1")&"至"&Vars("TXT2")&"期间分类别费用统计"
Chart.VisualEffect = True '加上这一行,让你的图表更漂亮
Chart.LegendVisible = True '显示图列
Chart.LegendCompass= CompassEnum.South '图列显示在南方(底端)