以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  表排序之后,生成的图表不是按照排序顺序显示  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=116319)

--  作者:LTHERO
--  发布时间:2018/3/22 17:06:00
--  表排序之后,生成的图表不是按照排序顺序显示

图片点击可在新窗口打开查看此主题相关图片如下:1.png
图片点击可在新窗口打开查看
问题:对统计表1 排序后,生成的图表并不是按照排序顺序生成!如图1!
图片点击可在新窗口打开查看此主题相关图片如下:qq截图20180322170156.png
图片点击可在新窗口打开查看

点击提取按钮就会生成统计表和图表
提取按钮代码如下:

Dim Filter As String
Dim mc As Integer = e.Form.Controls("TextBox1").value
With e.Form.Controls("DateTimePicker1")
    If .Value IsNot Nothing Then
        If Filter >"" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "日期 >= #" & .Value & "#"
    End If
End With
With e.Form.Controls("DateTimePicker2")
    If .Value IsNot Nothing Then
        If Filter >"" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "日期 <= #" & .Value & "#"
    End If
End With
With e.Form.Controls("ComboBox1")
    If .Value IsNot Nothing Then
        If Filter > "" Then
            Filter = Filter & " And "
        End If
        Filter =Filter & "发站 = \'" & .Value & "\'"
    End If
End With
With e.Form.Controls("ComboBox2")
    If .Value IsNot Nothing Then
        If Filter > "" Then
            Filter = Filter & " And "
        End If
        Filter =Filter & "到站 = \'" & .Value & "\'"
    End If
End With
Tables("货量排名_table1").Filter = Filter

Dim a As String
Dim b As String = "运费合计"
If e.Form.Controls("RadioButton1").Checked = True Then
    a = "发货人"
Else If e.Form.Controls("RadioButton2").Checked = True Then
    a = "收货人"
End If

Dim t As Table = Tables("所有开单记录库")
Dim g As Subtotalgroup
t.SubtotalGroups.Clear()
t.GroupAboveData = False
t.TreeVisible = False
g = New Subtotalgroup
g.Aggregate = AggregateEnum.Sum
\'g.GroupOn = "姓名"
g.Caption = "{0}"
t.SubtotalGroups.Add(g)
t.Subtotal()

Dim r As Row
For i As Integer = 0 To t.Rows.Count(True) - 1
    r = t.Rows(i,True)
    If r.IsGroup \'如果是分组行
        Dim f As String = "[" & a & "] = \'" & r("[" & a & "]") & "\'"
        Dim v As String = " [" & b & "]:" & t.Compute("Sum([" & b & "])",f)
        r("[" & a & "]") = "[" & a & "]:" & r("[" & a & "]") & v
    End If
Next

Dim b1 As New GroupTableBuilder("统计表1",DataTables("所有开单记录库"))
b1.Groups.AddDef("[" & a & "]","" & a & "") \'添加日期列用于分组,并用"月"代替原名称
b1.Totals.AddDef("[" & b & "]") \'添加数量列用于统计
b1.Subtotal = True \'生成汇总模式
b1.Filter = Filter
b1.Build \'生成统计表
\'MainTable = Tables("统计表1") \'打开生成的统计表
Tables("统计表1").Sort = "运费合计"


Dim Chart As WinForm.Chart \'定义一个图表变量
Dim Series As WinForm.ChartSeries \'定义一个图系变量
Dim tbl As DataTable = DataTables("统计表1") \'定义一个变量tbl引用数据表
Dim lst As List(Of String) = tbl.GetValues(a) \'获得产品名称集合
Chart = e.Form.Controls("Chart1") \' 引用窗口中的图表
Chart.ChartType = ChartTypeEnum.Bar \'图表类型该为Bar(条形)
Chart.SeriesList.Clear() \'清除图表原来的图系
chart.AxisX.ClearValueLabel
Series = Chart.SeriesList.Add() \'增加一个图系
Series.Length = lst.Count \'设置图系的长度
Series.DataLabelText = "{#YVAL}"
For i As Integer = 0 To lst.Count - 1 \'指定每个数据点的位置
    Series.X(i) = i \'指定水平坐标
    Series.Y(i) = tbl.Compute("Sum(" & b & ")","[" & a & "] = \'" & lst(i) & "\'") \'指定垂直坐标
    Chart.AxisX.SetValueLabel(i, lst(i)) \'指定字符表示
Next
Chart.AxisX.AnnoWithLabels = True \'启用字符标示


能帮忙解决下吗?谢谢老师!

--  作者:LTHERO
--  发布时间:2018/3/22 17:33:00
--  
列都是双精度小数!
--  作者:有点甜
--  发布时间:2018/3/22 17:40:00
--  

Dim lst As List(Of String) = tbl.GetValues(a) \'获得产品名称集合

 

改成

 

Dim lst As List(Of String) = tbl.GetValues(a, "", "运费合计") \'获得产品名称集合


--  作者:LTHERO
--  发布时间:2018/3/22 17:51:00
--  
好的,解决了!谢谢甜老师!