请问如何设置背景色为白色啊,调用方法chart.setBackgroundPaint(Color.white); 不起作用。 
还有当我设置plot.setSimpleLabels(true);的时候饼图上面的百分比会互相覆盖,请问怎么设置呢? 
图片看这个地址!
http://www.iteye.com/problems/69837

解决方案 »

  1.   

    现在默认背景色是灰色,十分难看,下面是我的代码。JFreeChart chart = ChartFactory.createPieChart(title, dataset, true, false, false);
    chart.setBackgroundPaint(Color.WHITE);
    chart.setTitle(new TextTitle(title,new Font("宋体", Font.BOLD, 14)));
    LegendTitle legend = chart.getLegend(0);
    legend.setItemFont(new Font("宋体",Font.BOLD,10));//修改图例的字体
    legend.setPosition(RectangleEdge.TOP);//设置图例的位置
    // legend.setLegendItemGraphicPadding(RectangleInsets.ZERO_INSETS);
    PiePlot plot = (PiePlot)chart.getPlot();
    plot.setLabelFont(new Font("宋体",Font.BOLD,10));//设置饼图各部分标签字体
    plot.setNoDataMessage("没有数据");
        plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{1},{2}"));
        plot.setToolTipGenerator(new StandardPieToolTipGenerator());
        plot.setLabelBackgroundPaint(new Color(220, 220, 220));
        plot.setLegendLabelToolTipGenerator(new StandardPieSectionLabelGenerator("Tooltip for legend item {0}"));
        plot.setSimpleLabels(true);
        plot.setInteriorGap(0.0D);
    plot.setBackgroundAlpha(0.9f);
    name = ServletUtilities.saveChartAsPNG(chart,280, 280,null, null);
      

  2.   

    你用的是1.0.9吗 这个版本有bug 用1.0.1版本吧