以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 堆积柱形图 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=161093) |
-- 作者:季朝龙 -- 发布时间:2021/3/5 13:41:00 -- 堆积柱形图 老师,帮忙看看的这段代码哪里出错了,得到的图形和我想要的有点偏差; \'生成堆积柱形图 Dim Chart As WinForm.Chart \'定义一个图表变量 Dim Series As WinForm.ChartSeries \'定义一个图系变量 Dim t As Table = Tables("统计表1") \'定义一个变量t引用数据表 Dim r1,ymax,y1 As Integer Chart = e.Form.Controls("Chart1") \' 引用窗口中的图表 Chart.ChartType = ChartTypeEnum.Bar \'图表类型改为Bar(条形) Chart.SeriesList.Clear() \'清除图表原来的图系 For Each c As Col In t.Cols If c.Name <> "姓名" Then y1 = 0 Series = Chart.SeriesList.Add() \'增加一个图系 Series.Text = c.Name \'设置图系的标题 Series.Length = t.Rows.Count \'设置图系的长度 For r1 = 0 To t.Rows.Count - 1 y1 = y1 + t.Rows(r1)(c.Name) Series.X(r1) = 2*r1 + 0.5 Series.Y(r1) = t.Rows(r1)(c.Name) Chart.AxisX.SetValueLabel(2*r1 + 0.25, t.Rows(r1)("姓名")) \'指定字符表示 Next If y1 > ymax Then ymax = y1 End If End If Next Chart.AxisX.AnnoRotation = - 90 \'X轴标示逆时针旋转45度 chart.AxisY.Max = 60 Chart.AxisX.AnnoWithLabels = True \'启用字符标示 \'Chart.VisualEffect = True \'加上这一行,让你的图表更漂亮 --实际更不好看 Chart.LegendVisible = True \'显示图列 Chart.LegendCompass = CompassEnum.South \'图列显示在南方(底端) |
-- 作者:有点蓝 -- 发布时间:2021/3/5 13:52:00 -- Chart = e.Form.Controls("Chart1") \' 引用窗口中的图表 Chart.ChartType = ChartTypeEnum.Bar \'图表类型改为Bar(条形) Chart.SeriesList.Clear() \'清除图表原来的图系 Chart.AxisX.ClearValueLabel For Each c As Col In t.Cols If c.Name <> "姓名" Then y1 = 0 Series = Chart.SeriesList.Add() \'增加一个图系 Series.Text = c.caption \'设置图系的标题 |
-- 作者:季朝龙 -- 发布时间:2021/3/5 14:53:00 -- 您好!代码改成下面这样,纵坐标太高了,我需要怎样修改代码呀? \'生成堆积柱形图 Dim Chart As WinForm.Chart \'定义一个图表变量 Dim Series As WinForm.ChartSeries \'定义一个图系变量 Dim t As Table = Tables("统计表1") \'定义一个变量t引用数据表 Dim r1,ymax,y1 As Integer Chart = e.Form.Controls("Chart1") \' 引用窗口中的图表 Chart.ChartType = ChartTypeEnum.Bar \'图表类型改为Bar(条形) Chart.SeriesList.Clear() \'清除图表原来的图系 Chart.AxisX.ClearValueLabel For Each c As Col In t.Cols If c.Name <> "姓名" Then y1 = 0 Series = Chart.SeriesList.Add() \'增加一个图系 Series.Text = c.Caption \'设置图系的标题 \'Series.Text = c.Name \'设置图系的标题 Series.Length = t.Rows.Count \'设置图系的长度 For r1 = 0 To t.Rows.Count - 1 y1 = y1 + t.Rows(r1)(c.Name) Series.X(r1) = 2*r1 + 0.5 Series.Y(r1) = t.Rows(r1)(c.Name) Chart.AxisX.SetValueLabel(2*r1 + 0.25, t.Rows(r1)("姓名")) \'指定字符表示 If y1 > ymax Then ymax = y1 End If Next chart.AxisY.Max = ymax End If Next Chart.AxisX.AnnoRotation = - 90 \'X轴标示逆时针旋转45度 \'chart.AxisY.Max = 60 Chart.AxisX.AnnoWithLabels = True \'启用字符标示 \'Chart.VisualEffect = True \'加上这一行,让你的图表更漂亮 --实际更不好看 Chart.LegendVisible = True \'显示图列 Chart.LegendCompass = CompassEnum.South \'图列显示在南方(底端) Chart.Stacked = True |
-- 作者:有点蓝 -- 发布时间:2021/3/5 15:07:00 -- y1 = y1 + t.Rows(r1)(c.Name) 改为 y1 = t.Rows(r1)(c.Name)
|