以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- 图标按自定义顺序显示 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=180269) |
-- 作者:weibu -- 发布时间:2022/10/11 14:06:00 -- 图标按自定义顺序显示 老师我想让下图按“入职”、“初级”、“中级”、“优秀”的顺序显示 同时我还想在每个柱状图上加上对应值的数字,如下代码如何修改? 此主题相关图片如下:微信截图_20221011140356.png Dim g As New GroupTableBuilder("统计表1", DataTables("userinfo")) g.Groups.AddDef("period") g.Totals.AddDef("pname", AggregateEnum.Count) g.GrandProportion = True g.FromServer = True g.Build() Dim Chart As WinForm.Chart \'定义一个图表变量 Dim Series As WinForm.ChartSeries \'定义一个图系变量 Chart = e.Form.Controls("Chart2") \' 引用窗口中的图表 Chart.VisualEffect = True \'加上这一行,让你的图表更漂亮 \'Chart.HeaderText = "员工能力等级概览" Chart.ChartType = ChartTypeEnum.Bar \'图表1类型为Bar(条形) Chart.DataSource = "统计表1" \'设置绑定表 Chart.SeriesList.Clear() \'清除图表原来的图系 Series = Chart.SeriesList.Add() \'给图表1增加一个图系 Series.Text = "period" Series.X.DataField = "period" \'X轴绑定到产品列 Series.Y.DataField = "pname" \'Y轴绑定到数量列 Series.MarkShape = MarkShapeEnum.Dot Series.MarkSize = 3 |
-- 作者:有点蓝 -- 发布时间:2022/10/11 14:08:00 -- 不要使用绑定,按这种遍历赋值的方法:http://www.foxtable.com/webhelp/topics/0966.htm |
-- 作者:weibu -- 发布时间:2022/10/11 15:52:00 -- Dim g As New GroupTableBuilder("统计表1", DataTables("userinfo")) g.Groups.AddDef("period") g.Totals.AddDef("pname", AggregateEnum.Count) g.GrandProportion = True g.FromServer = True g.Build() Dim cns() As String = {"入职", "初级", "中级", "优秀"} Dim Chart As WinForm.Chart \'定义一个图表变量 Dim Series As WinForm.ChartSeries \'定义一个图系变量 Chart = e.Form.Controls("Chart2") \' 引用窗口中的图表 Chart.VisualEffect = True \'加上这一行,让你的图表更漂亮 \'Chart.HeaderText = "员工能力等级概览" Chart.ChartType = ChartTypeEnum.Bar \'图表1类型为Bar(条形) Chart.DataSource = "统计表1" \'设置绑定表 Chart.SeriesList.Clear() \'清除图表原来的图系 Series = Chart.SeriesList.Add() \'给图表1增加一个图系 For Each cn As String In cns Series.Text = cn Series.X(cn) = "period" \'X轴绑定到产品列 Series.Y(cn) = "pname" \'Y轴绑定到数量列 Next Series.MarkShape = MarkShapeEnum.Dot Series.MarkSize = 3 老师我还是没弄出来,上面的报错?
|
-- 作者:有点蓝 -- 发布时间:2022/10/11 15:59:00 -- Dim g As New GroupTableBuilder("统计表1", DataTables("userinfo")) g.Groups.AddDef("period") g.Totals.AddDef("pname", AggregateEnum.Count) g.GrandProportion = True g.FromServer = True g.Build() Dim cns() As String = {"入职", "初级", "中级", "优秀"} Dim Chart As WinForm.Chart \'定义一个图表变量 Dim Series As WinForm.ChartSeries \'定义一个图系变量 Chart = e.Form.Controls("Chart2") \' 引用窗口中的图表 Chart.VisualEffect = True \'加上这一行,让你的图表更漂亮 \'Chart.HeaderText = "员工能力等级概览" Chart.ChartType = ChartTypeEnum.Bar \'图表1类型为Bar(条形) Chart.SeriesList.Clear() \'清除图表原来的图系 Series = Chart.SeriesList.Add() \'增加一个图系 Series.Length = 4 For i As integer = 0 to cns.length - 1 \'指定每个数据点的位置 dim dr as datarow = datatables("统计表1").find("period=\'" & cns(i) & "\'") if dr isnot nothing Series.X(i) = i \'指定水平坐标 Series.Y(i) = dr("pname") \'垂直坐标用随机数生成 Chart.AxisX.SetValueLabel(i, cns(i)) \'指定字符表示 endif Next Chart.AxisX.AnnoWithLabels = True |