Jump to content
Changes to the Jaspersoft community edition download ×

Rashmi Nagaraja

Recommended Posts

 

I am facing problems with Bar chart of Ireport. In Pie Charts, for legend and legend labels I use 0,1,2 and display values along with their percentages. I want to do a similar thing for Bar Charts. I want to display the value for each bar along its category as below.

 http://i.stack.imgur.com/ey4CP.jpg

Across forums, suggestions have been placed to use customizer class. Is there a simpler way to do what I require? If I need to use customizer class, is there a sample available? I am using the latest I report and jasper server 5.0

Any help would be highly appreciated. Thanks

Link to comment
Share on other sites

  • Replies 11
  • Created
  • Last Reply

Top Posters In This Topic

Thanks Ajinkya. Yes, I unchecked and checked again to get the 'Show Labels' property to get the values and it did work. For the shortest bar, the value doesn't get displayed. I reduced the font size to the possible level('6' to be precise) where users can view the values, but the shortest bar doesn't show the value since it is very small in size. Is there something I need to do so that value is displayed for the shortest bar?
Link to comment
Share on other sites

For now there is no 'Show Labels' attribute for the line plot. But you can render the labels visible using a chart customizer:

 

public void customize(JFreeChart chart, JRChart jasperChart){

LineAndShapeRenderer lineRenderer = (LineAndShapeRenderer)chart.getCategoryPlot().getRenderer();

lineRenderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());

lineRenderer.setBaseItemLabelsVisible(true);

}

 

If it's an XY line chart, use an XYPlot and a StandardXYItemLabelGenerator in the above code snippet.

 

I hope this helps,

sanda

 

Link to comment
Share on other sites

This works like a charm for Line Charts. Thanks a ton.I had a query for Bar Charts. Show labels works for bar Chart. But the value of the shortest bar doesn't get displayed. I reduced the font size to the possible level('6' to be precise) where users can view the values, but the shortest bar doesn't show the value since it is very small in size. Is there something I need to do so that value is displayed for the shortest bar?
Link to comment
Share on other sites

  • 1 month later...
  • 1 month later...

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...