java - JFreechart 中漂亮的饼图

标签 java jfreechart

是否有可能在 JFreechart 中为饼图获得复杂、漂亮的颜色?我的意思是我怎样才能获得像 link 中所示的图像的颜色?

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

最佳答案

您可以使用 PiePlot.setSectionPaint 为每个饼图切片使用 RGB 值指定颜色.

这是一个例子:

  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));

关于java - JFreechart 中漂亮的饼图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14819336/

相关文章:

jasper-reports - JfreeChart自定义票据标签

java - 为什么 JPA 元模型中的所有字段均为空?

java - ANTLR:解决根语法的静态初始化程序中代码太大的问题

java - 如何使用随机数添加 1/100 的机会

java - Jfree Chart 中日文语言不正确

java - 如何使用Jfreechart在Eclipse插件 View 中绘制XY折线图

java - 缺少 return 语句的错误

Java swing 组件在 netbeans 之外无法正确显示

java - 将图表添加到缓冲区

java - 在 EDT 中运行时显示 JFreeChart 点的性能问题