I'm trying to increase the size of the number (0->100) on the Y-axis and the size of colored boxes/shapes in the legend as you can see in this picture: emmanuel.lebel.free.fr/exchange/ftp/3371563802233760414.jpg (sorry but i'm not allowed to post urls)
Here is my code:
Code: Select all
// column keys...
String category = "";
// create the dataset...
DefaultCategoryDataset dataset = new DefaultCategoryDataset();
dataset.addValue(xx, "Paid out commitment", category);
...
JFreeChart chart = ChartFactory.createBarChart(
"", // chart title
"", // domain axis label
"% of commited amount", // range axis label
dataset, // data
PlotOrientation.VERTICAL, // the plot orientation
true, // include legend
true,
false
);
chart.setBackgroundPaint(Color.white);
chart.setBorderVisible(false);
// Legend
Font font = chart.getLegend().getItemFont();
font = new Font(font.getName(),font.getStyle(), 24);
chart.getLegend().setItemFont(font);
// get a reference to the plot for further customisation...
CategoryPlot plot = (CategoryPlot) chart.getPlot();
plot.setNoDataMessage("NO DATA!");
// Chart
CategoryItemRenderer renderer = plot.getRenderer();
renderer.setItemLabelGenerator(new StandardCategoryItemLabelGenerator("{2}%", new DecimalFormat("0.00")));
renderer.setItemLabelsVisible(true);
font = renderer.getBaseItemLabelFont();
font = new Font(font.getName(),font.getStyle(), 20);
renderer.setBaseItemLabelFont(font);
plot.setRenderer(renderer);
plot.setOutlinePaint(null);
plot.setOutlineStroke(null);
plot.setBackgroundPaint(Color.white);
// Range Axis
NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
rangeAxis.setRange(0.0, 100.0);
rangeAxis.setTickUnit(new NumberTickUnit(10, new DecimalFormat("0")));
rangeAxis.setUpperMargin(0.1);
font = rangeAxis.getTickLabelFont();
font = new Font(font.getName(),font.getStyle(), 24);
rangeAxis.setLabelFont(font);
font = rangeAxis.getLabelFont();
font = new Font(font.getName(),font.getStyle(), 18);
rangeAxis.setLabelFont(font);
ChartUtilities.saveChartAsJPEG(file, chart, width, height);
Manu