JFreechart中的漂亮饼图 [英] Pretty pie charts in JFreechart

查看:115
本文介绍了JFreechart中的漂亮饼图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能在JFreechart中为饼图获得复杂,美丽的颜色?我的意思是如何实现像链接中所示的图像颜色

Is it possible to get complex, beautiful colors for pie charts in JFreechart? I mean how can I achieve the colors like the image shown in the link?

是否可以使用RGB格式,还是需要使用其他格式?我们怎么做呢谢谢你的帮助

Is it possible using the RGB format, or do you need to use a different format? How can we do it. thank you for your help

推荐答案

您可以使用 PiePlot.setSectionPaint

以下是一个例子:

  DefaultPieDataset result = new DefaultPieDataset();
  result.setValue("1", 40.);
  result.setValue("2", 30.);
  result.setValue("3", 20.);
  result.setValue("4", 10.);
  JFreeChart chart = ChartFactory.createPieChart3D("", result, true, true, false);
  PiePlot3D plot = (PiePlot3D) chart.getPlot();
  plot.setBackgroundPaint(new Color(255, 255, 255, 0));
  plot.setSectionPaint("1", new Color(31, 73, 125));
  plot.setSectionPaint("2", new Color(192, 80, 77));
  plot.setSectionPaint("3", new Color(155, 187, 89));
  plot.setSectionPaint("4", new Color(128, 100, 162));

这篇关于JFreechart中的漂亮饼图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆