hklow Posted April 13, 2007 Share Posted April 13, 2007 can we set the scale of y-axis? or least not to show decimal units when the field/variable returns 0 or 1 or 2? the field/variable is defined as Integer, and it doesn't make sense if the Y axis shows 0.25, 0.5, 0.75... Link to comment Share on other sites More sharing options...
pkwooster Posted October 28, 2007 Share Posted October 28, 2007 Setting the scale or any other attributes of the axes is a JFreeChart activity. Here's some customizer code that adjusts the item margins and autoscale zero behaviour, it will provide some hints on where to startCode: public void customize(JFreeChart jFreeChart, JRChart jRChart) { super.customize(jFreeChart, jRChart); CategoryPlot plot = jFreeChart.getCategoryPlot(); BarRenderer renderer = (BarRenderer) plot.getRenderer(); ValueAxis axis = plot.getRangeAxis(); if (axis instanceof NumberAxis) { NumberAxis naxis = (NumberAxis)axis; Range rng = plot.getDataRange(naxis); double max = rng.getUpperBound(); double min = rng.getLowerBound(); boolean iz = ((max - min) > (max/5.0)); naxis.setAutoRangeIncludesZero(iz); naxis.setAutoRangeStickyZero(iz); } renderer.setItemMargin(0.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