Example usage for org.jfree.chart.axis NumberAxis isAutoTickUnitSelection

List of usage examples for org.jfree.chart.axis NumberAxis isAutoTickUnitSelection

Introduction

In this page you can find the example usage for org.jfree.chart.axis NumberAxis isAutoTickUnitSelection.

Prototype

public boolean isAutoTickUnitSelection() 

Source Link

Document

Returns a flag indicating whether or not the tick unit is automatically selected from a range of standard tick units.

Usage

From source file:net.sf.jasperreports.charts.util.ChartUtil.java

public void setAutoTickUnit(NumberAxis numberAxis) {
    if (numberAxis.isAutoTickUnitSelection()) {
        Range range = numberAxis.getRange();
        if (range.getLength() >= AUTO_TICK_UNIT_THRESHOLD) {
            // this is a workaround for a floating point error makes JFreeChart
            // select tick units that are too small when the values are very large
            double autoSize = range.getLength() / AUTO_TICK_UNIT_THRESHOLD;
            TickUnit unit = numberAxis.getStandardTickUnits().getCeilingTickUnit(autoSize);
            numberAxis.setTickUnit((NumberTickUnit) unit, false, false);
        }//from  w w w  . j av  a  2  s  . c om
    }
}

From source file:com.xpn.xwiki.plugin.charts.ChartCustomizer.java

public static void customizeNumberAxis(NumberAxis axis, ChartParams params, String prefix) {
    customizeValueAxis(axis, params, prefix);
    if (axis.isAutoRange()) { // work only with auto range
        if (params.get(prefix + ChartParams.NUMBER_AXIS_AUTO_RANGE_INCLUDES_ZERO_SUFFIX) != null) {
            axis.setAutoRangeIncludesZero(
                    params.getBoolean(prefix + ChartParams.NUMBER_AXIS_AUTO_RANGE_INCLUDES_ZERO_SUFFIX)
                            .booleanValue());
        }//w w  w  .  j av  a 2 s.  c o  m
        if (params.get(prefix + ChartParams.NUMBER_AXIS_AUTO_RANGE_STICKY_ZERO_SUFFIX) != null) {
            axis.setAutoRangeStickyZero(params
                    .getBoolean(prefix + ChartParams.NUMBER_AXIS_AUTO_RANGE_STICKY_ZERO_SUFFIX).booleanValue());
        }
    }
    if (params.get(prefix + ChartParams.NUMBER_AXIS_RANGE_TYPE_SUFFIX) != null) {
        axis.setRangeType(params.getRangeType(prefix + ChartParams.NUMBER_AXIS_RANGE_TYPE_SUFFIX));
    }
    if (params.get(prefix + ChartParams.NUMBER_AXIS_NUMBER_TICK_UNIT_SUFFIX) != null) {
        if (axis.isAutoTickUnitSelection()) {
            axis.setAutoTickUnitSelection(false);
        }
        axis.setTickUnit(params.getNumberTickUnit(prefix + ChartParams.NUMBER_AXIS_NUMBER_TICK_UNIT_SUFFIX));
    }
    if (params.get(prefix + ChartParams.NUMBER_AXIS_NUMBER_FORMAT_OVERRIDE_SUFFIX) != null) {
        axis.setNumberFormatOverride(
                params.getNumberFormat(prefix + ChartParams.NUMBER_AXIS_NUMBER_FORMAT_OVERRIDE_SUFFIX));
    }
}