Jump to content
We've recently updated our Privacy Statement, available here ×

vertical labels for X-axis in charts


petrm

Recommended Posts

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

 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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...