以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  饼图  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=74544)

--  作者:cqlistone
--  发布时间:2015/9/13 21:32:00
--  饼图
"待派工耗时M","待维修耗时M","维修耗时M","待检验耗时M","检验耗时M"是表的列名,求这些列的饼图

Dim Chart As WinForm.Chart 
Dim Series As WinForm.ChartSeries 
Dim t As Table = Tables("停机处置") 
Dim q1 As Single = val(t.Compute("Avg(" & "待派工耗时M" & ")", "[待派工耗时M] > 0"))
Dim q2 As Single = val(t.Compute("Avg(" & "待维修耗时M" & ")", "[待维修耗时M] > 0"))
Dim q3 As Single = val(t.Compute("Avg(" & "维修耗时M" & ")", "[维修耗时M] > 0"))
Dim q4 As Single = val(t.Compute("Avg(" & "待检验耗时M" & ")", "[待检验耗时M] > 0"))
Dim q5 As Single = val(t.Compute("Avg(" & "检验耗时M" & ")", "[检验耗时M] > 0"))
Dim qq() As Single = {q1,q2,q3,q4,q5}
Dim ss() As String = {"待派工耗时M","待维修耗时M","维修耗时M","待检验耗时M","检验耗时M"}
Dim sm As Integer = t.Compute("Sum(qq)") 
Chart= Forms("报表").Controls("Chart4") 
Chart.VisualEffect = True 
Chart.ChartType = ChartTypeEnum.Pie 
For Each r As Row In t.Rows
    Series = Chart.SeriesList.Add() 
    Series.Length = 1 
    Series.Text = r(" & ss & ") & "(" & r("qq") & ")" 
    Series.Y(0) = r("qq") \'指定值
    Series.DataLabelText = Math.Round(r("qq")*100/sm,2) & "%" 
Next
Chart.LegendVisible = True 
Chart.LegendCompass= CompassEnum.East \'

--  作者:大红袍
--  发布时间:2015/9/14 10:04:00
--  
Dim Chart As WinForm.Chart
Dim Series As WinForm.ChartSeries
Dim t As Table = Tables("停机处置")
Dim q1 As Single = val(t.Compute("Avg(" & "待派工耗时M" & ")", "[待派工耗时M] > 0"))
Dim q2 As Single = val(t.Compute("Avg(" & "待维修耗时M" & ")", "[待维修耗时M] > 0"))
Dim q3 As Single = val(t.Compute("Avg(" & "维修耗时M" & ")", "[维修耗时M] > 0"))
Dim q4 As Single = val(t.Compute("Avg(" & "待检验耗时M" & ")", "[待检验耗时M] > 0"))
Dim q5 As Single = val(t.Compute("Avg(" & "检验耗时M" & ")", "[检验耗时M] > 0"))
Dim qq() As Single = {q1,q2,q3,q4,q5}
Dim ss() As String = {"待派工耗时M","待维修耗时M","维修耗时M","待检验耗时M","检验耗时M"}
Dim sm As Integer = q1+q2+q3+q4+q5
Chart= Forms("报表").Controls("Chart4")
Chart.VisualEffect = True
Chart.ChartType = ChartTypeEnum.Pie
For i As Integer = 0 to ss.length -1
    Series = Chart.SeriesList.Add()
    Series.Length = 1
    Series.Text = ss(i) & "(" & qq(i) & ")"
    Series.Y(0) = qq(i) \'指定值
    Series.DataLabelText = Math.Round(qq(i)*100/sm,2) & "%"
Next
Chart.LegendVisible = True
Chart.LegendCompass= CompassEnum.East \'