Rashmi Nagaraja Posted February 12, 2013 Share Posted February 12, 2013 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.jpgAcross 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.0Any help would be highly appreciated. Thanks Link to comment Share on other sites More sharing options...
szaharia Posted February 12, 2013 Share Posted February 12, 2013 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 Link to comment Share on other sites More sharing options...
ajinkya_c Posted February 15, 2013 Share Posted February 15, 2013 HiIt 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. Link to comment Share on other sites More sharing options...
Rashmi Nagaraja Posted February 18, 2013 Author Share Posted February 18, 2013 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 More sharing options...
Rashmi Nagaraja Posted February 18, 2013 Author Share Posted February 18, 2013 Also, could you please tell how to display values for Line chart as well? Link to comment Share on other sites More sharing options...
Rashmi Nagaraja Posted February 18, 2013 Author Share Posted February 18, 2013 Thanks Sanda. Could you please tell me how to display values for Line chart as well? Link to comment Share on other sites More sharing options...
szaharia Posted February 18, 2013 Share Posted February 18, 2013 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 More sharing options...
Rashmi Nagaraja Posted February 18, 2013 Author Share Posted February 18, 2013 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 More sharing options...
szaharia Posted February 18, 2013 Share Posted February 18, 2013 Do you have a printscreen, or a test sample that illustrates this problem? I couldn't reproduce it locally. Thanks, sanda Link to comment Share on other sites More sharing options...
Rashmi Nagaraja Posted February 19, 2013 Author Share Posted February 19, 2013 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. Link to comment Share on other sites More sharing options...
shatad0101 Posted April 17, 2013 Share Posted April 17, 2013 Hi Rasmi, Could you explain me how to use these chart customizer in iReport, because i have no idea about java. Link to comment Share on other sites More sharing options...
sritharhello Posted June 13, 2013 Share Posted June 13, 2013 I have the same requirement for line chart... Could anyone help me on this topic? Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now