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

0
Attachments: 
sritharhello's picture
Joined: Jun 13 2013 - 12:15am
Last seen: 5 years 11 months ago

see the answer

khareprabudh1 - 1 month 1 week ago

2 Answers:

0

Hi,

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

Regards,

Ajinkya

ajinkya_c's picture
943
Joined: Aug 29 2012 - 6:13am
Last seen: 3 years 11 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 - 7 years 8 months ago
0

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: 3 weeks 6 days ago
Feedback