Jump to content
Changes to the Jaspersoft community edition download ×

x-axis labels  

Recommended Posts

By: Sergio22 - sergio22

x-axis labels Â

2006-01-11 05:00


I have a bar chart with 48 bars on a landscape A4 page. Because of the many bars the x-axis labels are not readable anymore. Is there a way to rotate the labels by 90 degrees?





By: Teodor Danciu - teodord

RE: x-axis labels Â

2006-01-11 05:16




The JFreeChart library lets us rotate the itemÂ

labels at an angle, but our chart component doesÂ

not expose this setting.Â


So you could solve your requirement by implementingÂ

the chart customizer interface.Â

Look at the "charts" sample and see how one of the reports uses an extension of the JRAbstractChartCustomizer Â

to change colors in a bar chart.Â


I hope this helps.Â







By: Sergio22 - sergio22

RE: x-axis labels Â

2006-01-11 07:49

Super thanks for you help the following modification helpedÂ

import net.sf.jasperreports.engine.JRChartCustomizer;Â

import net.sf.jasperreports.engine.JRChartDataset;Â

import net.sf.jasperreports.engine.JRChartPlot;Â

import net.sf.jasperreports.engine.JRChart;Â

import org.jfree.chart.JFreeChart;Â

import org.jfree.chart.renderer.category.BarRenderer;Â

import org.jfree.chart.axis.CategoryLabelPositions;Â


import java.awt.*;Â


public class BarChartCustomizer implements JRChartCustomizerÂ


public void customize(JFreeChart chart, JRChart jasperChart)Â

BarRenderer renderer = (BarRenderer) chart.getCategoryPlot().getRenderer();Â

renderer.setSeriesPaint(0, Color.green);Â

renderer.setSeriesPaint(1, Color.orange);Â



System.out.println("getCategoryLabelPositionOffset : "+chart.getCategoryPlot().getDomainAxis().getCategoryLabelPositionOffset());Â

System.out.println("getCategoryMargin : "+chart.getCategoryPlot().getDomainAxis().getCategoryMargin());Â

System.out.println("getLowerMargin : "+chart.getCategoryPlot().getDomainAxis().getLowerMargin());Â

System.out.println("getMaximumCategoryLabelLines : "+chart.getCategoryPlot().getDomainAxis().getMaximumCategoryLabelLines());Â

System.out.println("getMaximumCategoryLabelWidthRatio : "+chart.getCategoryPlot().getDomainAxis().getMaximumCategoryLabelWidthRatio());Â


Link to comment
Share on other sites

  • 5 months later...
  • Replies 3
  • Created
  • Last Reply

Top Posters In This Topic


This is Atanu. I am very new in ireport and also in java environment. In the ireport I have designed a template .like this.

please look on attach file

size=150]C:Documents and SettingsAtanuMy Documentsgraph.jpeg

Now I want to plot a line graph on the basis of the each data like t1 t2 ---t5 and lcl, ucl, actual value for each row.

That I have done. Now my problem is that I have to change the color of points of t1 t2 ---t5 on the basis of Lcl and Ucl . If the value of t1 ,or t2 or ----t5 are between Ucl and Lcl the color will be blue. And if it out side of Lcl and Ucl then it will be red..

I want the following figure. Where the upper bold line is Ucl and lower bold line isLcl

size=150]C:Documents and SettingsAtanuMy Documentsdata.jpeg

Actually I have got a information that for that I have to write a customizer class for chart. Also I have write it .



Now this customize class ok running successfully with creating jar files.

Now I want to create a logic to check the value of t1 t2 t3 t5 with respect to UCL and LCL. How can I fetch data from report.

Or is there any other way to do this.

Is there any way to pass value from iReport to customizer class ?


What should I do. Please please help me. It’s urget for me.


Any help would be greatly appreciated.

Thanks in advance.

[file name=query-37ab101e3a539a71be9c962f72749d92.doc size=49152]http://www.jasperforge.org/components/com_joomlaboard/uploaded/files/query-37ab101e3a539a71be9c962f72749d92.doc[/file]


Post edited by: atanupanda, at: 2007/02/06 10:06 [file name=query-10b0405423ed738f0fcb200de55b103b.doc size=49152]http://www.jasperforge.org/components/com_joomlaboard/uploaded/files/query-10b0405423ed738f0fcb200de55b103b.doc[/file] size=159]http://www.jasperforge.org/components/com_joomlaboard/uploaded/images/graph-b9f6e4b9c5699f5e036e1a4fc4336297.JPG

Link to comment
Share on other sites

  • 4 years later...
  • 10 months later...
Regarding the question, that how to rotate the x-axis labels, just go the properties of the chart and look for "Category axis Tick Label rotation" here you can fill any desired angle, you want to rotate your labels (ex. 90) it will rotate the horizontal labels to vertical...try this...
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...