2006 IR Open Dicussion Posted September 5, 2006 Share Posted September 5, 2006 By: rwdenney5 - rwdenney5 Bar Chart: Rotating the Category Expression 2006-06-14 14:21 I've created a simple 3D bar chart but the category labels are being truncated because they are too long. Some of JFreeChart's demos show the category lables rotated at a 45 degree angle... any idea how to do that in iReport? Thanks, Ryan By: Marcelo Fernandes - mcf-rocha RE: Bar Chart: Rotating the Category Expressi 2006-06-15 13:06 Ryan, I think it's impossible nowadays with iReport. Although it's possible to be done using the JFreeChart in your application, there isn't such option in iReport's GUI. You will have to create your JFreeChart outside iReport and pass it as a parameter for JasperReport to be displayed as an image. Finally, about rotating the labels, try this on JasperReports: final JFreeChart chart = ChartFactory.createBarChart3D( "blablabla", // chart title "domain", // domain axis label "range", // range axis label dataset, // data PlotOrientation.HORIZONTAL, // orientation true, // include legend true, // tooltips false // urls ); final CategoryPlot plot = chart.getCategoryPlot(); final CategoryAxis axis = plot.getDomainAxis(); axis.setCategoryLabelPositions( CategoryLabelPositions.createUpRotationLabelPositions(2*Math.PI) ); I've been trying to find a way to fix the range axis of a a simple 3D bar chart in iReport but it's only possible in the same way. Marcelo Carvalho Fernandes By: rwdenney5 - rwdenney5 RE: Bar Chart: Rotating the Category Expression 2006-06-19 11:33 Thanks Marcelo. I kind of figured as much. I'm wondering though if I could use a customizer class to extend the functionality of iReport's charting. I'm assuming that the customizer class would allow access to the entire jfreechart api, but I've not been able to implement it. I'm not sure of the classpath. Anyone have any ideas? Thanks, Ryan By: Marcelo Fernandes - mcf-rocha RE: Bar Chart: Rotating the Category Expressi 2006-06-19 11:39 You're welcome Ryan, I have no idea about using the Customizer Class. Can you send to me the source-code of your class so that I can make some tests? Marcelo By: rwdenney5 - rwdenney5 RE: Bar Chart: Rotating the Category Expression 2006-06-19 13:52 I was actually just trying to test one of the samples included in the jasperreports download... jasperreports-1.2.2demosampleschartsBarChartCustomizer.java If I can figure out how to get my chart to compile using the customizer class then I should be all set because I think I'll be able to customize the charts using the jfreechart api. Thanks, Ryan Link to comment Share on other sites More sharing options...
zerglicious Posted October 9, 2007 Share Posted October 9, 2007 Here is a Chart Customizer class that rotates 3DBarChart labels: Code:import java.awt.Font;import net.sf.jasperreports.engine.JRChart;import net.sf.jasperreports.engine.JRChartCustomizer;import org.jfree.chart.JFreeChart;import org.jfree.chart.axis.CategoryAxis;import org.jfree.chart.axis.CategoryLabelPositions;import org.jfree.chart.labels.ItemLabelAnchor;import org.jfree.chart.labels.ItemLabelPosition;import org.jfree.chart.plot.CategoryPlot;import org.jfree.chart.renderer.category.BarRenderer3D;import org.jfree.ui.TextAnchor;public class ItemStatusBarChartCustomizer implements JRChartCustomizer{ public void customize(JFreeChart jfc, JRChart jrchart) { CategoryPlot plot = jfc.getCategoryPlot(); CategoryAxis axis = plot.getDomainAxis(); axis.setCategoryLabelPositions(CategoryLabelPositions.UP_45); axis.setLabelFont(new Font("Verdana",Font.PLAIN, 7)); axis.setTickLabelFont(new Font("Verdana",Font.PLAIN, 7)); BarRenderer3D renderer = (BarRenderer3D) plot.getRenderer(); renderer.setItemLabelsVisible(true); renderer.setPositiveItemLabelPositionFallback( new ItemLabelPosition(ItemLabelAnchor.OUTSIDE10, TextAnchor.TOP_CENTER)); renderer.setNegativeItemLabelPositionFallback( new ItemLabelPosition(ItemLabelAnchor.OUTSIDE10, TextAnchor.TOP_CENTER)); } } Link to comment Share on other sites More sharing options...
wnasich Posted May 24, 2012 Share Posted May 24, 2012 New solution:See labelRotation> http://jasperreports.sourceforge.net/schema.reference.html#plot_labelRotationUsage: Edit in xml mode, and add the "plot" tag with labelRotation attribute. Example: Code: 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