以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 如何根据各列数据生成饼形图? (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=11301) |
-- 作者:狐狸爸爸 -- 发布时间:2011/7/17 7:31:00 -- Dim Chart As WinForm.Chart \'定义一个图表变量 Dim Series As WinForm.ChartSeries \'定义一个图系变量 Dim t As Table = Tables("统计表1") \'定义一个变量t引用数据表 Chart= Forms("窗口1").Controls("Chart1") \' 引用窗口中的图表 Chart.VisualEffect = True \'加上这一行,让你的图表更漂亮 Chart.ChartType = ChartTypeEnum.Pie \'图表1类型改为Bar(条形) Dim nms() as string = {"饲料费用","物耗费用","种苗费用","其它支出","工资费用"} for each nm as string in nms Series = Chart.SeriesList.Add() \'增加一个图系 Series.Length = 1 \'一个系列只能包括一个值 Series.Text = nm Series.Y(0) = Tables("xxx").Current(nm) next Chart.LegendVisible = True \'显示图列 Chart.LegendCompass= CompassEnum.East \'图列显示在东方(右方) |
-- 作者:易服 -- 发布时间:2011/7/17 14:56:00 --
Dim g As New GroupTableBuilder("分组统计", DataTables("总览")) g.Totals.AddDef("平坡退耕","平坡") g.Totals.AddDef("陡坡退耕","陡坡") Dim Chart As WinForm.Chart \'定义一个图表变量 Dim nms() As String = {"平坡","缓坡","斜坡","陡坡"} Series.DataLabelForeColor = Color.Red Next
希望显示:253.6亩占32.51% |
-- 作者:易服 -- 发布时间:2011/7/17 17:06:00 -- 根据各列数据生成饼形图(3楼)不知怎么变通成下面效果 Series.DataLabelText =" {#YVAL}" & "亩" & "占" & Math.Round(r("设计面积")*100/sm,2) & "%"
[此贴子已经被作者于2011-7-17 17:09:56编辑过]
|
-- 作者:狐狸爸爸 -- 发布时间:2011/7/17 17:12:00 -- 这里不是有现成的例子吗: http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&Id=11274
|
-- 作者:hhbb -- 发布时间:2011/7/17 17:44:00 -- ....... Series.Text = nm Dim r As Row = Tables("分组统计").Current Dim sm As Double=r("平坡")+r("缓坡")+r("斜坡")+r("陡坡") Series.Y(0) = r(nm) Series.DataLabelText =" {#YVAL}" & "亩 占" & Math.Round(r(nm)*100/sm,2) & "%" .......... |
-- 作者:易服 -- 发布时间:2011/7/18 15:14:00 -- 以下是引用hhbb在2011-7-17 17:44:00的发言:
.......
Series.Text = nm
Dim r As Row = Tables("分组统计").Current
Dim sm As Double=r("平坡")+r("缓坡")+r("斜坡")+r("陡坡")
Series.Y(0) = r(nm)
Series.DataLabelText =" {#YVAL}" & "亩 占" & Math.Round(r(nm)*100/sm,2) & "%"
..........
谢谢!成功了 ......... Series.Text = nm |