Changes to Pie Chart

  • Jason Fletcher

    Jason Fletcher - 2005-03-03

    I was using a previous release of Cewolf 0.9.8 in our application, then upgraded to 10.2. In the process it also upgraded the JFreeChart to 0.9.21. I made the necessary changes to get the code to work again. The implementation of the PieChart was "improved", however, I can't get a pie chart to look the way it used to. Instead of the labels showing up next to the slices, they are showing up on the sides with link lines to the slices. Also, I can't get the 3d pie to "lay down" unless I increase the depthFactor. I want to have a short pie chart that is an ellipse, not a circle.
    I've tried plot.setCircular in my postProcessor, but it didn't make a whole lot of difference.
    Does anyone know the settings to use in the post processor to get the pie chart to look like what used to be the default?
    Here is my existing post processor, (it's kind of cluttered as I have tried a lot of different things to get this to look right...):

    ChartPostProcessor dataColor = new ChartPostProcessor() {
        public void processChart(Object chart, Map params) {
            Color transparent = new Color( 0x00ffffff, true );
            Plot basePlot = ((JFreeChart) chart).getPlot();
            if (basePlot instanceof PiePlot3D) {
                PiePlot3D plot = (PiePlot3D) basePlot;
                for (int i = 0; i < params.size(); i++) {
                    String colorStr = (String) params.get(String.valueOf(i));
                    plot.setSectionPaint(i, java.awt.Color.decode(colorStr));
                PieSectionLabelGenerator generator = new StandardPieItemLabelGenerator("{2}", new DecimalFormat("0"), new DecimalFormat("0%"));

            } else {
                CategoryPlot plot = (CategoryPlot) basePlot;
                for (int i = 0; i < params.size(); i++) {
                    String colorStr = (String) params.get(String.valueOf(i));
                    plot.getRenderer().setSeriesPaint(i, java.awt.Color.decode(colorStr));
                    plot.getRenderer().setSeriesOutlinePaint(i, transparent);
                NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();

                if (rangeAxis.getMaximumAxisValue() < SMALLEST_MAX_SIZE) {


    Any help is appreciated.

    • Brian Fox

      Brian Fox - 2005-03-03

      Try posting on the jfreechart forums. If they did change the layout of the pie charts, I'm sure someone else already figured out how to make it work the old way.


Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.

No, thanks