Example usage for org.jfree.chart.plot XYPlot setRangeAxis

List of usage examples for org.jfree.chart.plot XYPlot setRangeAxis

Introduction

In this page you can find the example usage for org.jfree.chart.plot XYPlot setRangeAxis.

Prototype

public void setRangeAxis(ValueAxis axis) 

Source Link

Document

Sets the range axis for the plot and sends a PlotChangeEvent to all registered listeners.

Usage

From source file:org.jfree.chart.ChartFactory.java

/**
 * Creates a stacked XY area plot.  The chart object returned by this
 * method uses an {@link XYPlot} instance as the plot, with a
 * {@link NumberAxis} for the domain axis, a {@link NumberAxis} as the
 * range axis, and a {@link StackedXYAreaRenderer2} as the renderer.
 *
 * @param title  the chart title ({@code null} permitted).
 * @param xAxisLabel  a label for the X-axis ({@code null} permitted).
 * @param yAxisLabel  a label for the Y-axis ({@code null} permitted).
 * @param dataset  the dataset for the chart ({@code null} permitted).
 *
 * @return A stacked XY area chart./*from   w  ww.j av  a2  s.  c om*/
 */
public static JFreeChart createStackedXYAreaChart(String title, String xAxisLabel, String yAxisLabel,
        TableXYDataset dataset) {

    NumberAxis xAxis = new NumberAxis(xAxisLabel);
    xAxis.setAutoRangeIncludesZero(false);
    xAxis.setLowerMargin(0.0);
    xAxis.setUpperMargin(0.0);
    NumberAxis yAxis = new NumberAxis(yAxisLabel);
    XYToolTipGenerator toolTipGenerator = new StandardXYToolTipGenerator();
    StackedXYAreaRenderer2 renderer = new StackedXYAreaRenderer2(toolTipGenerator, null);
    renderer.setOutline(true);
    XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer);

    plot.setRangeAxis(yAxis); // forces recalculation of the axis range

    JFreeChart chart = new JFreeChart(title, plot);
    currentTheme.apply(chart);
    return chart;

}