cjasper Posted November 17, 2012 Share Posted November 17, 2012 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 More sharing options...
ajinkya_c Posted November 21, 2012 Share Posted November 21, 2012 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. 2. Save report from xml window, then open design window and save report to repository. Link to comment Share on other sites More sharing options...
cjasper Posted November 21, 2012 Author Share Posted November 21, 2012 hi @ajinkya_c .Thanks for the reply.I did this using customizer class.I will try this option too. Link to comment Share on other sites More sharing options...
ajinkya_c Posted November 22, 2012 Share Posted November 22, 2012 Can you please share how you do with customizer class ?. Link to comment Share on other sites More sharing options...
cjasper Posted November 22, 2012 Author Share Posted November 22, 2012 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 More sharing options...
ajinkya_c Posted November 22, 2012 Share Posted November 22, 2012 Thanks for reply Link to comment Share on other sites More sharing options...
swarm357 Posted December 14, 2012 Share Posted December 14, 2012 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now