找回密码
 立即注册

QQ登录

只需一步,快速开始

Hjr2350
论坛元老   /  发表于:2013-1-22 17:19  /   查看:5236  /  回复:2
我想找一个绘制柱形图的DEMO,不知BZ能不能给我提供一个。
现在我只找到了绘制饼图的DEMO,我现在参考它来绘制柱形图
参考代码:
  1.            string colors = "#ffbb22,#ff9911,#aacc33,#aabbbb,#bb0033,#00cc33,#990099,#0011aa,#14D0EE,#B17EC3,#E67F16,#EE5907,#6A2DA1,#0A35F0,#A816D7,#D218AD,#EE0A96,#5A4DAE,#ACE9D9";

  2.             PieSeries pseries = new PieSeries();
  3.             pseries.Values.AddRange(new double[] { 0.2, 0.3, 0.1, 0.2, 0.2 });
  4.             pseries.LabelVisible = true;
  5.             pseries.LabelFormatter = new FarPoint.Win.Spread.Model.GeneralFormatter("0.00%", false);

  6.             FillCollection fc = pseries.PieFills;
  7.             List<SolidFill> list = new List<SolidFill>();
  8.             foreach (string color in colors.Split(new char[] { ',' }))
  9.             {
  10.                 list.Add(new SolidFill(ColorTranslator.FromHtml(color)));
  11.             }
  12.             fc.Clear();
  13.             fc.AddRange(list.ToArray());

  14.             PiePlotArea plotArea = new PiePlotArea();
  15.             plotArea.Location = new PointF(0.2f, 0.2f);
  16.             plotArea.Size = new SizeF(0.6f, 0.6f);
  17.             plotArea.Series.Add(pseries);

  18.             ChartModel model = new ChartModel();
  19.             model.PlotAreas.Add(plotArea);

  20.             //FarPoint.Win.Spread.Chart.SpreadChart char000 = new FarPoint.Win.Spread.Chart.SpreadChart();
  21.             //char000.Top = 0;
  22.             //char000.Left = 0;
  23.             //char000.Width = 100;
  24.             //char000.Height = 100;
  25.             fpSpread1.ActiveSheet.AddChart(0, 0, typeof(PieSeries), 400, 400, 10, 1);
  26.             fpSpread1.ActiveSheet.Charts[0].Model = model;
复制代码

但是我现在对spread中,绘制柱形使用的类不是很清楚,
Series是用FarPoint.Win.Chart.ClusteredBarSeries这个类吗?
Area用那个类,我在帮助上面没有找到....
最好有个DEMO....谢谢

2 个回复

倒序浏览
ZenosZeng讲师达人认证 悬赏达人认证
超级版主   /  发表于:2013-1-22 17:42:00
沙发
回复 1楼Hjr2350的帖子

PieSeries 对应的是 BarSeries
PiePlotArea 对应的是 YPlotArea
  1. BarSeries series = new BarSeries();

  2. series.BarFill = new SolidFill(Color.Red);

  3. series.Values.Add(2.0);

  4. series.Values.Add(4.0);

  5. series.Values.Add(3.0);

  6. series.Values.Add(5.0);

  7. YPlotArea plotArea = new YPlotArea();

  8. plotArea.Location = new PointF(0.2f, 0.2f);

  9. plotArea.Size = new SizeF(0.6f, 0.6f);

  10. plotArea.Series.Add(series);

  11. ChartModel model = new ChartModel();

  12. model.PlotAreas.Add(plotArea);

复制代码
回复 使用道具 举报
Hjr2350
论坛元老   /  发表于:2013-1-23 09:54:00
板凳
感谢你的帮助,我大概了解了spread的做成,3Q!
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部