petrm Posted May 27, 2010 Share Posted May 27, 2010 Hi,is there a way how to make vertical labels on the X-axis of a bar chart? I found a solution for JChart:http://jcharts.sourceforge.net/usersGuide/0.7/axisCharts.html#verticalXAxisLabelsbut I don't know how to use it with JR (if it's possible). Thanks, Petr Link to comment Share on other sites More sharing options...
danielsb2 Posted May 27, 2010 Share Posted May 27, 2010 You can use a chart customizer like that, and set the properties that not is possible to set in iReport Code:package br.anc.reports.chart;import org.jfree.chart.JFreeChart;import org.jfree.chart.axis.NumberAxis;import org.jfree.chart.plot.CategoryPlot;import net.sf.jasperreports.engine.JRChart;import net.sf.jasperreports.engine.JRChartCustomizer;public class MyCustomChart implements JRChartCustomizer{ public void customize(JFreeChart chart, JRChart jasperChart){ CategoryPlot plot = (CategoryPlot)chart.getPlot(); // Set the x-axis range (0 to 5, only integers) NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setRange(0, 5); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); //Set Item label (Font/size) CategoryItemRenderer categoryRenderer = plot.getRenderer(); categoryRenderer.setBaseItemLabelFont(new Font("Arial", Font.PLAIN, 5)); //BarRenderer barRenderer = (BarRenderer) plot.getRenderer(); //barRenderer.setDrawBarOutline(false); //barRenderer.setItemMargin(.1); } } Link to comment Share on other sites More sharing options...
szaharia Posted May 27, 2010 Share Posted May 27, 2010 You could use the labelRotation attribute of the <plot /> element, or the labelRotation attribute of the <categoryAxisFormat /> element.Hope this helps,Sanda Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now