1
votes

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

3

3 Answers

1
votes

To my knowledge in JasperReports does not support this requirement for bar chart by configuration but as you found out by customization.

A chart customizer allows you to access full functionality of both jfreechart object and jasperreports chart object.

You need to implement the interface net.sf.jasperreports.engine.JRChartCustomizer. In the customize method you'd access your bar chart and modify the labels configuration.

An example can be found in the sample reference of JasperReports.

0
votes

Select the "Chart Data" of the graph and click on the "Details" section and open the "Category" which you have created and go to "Item Hyperlink" section and here in "Tooltip" section you can define the category and Value by concatenation them.

 "Category Name" + " = " + $F{Value_column}
-1
votes

For put a values on each bar:

  • create a new field of type String $F{FieldBarChart}
  • Select chart Data -> details -> modify category series -> and fill Label Expression like as $F{FieldBarChart}.valueOf($F{value_column})