Jump to content
Changes to the Jaspersoft community edition download ×

bar chart - value axis tick mask setting


dman

Recommended Posts

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 advance

regards,

DM

Link to comment
Share on other sites

  • Replies 6
  • Created
  • Last Reply

Top Posters In This Topic

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

  • 1 year later...

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

  • 4 weeks later...

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

  • 6 years later...

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

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