Example usage for org.jfree.chart.axis SymbolAxis setRange

List of usage examples for org.jfree.chart.axis SymbolAxis setRange

Introduction

In this page you can find the example usage for org.jfree.chart.axis SymbolAxis setRange.

Prototype

public void setRange(Range range) 

Source Link

Document

Sets the range for the axis and sends a change event to all registered listeners.

Usage

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

private void setLabelFormat(JFreeChart chart) {
    Plot plot = chart.getPlot();//from  w  w  w. ja  v a2s.  c  o  m
    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);
    }
}