The following three images best illustrate the problem:
1.0.6 behavior
1.0.9 behavior
1.0.10 behavior (from SVN source at revision 1009)
Specifically, I noticed that the post 1.0.6 releases all seem to reserve a larger area on the left and right edges of the plot area which causes most longer labels to wrap. I have played with every inset, margin, padding option I can find for the chart/labels and I cannot seem to force the labels to use the extra whitespace that exists on the edges.
The following is the simple source file that creates the pie chart shown in the images. Does anyone have any suggestions to correct the problem or is this just a bug in the new label distribution?
- Code: Select all
package com.chart;
import java.awt.Color;
import java.awt.Font;
import java.io.File;
import java.io.IOException;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartUtilities;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.PiePlot;
import org.jfree.chart.title.TextTitle;
import org.jfree.data.general.DefaultPieDataset;
import org.jfree.data.general.PieDataset;
public class PieTest {
public static void main(String[] args) throws IOException {
String fileName = args.length > 0 ? args[0] : "piechart.png";
JFreeChart pieChart = createChart(createDataset());
File chartFile = new File(fileName);
ChartUtilities.saveChartAsPNG(chartFile, pieChart, 300, 200);
}
private static PieDataset createDataset() {
DefaultPieDataset dataset = new DefaultPieDataset();
dataset.setValue("Tribbey, Chester", new Double(160.0));
dataset.setValue("Pittari, Cyril", new Double(122.0));
dataset.setValue("Noffer, Jacky", new Double(118.0));
dataset.setValue("Kochevar, Branden", new Double(76.0));
dataset.setValue("Juhnke, Fred", new Double(48.0));
dataset.setValue("Gardner, Jon", new Double(44.75));
dataset.setValue("Engle, Sheldon", new Double(44.5));
dataset.setValue("Bruend, Pierre", new Double(40.0));
dataset.setValue("Belgrade, Del", new Double(33.0));
dataset.setValue("Aughen, Quentin", new Double(8.0));
dataset.setValue("Abington, Bill", new Double(8.0));
return dataset;
}
private static JFreeChart createChart(PieDataset dataset) {
JFreeChart chart = ChartFactory.createPieChart(
"Pie Test",
dataset,
false,
false,
false);
chart.setBorderVisible(true);
chart.setBackgroundPaint(Color.WHITE);
TextTitle title = chart.getTitle();
title.setFont(new Font("SansSerif", Font.BOLD, 12));
title.setPaint(Color.GRAY);
PiePlot plot = (PiePlot)chart.getPlot();
plot.setNoDataMessage("No data available");
plot.setIgnoreZeroValues(true);
plot.setCircular(false);
plot.setOutlinePaint(null);
plot.setLabelFont(new Font("SansSerif", Font.PLAIN, 8));
plot.setLabelGap(0.02);
plot.setLabelOutlinePaint(null);
plot.setLabelShadowPaint(null);
plot.setLabelBackgroundPaint(Color.WHITE);
plot.setBackgroundPaint(Color.WHITE);
return chart;
}
}
