Dim bd1 As New GroupTableBuilder("统计",DataTables("账户"))
Dim dt1 As fxDataSource
bd1.FromServer = True
bd1.Groups.AddDef("账户名称")
bd1.Totals.AddDef("初始金额")
dt1 = bd1.BuildDataSource()
Dim bd2 As New GroupTableBuilder("统计表2",DataTables("流水账"))
Dim dt2 As fxDataSource
bd2.Filter = "[类别] ='支出' "
bd2.FromServer = True
bd2.Groups.AddDef("账户名称")
bd2.Totals.AddDef("金额","支出金额")
dt2 = bd2.BuildDataSource()
Dim bd3 As New GroupTableBuilder("统计表3",DataTables("流水账"))
Dim dt3 As fxDataSource
bd3.Filter = "[类别] = '收入'"
bd3.FromServer = True
bd3.Groups.AddDef("账户名称")
bd3.Totals.AddDef("金额","收入金额")
dt3 = bd3.BuildDataSource()
dt1.Combine("账户名称",dt2,"账户名称")
dt1.Combine("账户名称",dt3,"账户名称")
dt1.Show("统计")
DataTables("统计").DataCols.Add("余额",Gettype(Double),"( IIF( 初始金额 Is null,0,初始金额) -IIF( 支出金额 Is null,0, 支出金额) + IIF(收入金额 Is Null,0,收入金额))")
Dim Chart As WinForm.Chart
Dim Series As WinForm.ChartSeries
Dim t As Table = Tables("统计")
Dim sm As Integer = t.Compute("Sum(余额)") '计算总数量
Chart= e.Form.Controls("Chart1")
Chart.SeriesList.Clear()
Chart.VisualEffect = True
Chart.ChartType = ChartTypeEnum.Pie
For Each r As Row In t.Rows
If r("余额") <> 0 Then
Series = Chart.SeriesList.Add()
Series.Length = 1
Series.Text = r("账户名称") & "(" & r("余额") & ")"
Series.Y(0) = r("余额")
Series.DataLabelText = Math.Round(r("余额")*100/sm,2) & "%"
End If
Next
Chart.LegendVisible = True '显示图列
Chart.LegendCompass= CompassEnum.East
RibbonMenu.StatusBar.Message3 = "余额:" & " " & DataTables("统计").Compute("Sum(余额)")
麻烦帮忙上面Pie 的图表改成Bar