Jump to content
Changes to the Jaspersoft community edition download ×

cjasper

Recommended Posts

I am having an issue which is can we add the “%” in the value axis. e.g. instead of (0,5,10…..) in the y axis can we have (0.0 % , 5.0% , 10.0%).the “value axis tick level mask” mask is not working in jasper server.

the thread  "http://community.jaspersoft.com/questions/539134/value-axis-tick-label-expression-timeseries-chart-ireports#comment-800971"  relates closely to my problem. I have attached the images.The required.jpeg  file is what actually needs to be done and current chart,jpeg shows what i am actually getting.

Thanks

Link to comment
Share on other sites

  • Replies 6
  • Created
  • Last Reply

Top Posters In This Topic

 

1.   You  will need to add below in the iReport XML part directly. Somehow jasper does not take “Value Axis Tick Label Mask” property from Chart Properties window.Valueaxistick.JPG.70f69f9c1bf2da341b0ee4db8b6315ee.JPG                                      

                                                                              

2. Save report from xml window, then open design window and save report to repository.

 

 

Link to comment
Share on other sites

 

Hi . this is the method i used to customize it 
 
public void customize(JFreeChart chart, JRChart jasperChart) {
        Plot plot = chart.getPlot();
 
        if (plot instanceof CategoryPlot) {
            CategoryPlot catPlot = (CategoryPlot) plot;
 
 
            BarRenderer renderer = (BarRenderer) catPlot.getRenderer();
            //ser bar widht
            renderer.setMaximumBarWidth(0.07);
            //set margin between two bar('of one year')
            renderer.setItemMargin(0.0f);
 
            NumberAxis leftNumberAxis = (NumberAxis) catPlot.getRangeAxis();
            leftNumberAxis.setUpperMargin(0.30);
            leftNumberAxis.setNumberFormatOverride(new NumberFormat() {
 
                @Override
                public StringBuffer format(double number, StringBuffer toAppendTo, FieldPosition pos) {
 
                    return new StringBuffer(String.valueOf(number).concat("%"));
                }
 
                @Override
                public StringBuffer format(long number, StringBuffer toAppendTo, FieldPosition pos) {
 
 
 
                    return new StringBuffer(String.valueOf(number).concat("%"));
                }
 
                @Override
                public Number parse(String source, ParsePosition parsePosition) {
                    throw new UnsupportedOperationException("Not supported yet.");
                }
            });
        }
    }
Link to comment
Share on other sites

  • 4 weeks later...

A shorter way to do cjasper's solution is something like this:

 

public class MyCustomizer implements JRChartCustomizer {

 

@Override

public void customize(JFreeChart chart, JRChart jasperChart) {

NumberAxis numAxis = (NumberAxis) chart.getCategoryPlot().getRangeAxis();

numAxis.setNumberFormatOverride(new DecimalFormat("#,##0"));

}

}

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...