weixin_42298077 2008-11-11 11:55
浏览 295
已采纳

jfreechart如何在MultiplePiePlot设定颜色?

想请问jfreechart如何在MultiplePiePlot设定颜色?因为MultiplePiePlot没有setSectionPaint(),那该如何解决呢?此外,饼图的饼分也不一样,而颜色是要依照组别来设定的。我想要设定的颜色是这样的。。可以给些代码参考吗?谢谢!
[b]问题补充:[/b]
想请问jfreechart如何在MultiplePiePlot设定颜色?因为MultiplePiePlot没有setSectionPaint(),那该如何解决呢?此外,饼图的饼分也不一样,而颜色是要依照组别来设定的。我想要设定的颜色是这样的。。可以给些代码参考吗?谢谢!
我想要的是依组别来设定颜色,不是依饼图的Section因为第一个多重饼图可能有B,C和A,B,C,D。。第二个多重饼图有C,D 和A,B,C..而颜色是要依
A-红
B-蓝
C-黄
D-绿

由谁会吗?

  • 写回答

1条回答 默认 最新

  • iteye_521 2008-11-11 11:59
    关注

    [code="java"]
    try
    {
    vMultiplePiePlot=(MultiplePiePlot)vFreeChart.getPlot();
    if(vMultiplePiePlot!=null)
    {
    vFreeChartExtend=vMultiplePiePlot.getPieChart();
    vPiePlot=(PiePlot)vFreeChartExtend.getPlot();
    if(bRender)
    {
    if(strItemArray.length>0)
    {
    for(int iIndex=0;iIndex<strItemArray.length;iIndex++)
    {
    //指定Section色彩
    vPiePlot.setSectionPaint(iIndex,new Color(0,0+iIndex*(255/strItemArray.length),255));
    //指定Section轮廓线颜色
    vPiePlot.setSectionOutlinePaint(0,Color.BLACK);
    }
    }
    }
    //指定Section标签格式
    vStandardPieItemLabelGenerator=new StandardPieItemLabelGenerator("{1}");
    vPiePlot.setLabelGenerator(vStandardPieItemLabelGenerator);
    vPiePlot.setForegroundAlpha(0.5f);

    }
    }
    [/code]

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 关于大棚监测的pcb板设计
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用
  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥15 帮我写一个c++工程