Jump to content
We've recently updated our Privacy Statement, available here ×

keth

Recommended Posts

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

 

 

 

Link to comment
Share on other sites

  • Replies 4
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...