以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 饼图 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=80500) |
-- 作者:cqlistone -- 发布时间:2016/1/24 21:20:00 -- 饼图 表A 有两列, 产品名称 数量 A1 30 A2 50 A3 20 A1 15 An 60 跳过统计表如何编写饼图代码 |
-- 作者:y2287958 -- 发布时间:2016/1/24 21:36:00 -- http://www.foxtable.com/help/topics/0969.htm |
-- 作者:cqlistone -- 发布时间:2016/1/26 10:05:00 -- 按产品列生成饼图,代码哪里出错了,请帮忙改下。
Dim Chart As WinForm.Chart Dim Series As WinForm.ChartSeries |
-- 作者:Hyphen -- 发布时间:2016/1/26 10:12:00 -- Dim Chart As WinForm.Chart Dim Series As WinForm.ChartSeries Dim t As DataTable = DataTables("订单") Dim pds() As String = t.GetValues("产品") \'Dim qq() As Single = = val(t.Compute("Sum(" & pds & ")", "产品 is not null")) Dim sm As Integer = t.Compute("Sum(数量)") Chart= Forms("窗口1").Controls("Chart1") Chart.SeriesList.Clear() Chart.VisualEffect = True Chart.ChartType = ChartTypeEnum.Pie For i As Integer = 0 To pds.length -1 Series = Chart.SeriesList.Add() Series.Length = 1 Dim sum = val(t.Compute("Sum(" & pds(i) & ")", "产品 is not null")) Series.Text = pds(i) & "(" & sum & ")" Series.Y(0) = sum Series.DataLabelText = Math.Round(sum * 100 / sm,1) & "%" Next Chart.LegendVisible = True Chart.LegendCompass= CompassEnum.South
|
-- 作者:cqlistone -- 发布时间:2016/1/26 18:17:00 -- 你好! 代码报错 无法将类型为“System.Collections.Generic.List`1[System.String]”的对象强制转换为类型“System.String[]”。
|
-- 作者:大红袍 -- 发布时间:2016/1/26 22:07:00 -- Dim pds() As String = t.GetValues("产品")
改成
Dim pds As List(of String) = t.GetValues("产品") |
-- 作者:cqlistone -- 发布时间:2016/1/27 9:09:00 -- 你好! 还是不行 |
-- 作者:Hyphen -- 发布时间:2016/1/27 9:14:00 -- 什么地方不行,贴出完整代码和出错提示 |
-- 作者:cqlistone -- 发布时间:2016/1/27 9:23:00 -- 你好! 聚合函数错误 Dim Chart As WinForm.Chart
Dim Series As WinForm.ChartSeries
Dim t As DataTable = DataTables("订单")
Dim pds As List(of String) = t.GetValues("产品") Dim sm As Integer = t.Compute("Sum(数量)")
Chart= Forms("窗口1").Controls("Chart1")
Chart.SeriesList.Clear()
Chart.VisualEffect = True
Chart.ChartType = ChartTypeEnum.Pie
For i As Integer = 0 To pds.count -1
Series = Chart.SeriesList.Add()
Series.Length = 1
Dim sum = val(t.Compute("Sum(" & pds(i) & ")", "产品 is not null"))
Series.Text = pds(i) & "(" & sum & ")"
Series.Y(0) = sum
Series.DataLabelText = Math.Round(sum * 100 / sm,1) & "%"
Next
Chart.LegendVisible = True
Chart.LegendCompass= CompassEnum.South
|
-- 作者:大红袍 -- 发布时间:2016/1/27 9:58:00 -- Dim sum = val(t.Compute("Sum(数量)", "产品 = \'" & pds(i) & "\'")) |