In line chart, how to show the values in points ?

Attachments: 
sritharhello's picture
Joined: Jun 13 2013 - 12:15am
Last seen: 8 years 6 months ago

see the answer

khareprabudh1 - 2 years 8 months ago

2 Answers:

Hi,

Check the chart properties there is a option that you need to check to show values.

Regards,

Ajinkya

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

Thanks for the reply.

I'm using the version iReport 3.7.4 ... Show values are not there in properties ... I checked it in "Common Chart properties" and in "Line Plot Properties"....

sritharhello - 10 years 3 months ago

Below code will show values as well as add the "%" sign to that value. In this code i have only one series so i have just used getItemCount(0)  and getY(0,i) to get first series. if you have many series just use a loop at the top level.


    public strictfp void customize(JFreeChart chart, JRChart jasperChart)
    {
       XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) chart.getXYPlot().getRenderer();
       renderer.setBaseItemLabelsVisible(Boolean.TRUE);
       renderer.setBaseItemLabelFont(new Font("SansSerif", Font.PLAIN, 12));
       for(int i = 0 ; i <chart.getXYPlot().getDataset().getItemCount(0); i++){
           Number n = chart.getXYPlot().getDataset().getY(0,i);
           renderer.setBaseItemLabelGenerator((XYItemLabelGenerator) new StandardXYItemLabelGenerator(n.toString().concat("%")));
        }
      
    }

khareprabudh1's picture
Joined: Jul 2 2020 - 2:20am
Last seen: 11 months 2 weeks ago
Feedback