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 微信公众号自制会员卡没有收款渠道啊
  • ¥15 stable diffusion
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿