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

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

Introduction

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

Prototype

public void setAutoRangeMinimumSize(double size) 

Source Link

Document

Sets the auto range minimum size and sends an AxisChangeEvent to all registered listeners.

Usage

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());
    }/*from  w  w w .ja  va 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:org.jfree.chart.demo.TimeSeriesDemo6.java

/**
 * Creates a chart.// w w  w.  j  av  a  2s .c  o m
 * 
 * @param dataset  the dataset.
 * 
 * @return a chart.
 */
private JFreeChart createChart(final XYDataset dataset) {

    final JFreeChart chart = ChartFactory.createTimeSeriesChart("Time Series Demo 6", "Date", "Value", dataset,
            true, true, false);

    final XYPlot plot = chart.getXYPlot();
    final DateAxis axis = (DateAxis) plot.getDomainAxis();
    axis.setDateFormatOverride(new SimpleDateFormat("MMM-yyyy"));
    final ValueAxis rangeAxis = plot.getRangeAxis();
    rangeAxis.setAutoRangeMinimumSize(1.0);
    return chart;

}

From source file:br.com.criativasoft.opendevice.samples.ui.SimpleChart.java

private JFreeChart createChart(final XYDataset dataset) {
    final JFreeChart result = ChartFactory.createTimeSeriesChart(TITLE, "mm:ss", "Value", dataset, true, true,
            false);// w  w  w  . jav  a2  s .co m
    final XYPlot plot = result.getXYPlot();
    plot.setBackgroundPaint(Color.white);
    ValueAxis domain = plot.getDomainAxis();
    domain.setAutoRange(true);
    ValueAxis range = plot.getRangeAxis();
    range.setRange(0, MINMAX);
    range.setAutoRangeMinimumSize(20);

    XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer();

    for (int i = 0; i < SERIES; i++) {
        renderer.setSeriesStroke(i, new BasicStroke(2.0f));
    }

    return result;
}

From source file:org.squale.squaleweb.util.graph.HistoMaker.java

/**
 * This method create the JFreechart chart
 * //from  w ww .j a v  a 2s. c  o m
 * @param maxAxisToday Does the max for the date axis should be set to today ?
 * @return A JFreeChart chart
 */
public JFreeChart getChart(boolean maxAxisToday) {
    JFreeChart retChart = super.getChart();
    if (null == retChart) {
        retChart = ChartFactory.createTimeSeriesChart(mTitle, mXLabel, mYLabel, mDataSet, mShowLegend, false,
                false);
        XYPlot plot = retChart.getXYPlot();
        XYLineAndShapeRenderer xylineandshaperenderer = new XYLineAndShapeRenderer();
        xylineandshaperenderer.setBaseShapesVisible(true);
        plot.setRenderer(xylineandshaperenderer);
        SimpleDateFormat sdf = new SimpleDateFormat(mDateFormat);
        DateAxis axis = (DateAxis) plot.getDomainAxis();
        if (maxAxisToday) {
            axis.setMaximumDate(new Date());
        }
        axis.setDateFormatOverride(sdf);
        ValueAxis yAxis = plot.getRangeAxis();
        yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
        yAxis.setAutoRangeMinimumSize(2.0);
        super.setChart(retChart);
    }
    return retChart;
}

From source file:de.citec.csra.allocation.vis.MovingChart.java

/**
 * Creates a sample chart./*from  w  w  w  .  j a va  2s .  co  m*/
 *
 * @param dataset the dataset.
 *
 * @return A sample chart.
 */
private JFreeChart createChart(final XYDataset dataset) {
    final JFreeChart result = ChartFactory.createTimeSeriesChart(null, "Time", "Resource", dataset, false, true,
            false);

    final XYPlot plot = result.getXYPlot();

    plot.addDomainMarker(this.marker);
    plot.setBackgroundPaint(new Color(0xf8f8ed));
    plot.setDomainGridlinesVisible(true);
    plot.setDomainGridlinePaint(Color.lightGray);
    plot.setRangeGridlinesVisible(true);
    plot.setRangeGridlinePaint(Color.lightGray);

    ValueAxis xaxis = plot.getDomainAxis();
    xaxis.setAutoRange(true);
    xaxis.setTickLabelsVisible(false);
    //Domain axis would show data of 60 seconds for a time
    xaxis.setFixedAutoRange(this.past + this.future); // 60 seconds
    xaxis.setVerticalTickLabels(true);
    ValueAxis yaxis = plot.getRangeAxis();
    yaxis.setAutoRangeMinimumSize(1.8);
    yaxis.setAutoRange(true);

    NumberAxis range = (NumberAxis) plot.getRangeAxis();
    range.setTickUnit(new NumberTickUnit(1));
    range.setNumberFormatOverride(new NumberFormat() {
        @Override
        public StringBuffer format(double number, StringBuffer toAppendTo, FieldPosition pos) {
            return format((long) number, toAppendTo, pos);
        }

        private String getID(long number) {
            return values.entrySet().stream().filter(e -> e.equals(number)).findFirst().get().getKey();
        }

        @Override
        public StringBuffer format(long number, StringBuffer ap, FieldPosition pos) {
            String id = "N/A";
            if (number == 0) {
                id = "(Time)";
            }
            if (values.containsValue(number)) {
                for (Map.Entry<String, Long> entry : values.entrySet()) {
                    if (entry.getValue() == number) {
                        id = entry.getKey();
                        break;
                    }
                }
            }
            id = id.replaceFirst("/$", "");
            ap.append(id);
            if (id.length() > 32) {
                ap.replace(15, ap.length() - 15, "..");
            }
            return ap;
        }

        @Override
        public Number parse(String source, ParsePosition parsePosition) {
            return null;
        }
    });

    //      this.chart.getXYPlot().getRenderer(1).set
    //      XYLineAndShapeRenderer r = (XYLineAndShapeRenderer) this.chart.getXYPlot().getRendererForDataset(dataset);
    return result;
}

From source file:com.xilinx.ultrascale.gui.BarCharts.java

License:asdf

public void setaRange() {
    CategoryPlot plot = chart.getCategoryPlot();
    ValueAxis axis = plot.getRangeAxis();

    //        axis.setUpperBound(1000.0);
    //        axis.setLowerBound(0.0);
    //        axis.setAutoRangeMinimumSize(1.0);
    axis.setAutoRange(true);/*  ww w  .  j  av a 2  s .  co  m*/
    //        axis.setLowerMargin(0);
    axis.setLowerMargin(0);
    axis.setUpperMargin(0.40);
    axis.setAutoRangeMinimumSize(1.0);
    axis.setDefaultAutoRange(new Range(0, 1000));
}

From source file:org.zaproxy.zap.extension.ascan.ScanProgressDialog.java

private JFreeChart createChart(final XYDataset dataset) {
    JFreeChart result = ChartFactory.createTimeSeriesChart(null, // No title - it just takes up space 
            Constant.messages.getString("ascan.progress.chart.time"),
            Constant.messages.getString("ascan.progress.chart.responses"), dataset, true, true, false);
    XYPlot plot = result.getXYPlot();/* w ww  . j av  a2s .c o m*/
    ValueAxis daxis = plot.getDomainAxis();
    daxis.setAutoRange(true);
    daxis.setAutoRangeMinimumSize(60000.0);

    plot.getRangeAxis().setAutoRangeMinimumSize(20);

    return result;
}

From source file:org.zaproxy.zap.extension.customFire.ScanProgressDialog.java

/**
 * /*from   w ww. j av  a2 s  . c o m*/
 * @param dataset
 * @return JFreeChart `
 */
private JFreeChart createChart(final XYDataset dataset) {

    JFreeChart result = ChartFactory.createTimeSeriesChart(null, "Time", "Response/seconds", dataset, true,
            false, false);
    XYPlot plot = result.getXYPlot();
    ValueAxis daxis = plot.getDomainAxis();
    daxis.setAutoRange(true);
    daxis.setAutoRangeMinimumSize(60000.0);

    plot.getRangeAxis().setAutoRangeMinimumSize(20);

    return result;
}