JFreeChart Margin
I am very new to this.
I am using jasperreport to create a line chart for my webapps.
I have successfully passed the dataset to the compiled Jasperreport
(created in iReport) and can see the data correctly.
However, I want to do some customization on the margin.
The value shown on the line chart is trimming for the highest value as
there is no margin.
The X-Axis label is coming after few empty space from Y-Axis 0 value. I
want to remove that margin and start the X-Axis from very close to the
meeting point of X & Y.
Please see the picture.
I am using customized class which is defined in my webspps. I am able to
change the font size and rotation of the label but don't know how to
adjust margin.
public class LineChartCustomizer implements JRChartCustomizer {
private static Log log = LogFactory.getLog(LineChartCustomizer.class);
@Override
public void customize(JFreeChart jFreeChart, JRChart jrChart) {
CategoryPlot plot = jFreeChart.getCategoryPlot();
DecimalFormat dfKey = new DecimalFormat("###,###");
StandardCategoryItemLabelGenerator labelGenerator = new
StandardCategoryItemLabelGenerator("{2}", dfKey);
/*
* {0} - label would be equal to Series expression,
* {1} - label would be equal to Category expression,
* {2} - label would be equal to Value expression
*
*/
LineAndShapeRenderer renderer = new LineAndShapeRenderer();
renderer.setBaseItemLabelsVisible(true);
renderer.setBaseItemLabelGenerator(labelGenerator);
renderer.setBaseItemLabelFont(new java.awt.Font("SansSerif",
java.awt.Font.PLAIN, 4));
/*
renderer.setSeriesPositiveItemLabelPosition(0,
new
ItemLabelPosition(ItemLabelAnchor.OUTSIDE3,
TextAnchor.BOTTOM_LEFT,
TextAnchor.BOTTOM_LEFT,
Math.PI));*/
renderer.setSeriesShape(0, ShapeUtilities.createDiamond(1F));
plot.setRenderer(renderer);
}
}
See the image : http://tinypic.com/r/2lidiz6/5
No comments:
Post a Comment