Example usage for org.jfree.chart.axis ValueAxis getStandardTickUnits

List of usage examples for org.jfree.chart.axis ValueAxis getStandardTickUnits

Introduction

In this page you can find the example usage for org.jfree.chart.axis ValueAxis getStandardTickUnits.

Prototype

public TickUnitSource getStandardTickUnits() 

Source Link

Document

Returns the source for obtaining standard tick units for the axis.

Usage

From source file:lucee.runtime.tag.Chart.java

private void setLabelFormat(JFreeChart chart) {
    Plot plot = chart.getPlot();/*from   ww w. j a  v a  2s  .c  om*/
    if (plot instanceof CategoryPlot) {
        CategoryPlot cp = (CategoryPlot) plot;
        ValueAxis rangeAxis = cp.getRangeAxis();
        rangeAxis.setAutoTickUnitSelection(true);
        rangeAxis.setStandardTickUnits(new TickUnitsImpl(rangeAxis.getStandardTickUnits(), labelFormat));
        CategoryItemRenderer r = cp.getRenderer();
        r.setBaseItemLabelsVisible(false);

        CategoryAxis da = cp.getDomainAxis();
        if (!showXLabel)
            da.setTickLabelsVisible(false);
        da.setCategoryLabelPositions(labelPosition);
        da.setMaximumCategoryLabelWidthRatio(100);
        //da.setVisible(false);
    }
    if (plot instanceof XYPlot) {
        XYPlot cp = (XYPlot) plot;
        ValueAxis rangeAxis = cp.getRangeAxis();
        rangeAxis.setAutoTickUnitSelection(true);
        rangeAxis.setStandardTickUnits(new TickUnitsImpl(rangeAxis.getStandardTickUnits(), labelFormat));
        XYItemRenderer r = cp.getRenderer();
        r.setBaseItemLabelsVisible(false);
        ValueAxis da = cp.getDomainAxis();
        if (!_plotItemLables.isEmpty()) {
            _plotItemLables.add(0, "");
            String[] cols = _plotItemLables.toArray(new String[_plotItemLables.size()]);
            SymbolAxis sa = new SymbolAxis(da.getLabel(), cols);
            sa.setRange(da.getRange());
            if (labelPosition == LABEL_VERTICAL) {
                sa.setVerticalTickLabels(true);
            }
            cp.setDomainAxis(sa);
        }
        if (!showXLabel)
            cp.getDomainAxis().setTickLabelsVisible(false);
        //da.setVisible(false);
    }
}