Charts

0

Hi,

In my Current project i need to create a Line Graph. i am using Jasper 3.5.

But the problem is i can not number my Y Axis continuously. after i define min and max values for Y axis

it shows only the range of values instead of continous numbering though the Axis.(it shows 0,5,10,15 instead of 1,2,3,4,5,6,7,8...etc).

Can any one help me to solve this? Can we use chart customizer to solve this?

 

any help greatly appreciate

 

Thanks,

Keth

 

 

 

keth's picture
5
Joined: Oct 1 2009 - 7:08am
Last seen: 4 years 6 months ago

4 Answers:

0

I am also interested in the answer to this question.

I am encountering the same issue.

 

Thanks,

D Grove



Post Edited by dgrove at 10/08/2009 13:23
dgrove's picture
9
Joined: Oct 8 2009 - 6:00am
Last seen: 4 years 6 months ago
0

Keth,

 

JFreeChart has an algorithm to decide how many labels to show. Normally it's quite good, but in this case you want to override it. A chart customizer can definitely solve this. Likewise, a chart theme could solve it (since a chart theme is like a chart customizer but newer and more powerful).

 

But the details aren't so easy to supply. It will require Java coding and knowledge of the JFreeChart API. There is a chart theme example that ships with JasperReports. There is a chart customizer example that is included with the sample reports in JasperServer Pro. These are good starting points.

 

Regards,
Matt

mdahlman's picture
1555
Joined: Mar 13 2007 - 2:43am
Last seen: 8 months 5 days ago
0

Hi Matt,

Thanks for the reply. i was able to solve the problem. i posting it here so others can refer it

 

public class LineChartCustomizer extends JRAbstractChartCustomizer {
    public void customize(JFreeChart chart, JRChart jasperChart) {
        LineAndShapeRenderer renderer = (LineAndShapeRenderer) chart.getCategoryPlot().getRenderer();
        renderer.setSeriesPaint(1, Color.green);
        renderer.setSeriesPaint(4, Color.orange);
       
       
        // get a reference to the plot for further customisation...
        final CategoryPlot plot = chart.getCategoryPlot();
        // change the auto tick unit selection to integer units only...
        final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
       
        rangeAxis.setTickUnit(new NumberTickUnit(1));
  
        rangeAxis.setUpperBound(24);
             
         chart.setTitle("Setting the title ");
    }       
}

 

Your blog post post was very helpful for achive this.

 

Thanks

keth

keth's picture
5
Joined: Oct 1 2009 - 7:08am
Last seen: 4 years 6 months ago
0

Hello,

Thank you for the replies.

Keth, how and where did you apply that change ?

I have checked through various files but cannot find where to put/modify this information.

dgrove's picture
9
Joined: Oct 8 2009 - 6:00am
Last seen: 4 years 6 months ago
Feedback
randomness