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

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

Introduction

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

Prototype

public void setAutoRangeIncludesZero(boolean flag) 

Source Link

Document

Sets the flag that indicates whether or not the axis range, if automatically calculated, is forced to include zero.

Usage

From source file:org.operamasks.faces.render.graph.CurveAreaChartRenderer.java

private JFreeChart createXYCurveAreaChart(XYDataset dataset, PlotOrientation orientation) {
    ValueAxis xAxis;/* www. j a  v a2 s  .  c  om*/
    if (dataset instanceof TimeSeriesCollection) {
        xAxis = new DateAxis();
    } else {
        xAxis = new NumberAxis();
        ((NumberAxis) xAxis).setAutoRangeIncludesZero(false);
    }
    xAxis.setLowerMargin(0.0);
    xAxis.setUpperMargin(0.0);

    NumberAxis yAxis = new NumberAxis();
    yAxis.setAutoRangeIncludesZero(false);

    XYCurveAndShapeRenderer renderer = new XYCurveAndShapeRenderer(true, false);
    renderer.setDrawArea(true);

    XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer);
    plot.setOrientation(orientation);
    if (dataset.getSeriesCount() > 1) {
        plot.setForegroundAlpha(0.75f);
    }

    return new JFreeChart(null, null, plot, false);
}

From source file:aka.pirana.jdoc.JChart.java

private JPanel createChartPanel() {
    NumberAxis numberaxis = new NumberAxis("Date");
    numberaxis.setAutoRangeIncludesZero(false);
    NumberAxis numberaxis1 = new NumberAxis("%");
    numberaxis1.setAutoRangeIncludesZero(false);
    XYSplineRenderer xysplinerenderer = new XYSplineRenderer();
    XYPlot xyplot = new XYPlot(SampleGenerator(), numberaxis, numberaxis1, xysplinerenderer);
    xyplot.setBackgroundPaint(Color.lightGray);
    xyplot.setDomainGridlinePaint(Color.white);
    xyplot.setRangeGridlinePaint(Color.white);
    xyplot.setAxisOffset(new RectangleInsets(4D, 4D, 4D, 4D));
    JFreeChart jfreechart = new JFreeChart("JDocSplineRenderer", JFreeChart.DEFAULT_TITLE_FONT, xyplot, true);
    ChartUtilities.applyCurrentTheme(jfreechart);
    ChartPanel chartpanel = new ChartPanel(jfreechart);
    return chartpanel;
}

From source file:playground.anhorni.PLOC.analysis.RunsEnsembleBoxPlot.java

public JFreeChart createChart() {
    String title = chartTitle;//from  w w w .ja v a 2 s  . c om

    final CategoryAxis xAxis = new CategoryAxis("Hour");
    xAxis.setTickLabelFont(new Font("SansSerif", Font.PLAIN, 10));
    xAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45);

    final NumberAxis yAxis = new NumberAxis("AverageDays_Expenditures");
    yAxis.setAutoRangeIncludesZero(true);

    final BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer();
    renderer.setFillBox(false);
    renderer.setSeriesPaint(0, Color.blue);
    CategoryPlot plot = new CategoryPlot(dataset, xAxis, yAxis, renderer);

    this.chart_ = new JFreeChart(title, new Font("SansSerif", Font.BOLD, 14), plot, false);
    return this.chart_;
}

From source file:org.jfree.chart.demo.FastScatterPlotDemo.java

/**
 * Creates a new fast scatter plot demo.
 *
 * @param title  the frame title.//from ww w .ja  va2  s . c  o  m
 */
public FastScatterPlotDemo(final String title) {

    super(title);
    populateData();
    final NumberAxis domainAxis = new NumberAxis("X");
    domainAxis.setAutoRangeIncludesZero(false);
    final NumberAxis rangeAxis = new NumberAxis("Y");
    rangeAxis.setAutoRangeIncludesZero(false);
    final FastScatterPlot plot = new FastScatterPlot(this.data, domainAxis, rangeAxis);
    final JFreeChart chart = new JFreeChart("Fast Scatter Plot", plot);
    //        chart.setLegend(null);

    // force aliasing of the rendered content..
    chart.getRenderingHints().put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

    final ChartPanel panel = new ChartPanel(chart, true);
    panel.setPreferredSize(new java.awt.Dimension(500, 270));
    //      panel.setHorizontalZoom(true);
    //    panel.setVerticalZoom(true);
    panel.setMinimumDrawHeight(10);
    panel.setMaximumDrawHeight(2000);
    panel.setMinimumDrawWidth(20);
    panel.setMaximumDrawWidth(2000);

    setContentPane(panel);

}

From source file:test.FastScatterDemo.java

/**
 * Creates a new fast scatter plot demo.
 *
 * @param title  the frame title.// w  w w . ja v  a2 s.c  om
 */
public FastScatterDemo(final String title) {

    super(title);
    populateData();
    final NumberAxis domainAxis = new NumberAxis("X");
    domainAxis.setAutoRangeIncludesZero(false);
    final NumberAxis rangeAxis = new NumberAxis("Y");
    rangeAxis.setAutoRangeIncludesZero(false);
    final FastScatterPlot plot = new FastScatterPlot(this.data, domainAxis, rangeAxis);
    final JFreeChart chart = new JFreeChart("Fast Scatter Plot", plot);
    //        chart.setLegend(null);

    // force aliasing of the rendered content..
    chart.getRenderingHints().put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

    final ChartPanel panel = new ChartPanel(chart, true);
    panel.setPreferredSize(new java.awt.Dimension(500, 270));
    //      panel.setHorizontalZoom(true);
    //    panel.setVerticalZoom(true);
    panel.setMinimumDrawHeight(10);
    panel.setMaximumDrawHeight(2000);
    panel.setMinimumDrawWidth(20);
    panel.setMaximumDrawWidth(2000);

    setContentPane(panel);

}

From source file:playground.anhorni.surprice.analysis.SupriceBoxPlot.java

public JFreeChart createChart() {
    String title = chartTitle;// w  w  w .  j  av a 2s  .  c  o m

    final CategoryAxis xAxis = new CategoryAxis(this.xAxisName);
    xAxis.setTickLabelFont(new Font("SansSerif", Font.PLAIN, 10));
    xAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45);

    final NumberAxis yAxis = new NumberAxis(this.yAxisName);
    yAxis.setAutoRangeIncludesZero(true);

    if (Math.abs(yrangeLower - yrangeUpper) > Double.MIN_VALUE) {
        yAxis.setRange(yrangeLower, yrangeUpper);
    }

    final BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer();
    renderer.setFillBox(false);
    renderer.setSeriesPaint(0, Color.blue);
    CategoryPlot plot = new CategoryPlot(dataset, xAxis, yAxis, renderer);

    this.chart_ = new JFreeChart(title, new Font("SansSerif", Font.BOLD, 14), plot, false);
    return this.chart_;
}

From source file:playground.yu.utils.charts.XYScatterLineChart.java

private JFreeChart createChart(final String title, final String categoryAxisLabel, final String valueAxisLabel,
        final XYSeriesCollection dataset) {
    // return ChartFactory.createScatterPlot(title, categoryAxisLabel,
    // valueAxisLabel, dataset, PlotOrientation.VERTICAL, true, // legend?
    // false, // tooltips?
    // false // URLs?
    // );//from  w w w.jav  a  2  s .  co m
    NumberAxis xAxis = new NumberAxis(categoryAxisLabel);
    xAxis.setAutoRangeIncludesZero(false);
    xAxis.setRange(0, 24);
    NumberAxis yAxis = new NumberAxis(valueAxisLabel);
    yAxis.setAutoRangeIncludesZero(true);
    yAxis.setRange(0, 100);

    XYPlot plot = new XYPlot(dataset, xAxis, yAxis, null);

    XYItemRenderer renderer = new XYLineAndShapeRenderer(true, true);
    renderer.setBaseToolTipGenerator(null/* XYToolTipGenerator */);
    renderer.setURLGenerator(null/* urlGenerator */);
    plot.setRenderer(renderer);
    plot.setOrientation(PlotOrientation.VERTICAL);

    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, true/* legend */);
    return chart;
}

From source file:graph.MySensorPanel.java

/**
 * Creates a new self-contained demo panel.
 *//*from w  w w  .  ja va  2 s  . c  o m*/
public MySensorPanel(String header_str) {
    //super(new BorderLayout());
    this.series1 = new TimeSeries("Temperature");
    this.series2 = new TimeSeries("Humidity");
    TimeSeriesCollection dataset1 = new TimeSeriesCollection(this.series1);
    TimeSeriesCollection dataset2 = new TimeSeriesCollection(this.series2);

    JFreeChart chart = ChartFactory.createTimeSeriesChart(header_str, "Time", "C", dataset1, true, true,
            false);

    /*this.addChart(chart);*/

    XYPlot plot = (XYPlot) chart.getPlot();
    ValueAxis axis = plot.getDomainAxis();
    axis.setAutoRange(true);
    axis.setFixedAutoRange(1000.0 * 60 * 60 /* 24*/); // 24 hrs

    plot.setDataset(1, dataset2);
    NumberAxis rangeAxis2 = new NumberAxis("%");
    rangeAxis2.setAutoRangeIncludesZero(false);
    plot.setRenderer(1, new DefaultXYItemRenderer());
    plot.setRangeAxis(1, rangeAxis2);
    plot.mapDatasetToRangeAxis(1, 1);

    ChartUtilities.applyCurrentTheme(chart);
    plot.setBackgroundPaint(Color.DARK_GRAY);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);

    chartPanel = new ChartPanel(chart);
}

From source file:ste.travian.world.WorldChart.java

/**
 * Create the JFreeChart world chart//from  w  w w .  j a va  2 s. c o  m
 * 
 * @param title world title
 * @param dataset world data set
 * 
 */
private void createWorldPlot(String title, XYDataset dataset) {

    NumberAxis xAxis = new NumberAxis(LABEL_X_AXIS);
    xAxis.setAutoRangeIncludesZero(false);
    NumberAxis yAxis = new NumberAxis(LABEL_Y_AXIS);
    yAxis.setAutoRangeIncludesZero(false);

    XYPlot plot = new XYPlot(dataset, xAxis, yAxis, null);

    TileRenderer renderer = new TileRenderer(3, 3);
    renderer.setBaseToolTipGenerator(new TileToolTipGenerator());

    plot.setRenderer(renderer);
    plot.setOrientation(PlotOrientation.VERTICAL);

    chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, true);
}

From source file:smellminer.engine.JFreeChartDemo.java

/**
 * Creates a new demo./* www.  ja  v  a  2  s .com*/
 *
 * @param title  the frame title.
 */
public JFreeChartDemo(final String title) {

    super(title);

    final BoxAndWhiskerCategoryDataset dataset = createSampleDataset();

    final CategoryAxis xAxis = new CategoryAxis("Type");
    final NumberAxis yAxis = new NumberAxis("Value");
    yAxis.setAutoRangeIncludesZero(false);
    final BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer();
    renderer.setFillBox(false);
    renderer.setToolTipGenerator(new BoxAndWhiskerToolTipGenerator());
    final CategoryPlot plot = new CategoryPlot(dataset, xAxis, yAxis, renderer);

    final JFreeChart chart = new JFreeChart("Box-and-Whisker Demo", new Font("SansSerif", Font.BOLD, 14), plot,
            true);
    final ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new java.awt.Dimension(450, 270));
    setContentPane(chartPanel);

}