jeipack Posted March 26, 2007 Share Posted March 26, 2007 HiI have a problem with the labels in my bar chart.The labeltext is cut, but it most nut be cut.have you any ideas to solve this problem? Link to comment Share on other sites More sharing options...
fwhorton Posted March 27, 2007 Share Posted March 27, 2007 I had the same problem and I posted a question with no reply. So eventually I just had to expand the chart. Link to comment Share on other sites More sharing options...
ag201 Posted March 29, 2007 Share Posted March 29, 2007 rotate your graph so that its vertical and not horizontal, that will give the labels some more space. Link to comment Share on other sites More sharing options...
zmanning Posted October 2, 2007 Share Posted October 2, 2007 Hey I know this is an old post but for anyone else looking to do this, use a chart customizer w/: Code:CategoryPlot plot = chart.getCategoryPlot();cata.setMaximumCategoryLabelWidthRatio(2f);or Code:[code]CategoryPlot plot = chart.getCategoryPlot();cata.setMaximumCategoryLabelLines(2); Hope this helps someone. Link to comment Share on other sites More sharing options...
derek_ricca Posted October 2, 2007 Share Posted October 2, 2007 This may be a stupid question but can you give a full example of how to do that in the customize() function? I have a good idea but I'm still learning how to customize through iReport. Speaking of which, where would I put my class once it's compiled, and how would I tell my chart in iReport where to find it? Link to comment Share on other sites More sharing options...
mdahlman Posted October 23, 2007 Share Posted October 23, 2007 It's not a stupid question at all. Sometimes even when you understand the idea perfectly it can be tough to get all of the details exactly correct. Here are my notes from creating a chart customizer that allows long category labels. 1. mkdir com/jaspersoft/demo2. create the chart customizer in the demo directory (code below)3. set CLASSPATH=%CLASSPATH%;C:/JasperSoft/iReport-2.0/lib/jasperreports-2.0.2.jar4. set CLASSPATH=%CLASSPATH%;C:/JasperSoft/iReport-2.0/lib/jfreechart-1.0.0.jar5. javac -target 1.5 -source 1.5 com/jaspersoft/demo/MyChartCustomizer.java6. jar -cf MyCustomizers.jar com Now you have a jar file that contains your compiled chart customizer. To run the report in iReport you can add MyCustomizers.jar to the classpath with the menu Options->Classpath. (It will pick the .jar file up automatically if it's in the working directory. But I recommend setting it explicitly to be clear.) To run the report in JasperServer just upload the .jar file and then add a reference on the Report Unit to it. I hope my notes will be useful for someone. -MattCode:package com.jaspersoft.demo;/** * * @author gtoffoli * Modified 19 Aug 2007 by mdahlman * */import net.sf.jasperreports.engine.JRChart;import net.sf.jasperreports.engine.JRChartCustomizer;import org.jfree.chart.JFreeChart;import org.jfree.chart.axis.NumberAxis;import org.jfree.chart.plot.XYPlot;import org.jfree.chart.plot.CategoryPlot;import org.jfree.chart.renderer.category.BarRenderer;import org.jfree.chart.axis.CategoryAxis;public class BarLabels implements JRChartCustomizer { public void customize(JFreeChart jFreeChart, JRChart jrChart) { CategoryPlot plot = jFreeChart.getCategoryPlot(); BarRenderer renderer = (BarRenderer) plot.getRenderer(); CategoryAxis axis = plot.getDomainAxis(); axis.setMaximumCategoryLabelWidthRatio(1.5f); } }Post edited by: mdahlman, at: 2007/10/24 21:02 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