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

MrsTang
  • 3,119
  • 1
  • 19
  • 24
Rashmi Nagaraja
  • 801
  • 11
  • 20

3 Answers3

1

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.

MrsTang
  • 3,119
  • 1
  • 19
  • 24
  • 1
    Apparently, latest Ireport does support this requirement. If the show labels is checked, uncheck and recheck the same to see the values for each bar. There is a small glitch though. I have one very short bar. Only for that particular bar, the value doesnt get displayed. I am trying to look for a work around for the same – Rashmi Nagaraja Feb 18 '13 at 06:16
0

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}
Sharad
  • 3,562
  • 6
  • 37
  • 59
-1

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})
Kev
  • 118,037
  • 53
  • 300
  • 385