Display of Values for each bar in bar chart

-1

 

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.

 Bar Chart

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

Rashmi Nagaraja's picture
Joined: Nov 13 2012 - 4:08am
Last seen: 4 years 7 months ago

2 Answers:

0

Hi,

In iReport try to enable the 'Show Labels' property of the Bar plot and see if it helps.

If you need to customize the item label appearance in a different way, a chart customizer is then recommended.

Regards,

sanda

shertage's picture
1932
Joined: Sep 26 2006 - 8:06pm
Last seen: 3 days 4 hours ago

Thanks Sanda. Could you please tell me how to display values for Line chart as well?

Rashmi Nagaraja - 6 years 5 months ago

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

shertage - 6 years 5 months ago

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?

Rashmi Nagaraja - 6 years 5 months ago
show 3 more...

Do you have a printscreen, or a test sample that illustrates this problem? I couldn't reproduce it locally.

Thanks,
sanda

shertage - 6 years 5 months ago

Thanks Sanda for all your inputs. It really helped me . I forgot to mention Bar Chart 3D. I have now changed it into 2D Bar Chart and it works perfectly. I will surely paste the sample for future references. Thanks again.

Rashmi Nagaraja - 6 years 5 months ago

Hi Rasmi,

Could you explain me how to use these chart customizer in iReport, because i have no idea about java.

shatad0101 - 6 years 3 months ago
-1

Hi

It is possible with 'Show Label' option as well as 'class customizer' as Shertage said, If 'show label' option already checked then unchecked it and again checked so that it works. 

ajinkya_c's picture
976
Joined: Aug 29 2012 - 6:13am
Last seen: 2 years 4 months ago

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?

Rashmi Nagaraja - 6 years 5 months ago

Also, could you please tell how to display values for Line chart as well?

Rashmi Nagaraja - 6 years 5 months ago

I have the same requirement for line chart... Could anyone help me on this topic?

sritharhello - 6 years 1 month ago
Feedback
randomness