Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#156 piePlot.setExplodePercent() throws IllegalArgumentException

closed-works-for-me
David Gilbert
General (896)
5
2004-02-16
2003-04-15
m.hilpert
No

Having a chart created via ChartFactory.createPieChart
(chartTitle,DatasetUtilities.createPieDatasetForColumn
(dataset, 0), showLegend, false, false);

calling setExplodePercent() on the piePlot throws

---
java.lang.IllegalArgumentException:
PiePlot.setExplodePercent(int, double): section outside
valid range.
at
com.jrefinery.chart.plot.PiePlot.setExplodePercent
(Unknown Source)
---

The "section" (= series) is valid as i have 4 series,
checked with system.out and set '2' as section.

Discussion

  • David Gilbert
    David Gilbert
    2003-06-02

    Logged In: YES
    user_id=112975

    Here's some code I used to try to replicate the problem. It
    doesn't generate an exception for me, so if possible can you
    modify the example to that it does fail...that will help me
    to track down the problem.

    Regards,

    Dave Gilbert

    package org.jfree.chart.demo;

    import org.jfree.chart.ChartFactory;
    import org.jfree.chart.ChartPanel;
    import org.jfree.chart.JFreeChart;
    import org.jfree.chart.plot.PiePlot;
    import org.jfree.data.DatasetUtilities;
    import org.jfree.data.DefaultCategoryDataset;
    import org.jfree.data.PieDataset;
    import org.jfree.ui.ApplicationFrame;
    import org.jfree.ui.RefineryUtilities;

    /**
    * A pie chart test for debugging 721737 and 721733.
    *
    * @author David Gilbert
    */
    public class PieChartTest extends ApplicationFrame {

    /**
    * Default constructor.
    *
    * @param title the frame title.
    */
    public PieChartTest(String title) {

    super(title);

    PieDataset data = createDataset();

    // create the chart...
    JFreeChart chart = ChartFactory.createPieChart(
    "Pie Chart Test", // chart title
    data, // data
    true, // include legend
    true,
    false
    );

    // set the background color for the chart...
    PiePlot plot = (PiePlot) chart.getPlot();

    plot.setSectionLabelType(PiePlot.NAME_AND_PERCENT_LABELS);
    plot.setDefaultOutlinePaint(null);

    plot.setRadius(0.60);
    plot.setExplodePercent(2, 1.00);

    // add the chart to a panel...
    ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new
    java.awt.Dimension(500, 270));
    setContentPane(chartPanel);

    }

    private PieDataset createDataset() {
    // create a dataset...
    DefaultCategoryDataset c = new DefaultCategoryDataset();
    c.addValue(34.3, "Series 1", "Category 1");
    c.addValue(12.5, "Series 1", "Category 2");
    c.addValue(27.0, "Series 2", "Category 1");
    c.addValue(38.8, "Series 2", "Category 2");
    c.addValue(53.2, "Series 3", "Category 1");
    c.addValue(97.3, "Series 3", "Category 2");
    c.addValue(56.1, "Series 4", "Category 1");
    c.addValue(23.9, "Series 4", "Category 2");

    return DatasetUtilities.createPieDatasetForColumn(c, 0);
    }

    /**
    * Starting point for the demonstration application.
    *
    * @param args ignored.
    */
    public static void main(String[] args) {

    PieChartTest demo = new PieChartTest("Pie Chart Test");
    demo.pack();
    RefineryUtilities.centerFrameOnScreen(demo);
    demo.setVisible(true);

    }

    }

     
  • David Gilbert
    David Gilbert
    2003-06-02

    • labels: --> General
    • assigned_to: nobody --> mungady
     
  • David Gilbert
    David Gilbert
    2004-02-16

    • status: open --> closed-works-for-me