List of usage examples for org.jfree.chart.axis ValueAxis setAutoTickUnitSelection
public void setAutoTickUnitSelection(boolean flag)
From source file:MWC.GUI.JFreeChart.NewFormattedJFreeChart.java
public void setDateTickUnits(final DateAxisEditor.MWCDateTickUnitWrapper theDateTick) { final ValueAxis hd = this.getXYPlot().getDomainAxis(); // store the current tick _theDateTick = theDateTick;/*from w w w. ja v a 2s .c o m*/ if (theDateTick.isAutoScale()) { hd.setAutoTickUnitSelection(true); } else { // cancel auto calc hd.setAutoTickUnitSelection(false); // get the date axis final ValueAxis va = this.getXYPlot().getDomainAxis(); final DateAxis da = (DateAxis) va; // and set the tick da.setTickUnit(_theDateTick.getUnit()); } }
From source file:com.xpn.xwiki.plugin.charts.ChartCustomizer.java
public static void customizeValueAxis(ValueAxis axis, ChartParams params, String prefix) { customizeAxis(axis, params, prefix); if (params.get(prefix + ChartParams.VALUE_AXIS_AUTO_RANGE_SUFFIX) != null) { axis.setAutoRange(params.getBoolean(prefix + ChartParams.VALUE_AXIS_AUTO_RANGE_SUFFIX).booleanValue()); }/* w w w. ja v a 2 s . c om*/ if (axis.isAutoRange()) { // work only with auto range if (params.get(prefix + ChartParams.VALUE_AXIS_AUTO_RANGE_MIN_SIZE_SUFFIX) != null) { axis.setAutoRangeMinimumSize( params.getDouble(prefix + ChartParams.VALUE_AXIS_AUTO_RANGE_MIN_SIZE_SUFFIX).doubleValue()); } if (params.get(prefix + ChartParams.AXIS_LOWER_MARGIN_SUFFIX) != null) { axis.setLowerMargin(params.getDouble(prefix + ChartParams.AXIS_LOWER_MARGIN_SUFFIX).doubleValue()); } if (params.get(prefix + ChartParams.AXIS_UPPER_MARGIN_SUFFIX) != null) { axis.setUpperMargin(params.getDouble(prefix + ChartParams.AXIS_UPPER_MARGIN_SUFFIX).doubleValue()); } } else { // work only when auto range is off if (params.get(prefix + ChartParams.VALUE_AXIS_LOWER_BOUND_SUFFIX) != null) { axis.setLowerBound( params.getDouble(prefix + ChartParams.VALUE_AXIS_LOWER_BOUND_SUFFIX).doubleValue()); } if (params.get(prefix + ChartParams.VALUE_AXIS_UPPER_BOUND_SUFFIX) != null) { axis.setUpperBound( params.getDouble(prefix + ChartParams.VALUE_AXIS_UPPER_BOUND_SUFFIX).doubleValue()); } } if (params.get(prefix + ChartParams.VALUE_AXIS_AUTO_TICK_UNIT_SUFFIX) != null) { axis.setAutoTickUnitSelection( params.getBoolean(prefix + ChartParams.VALUE_AXIS_AUTO_TICK_UNIT_SUFFIX).booleanValue()); } if (params.get(prefix + ChartParams.VALUE_AXIS_VERTICAL_TICK_LABELS_SUFFIX) != null) { axis.setVerticalTickLabels( params.getBoolean(prefix + ChartParams.VALUE_AXIS_VERTICAL_TICK_LABELS_SUFFIX).booleanValue()); } }
From source file:lucee.runtime.tag.Chart.java
private void setLabelFormat(JFreeChart chart) { Plot plot = chart.getPlot();//from ww w . j av a 2 s.co 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); } }