dman Posted April 27, 2009 Share Posted April 27, 2009 hi all, any idea how to configure the axis range of a bar chart to display only integer values?what i get is: 0.1, 0.2, ... 1, ... 3 values (see appended image). do i need to use a customizer class?i read in a post a short while ago not to use the customizer classes (deprecated??) but to use chart themes. what is then the correct way to use a theme to configure the axis ticks in order to solve my problem? thanks for any help in advanceregards,DM Link to comment Share on other sites More sharing options...
rameshinpower Posted April 29, 2009 Share Posted April 29, 2009 Decrease the width of the chart and see the result.......... Link to comment Share on other sites More sharing options...
dman Posted April 29, 2009 Author Share Posted April 29, 2009 amazing.... i don't know how but it works:-) anyhow i think it is better to use a customizer class to get the job done: public class BarChartCustomizer extends JRAbstractChartCustomizer { public void customize(JFreeChart jFreeChart, JRChart jrChart) { CategoryPlot catPlot = jFreeChart.getCategoryPlot(); final NumberAxis rangeAxis = (NumberAxis) catPlot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); }} br,DM Link to comment Share on other sites More sharing options...
ktlam1955 Posted March 18, 2011 Share Posted March 18, 2011 How do I add this in iReport? Link to comment Share on other sites More sharing options...
dman Posted March 22, 2011 Author Share Posted March 22, 2011 i'm not sure... there might be a better (simpler) solution yet, but if you still decide to use a chart cutomizer:... 1) define your chart customizer as described above public class MyChartCustomizer extends JRAbstractChartCustomizer { ....} 2) create your chart within iReport 3) select this chart; define the path to your chart customizer class (with full package name) in the properties pane (properties -> common chart properties -> customizer class): "the.path.to.my.customizer.MyChartCustomizer" 4) add the folder/jar where your package is located via menu: options -> classpath Link to comment Share on other sites More sharing options...
mdahlman Posted April 18, 2011 Share Posted April 18, 2011 By the way, for future readers of this thread, I wrote an article about chart customizers that includes a compiled chart customizer that does exactly this. So anyone that isn't familiar with building a chart customizer from source could grab that .jar file and get integer tick marks on their reports.It covers some other common chart tweaks too. The article is here:http://mdahlman.wordpress.com/2011/04/17/chart-customizers-2/Regards,Matt Link to comment Share on other sites More sharing options...
ragopalakrishnan Posted September 20, 2017 Share Posted September 20, 2017 Decreasing chart width or height is not a dynamic solution.I had the same issue with Stacked Bar Chart. Mine is Jasper Community Editionn 6.2.1.Able to fix the issue by using below property in <reportElement><property name="net.sf.jasperreports.chart.range.axis.tick.interval" value="1"/>my source code snippet<stackedBarChart> <chart evaluationTime="Report"> <reportElement x="3" y="4" width="547" height="310" uuid="437a72b9-4d07-40de-8497-358e8d904795"> <property name="com.jaspersoft.studio.unit.width" value="pixel"/> <property name="com.jaspersoft.studio.unit.height" value="pixel"/> <property name="net.sf.jasperreports.chart.range.axis.tick.interval" value="1"/> </reportElement> Hope this helps 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