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

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

Introduction

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

Prototype

public ValueAxis getRangeAxis() 

Source Link

Document

Returns the range axis for the plot.

Usage

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

/**
 * Creates a sample chart./*from   w  w  w .  java 2  s.  c o  m*/
 * 
 * @param dataset  the dataset.
 * 
 * @return A sample chart.
 */
private JFreeChart createChart(final XYDataset dataset) {
    final JFreeChart result = ChartFactory.createTimeSeriesChart("Client Packets", "Time", "Value", dataset,
            true, true, false);
    final XYPlot plot = result.getXYPlot();
    ValueAxis axis = plot.getDomainAxis();
    axis.setAutoRange(true);
    axis.setFixedAutoRange(60000.0); // 60 seconds
    axis = plot.getRangeAxis();
    axis.setRange(0.0, 200.0);
    return result;
}

From source file:greenapi.ui.charts.LineChartPanelSupport.java

public void setRangeAxisRange(int lower, int upper) {
    XYPlot localXYPlot = (XYPlot) this.getChart().getPlot();
    NumberAxis localNumberAxis = (NumberAxis) localXYPlot.getRangeAxis();
    localNumberAxis.setRange(lower, upper);
}

From source file:LowPassFilterTest.java

@Test
public void test() throws InterruptedException {
    CategoryTableXYDataset serie = new CategoryTableXYDataset();
    serie.setNotify(false);/*from  www.  j  a va  2 s  .c o  m*/
    double step = 1.0 / discretization;
    double startPosition = step * framePosition;
    //100 ? - 100 , 50 ? - 50 , 25 ?- 25 
    double[] data = math.convolve(
            math.HammingWindow(testData.get1DPolyharmSignal(4, 200, frameWidth, discretization), frameWidth),
            math.lpf(60, step, 1024));
    //        double[] data = math.convolve(testData.get1DSignal(100, 200, frameWidth, discretization), math.lpf(70, step, 128));

    //        double[] data = math.convolve(testData.get1DSignal(100, 200, 32768, 10000), math.lpf(70, 1./10000, 32));
    //        double[] data = testData.get1DSignal(100, 200, frameWidth, discretization);
    //        double[] data = math.lpf(70, step,128);
    for (int i = 0; i < data.length; i++) {
        serie.add(startPosition, data[i], "");
        startPosition += step;
    }
    JFreeChart chart = ChartFactory.createXYLineChart("", "t,c", "g, /c^2", serie);
    chart.removeLegend();
    chart.setAntiAlias(false);

    XYPlot plot = chart.getXYPlot();
    //plot.setRangeGridlinePaint(Color.BLACK);
    org.jfree.chart.axis.ValueAxis yAxis = plot.getRangeAxis();
    org.jfree.chart.axis.ValueAxis xAxis = plot.getDomainAxis();
    double start = framePosition * 1.0 / discretization;
    double max = start + frameWidth * 1.0 / discretization;
    xAxis.setRange(start, max);
    ChartPanel chartPanel = new ChartPanel(chart);

    JPanel p = new JPanel(new BorderLayout());

    p.removeAll();
    p.add(chartPanel);
    p.validate();
    //1. Create the frame.
    JFrame frame = new JFrame("FrameDemo");

    //2. Optional: What happens when the frame closes?
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    //3. Create components and put them in the frame.
    //...create emptyLabel...
    frame.getContentPane().add(new Label("olol"), BorderLayout.CENTER);
    frame.getContentPane().add(p, BorderLayout.CENTER);

    //4. Size the frame.
    frame.pack();

    //5. Show it.
    frame.setVisible(true);
}

From source file:com.orange.atk.results.logger.documentGenerator.GraphGenerator.java

/**
 * This function creates the measurement graph by using the JFreeChart
 * library. The X axis of the graph is in minutes.
 * /*w w  w.j  a v  a 2s .c o  m*/
 * @param plotList
 *            plotlist to save. Xvalues must be stored in milliseconds.
 * @param associatedName
 *            Name of the list
 * @param folderWhereResultsAreSaved
 *            folder where results are saved
 * @param yLabel
 *            Name of the y label
 * @param pictureFile
 *            name of the file
 * @param yDivisor
 *            use to divide measurements stored in the plotlist by yDivisor
 */
public static void generateGraphWithJFreeChart(PlotList plotList, String associatedName,
        String folderWhereResultsAreSaved, String yLabel, String pictureFile, float yDivisor) {

    // Create a new XYSeries
    // XYSeries are used to represent couples of (x,y) values.
    XYSeries data = new XYSeries(associatedName);

    int size = plotList.getSize();
    if (size == 0) {
        // no element in graphics, exit
        //Logger.getLogger(this.getClass() ).warn("Nothing in graph");
        return;
    }

    // Find the initial value of the time
    // Due to the fact that getX(i) <= getX(i+1),
    // min({0<=i<size / getX(i)}) = getX(0)
    long initialValue = plotList.getX(0);

    XYSeriesCollection series = new XYSeriesCollection(data);
    if (!plotList.getunit().equals(""))
        yLabel += " (" + plotList.getunit() + ")";
    // Create a new XY graph.
    //JFreeChart chart = ChartFactory.createXYLineChart("", "Time", yLabel, series, PlotOrientation.VERTICAL, true, true, false);
    JFreeChart chart = ChartFactory.createTimeSeriesChart("", "Time (min:sec)", yLabel, series, true, true,
            false);
    // Set the graph format
    XYPlot plot = chart.getXYPlot();
    plot.setOrientation(PlotOrientation.VERTICAL);
    DateAxis axis = (DateAxis) plot.getDomainAxis();
    //axis.setTickUnit(new DateTickUnit(DateTickUnit.SECOND, 10));
    RelativeDateFormat rdf = new RelativeDateFormat(initialValue);
    rdf.setSecondFormatter(new DecimalFormat("00"));
    axis.setDateFormatOverride(rdf);

    // Fill the JFreeChart object which will be used to create the Graph
    for (int i = 0; i < size; i++) {
        // xvalue must be in
        double xval = ((Long) plotList.getX(i)).doubleValue();
        float yval = plotList.getY(i).floatValue() / yDivisor;
        // Logger.getLogger(this.getClass() ).debug(associatedName + " [" + (((Long)
        // plotList.getX(i)).floatValue() - initialValue)
        // / XDIVISOR +"] "+ yval);
        data.add(xval, yval);
    }

    ValueAxis rangeAxis = plot.getRangeAxis();
    Long min = plotList.getMin();
    Long max = plotList.getMax();
    double diff = (max - min) * 0.02;
    if (diff == 0)
        diff = max * 0.0001;

    rangeAxis.setLowerBound((min - diff) / yDivisor);
    rangeAxis.setUpperBound((max + diff) / yDivisor);
    //      Logger.getLogger(this.getClass() ).debug("(" + (min / yDivisor) * 0.98 + " - "
    //            + (min / yDivisor) * 0.98 + ")");
    //      Logger.getLogger(this.getClass() ).debug("Bound = " + rangeAxis.getLowerBound() + " - "
    //            + rangeAxis.getUpperBound());
    //      Logger.getLogger(this.getClass() ).debug("Margin = " + rangeAxis.getLowerMargin() + " - "
    //            + rangeAxis.getUpperMargin());
    //      Logger.getLogger(this.getClass() ).debug("NB AXIS = " + plot.getRangeAxisCount());

    // save the chart in a picture file.
    BufferedImage bufImage = chart.createBufferedImage(640, 480);
    File fichier = new File(pictureFile);
    try {
        if (!ImageIO.write(bufImage, "png", fichier)) {
            return;
        }
    } catch (IOException e) {
        e.printStackTrace();
    }

}

From source file:org.jfree.chart.demo.selection.SelectionDemo2.java

private static JFreeChart createChart(XYDataset dataset, DatasetSelectionExtension<XYCursor> ext) {
    JFreeChart chart = ChartFactory.createScatterPlot("SelectionDemo2", "X", "Y", dataset);

    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setNoDataMessage("NO DATA");

    plot.setDomainPannable(true);//w w w  .j a  v a 2  s . c  o m
    plot.setRangePannable(true);
    plot.setDomainZeroBaselineVisible(true);
    plot.setRangeZeroBaselineVisible(true);

    plot.setDomainGridlineStroke(new BasicStroke(0.0f));
    plot.setRangeGridlineStroke(new BasicStroke(0.0f));

    plot.setDomainMinorGridlinesVisible(true);
    plot.setRangeMinorGridlinesVisible(true);

    XYLineAndShapeRenderer r = (XYLineAndShapeRenderer) plot.getRenderer();
    r.setSeriesFillPaint(0, r.lookupSeriesPaint(0));
    r.setSeriesFillPaint(1, r.lookupSeriesPaint(1));
    r.setSeriesFillPaint(2, r.lookupSeriesPaint(2));
    r.setUseFillPaint(true);

    NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis();
    domainAxis.setAutoRangeIncludesZero(false);

    domainAxis.setTickMarkInsideLength(2.0f);
    domainAxis.setTickMarkOutsideLength(2.0f);
    domainAxis.setMinorTickMarksVisible(true);

    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setTickMarkInsideLength(2.0f);
    rangeAxis.setTickMarkOutsideLength(2.0f);
    rangeAxis.setMinorTickMarksVisible(true);

    //add selection specific rendering
    IRSUtilities.setSelectedItemFillPaint(r, ext, Color.white);

    //register plot as selection change listener
    ext.addChangeListener(plot);

    return chart;
}

From source file:com.romraider.logger.ecu.ui.tab.LoggerChartPanel.java

private void configurePlot(JFreeChart chart) {
    XYPlot plot = chart.getXYPlot();
    plot.setBackgroundPaint(BLACK);/*from www  . jav  a2  s.  co  m*/
    plot.getDomainAxis().setLabelPaint(WHITE);
    plot.getRangeAxis().setLabelPaint(WHITE);
    plot.getDomainAxis().setTickLabelPaint(LIGHT_GREY);
    plot.getRangeAxis().setTickLabelPaint(LIGHT_GREY);
    plot.setDomainGridlinePaint(DARK_GREY);
    plot.setRangeGridlinePaint(DARK_GREY);
    plot.setOutlinePaint(DARK_GREY);
    plot.setRenderer(buildScatterRenderer(2, RED));
}

From source file:com.itemanalysis.jmetrik.graph.irt.IrtPlotPanel.java

public void updateOrdinate(String name, double min, double max) {
    JFreeChart chart = charts.get(name);
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.getRangeAxis().setRange(min, max);
}

From source file:com.itemanalysis.jmetrik.graph.irt.IrtPlotPanel.java

public void setOrdinateAutoRange(String name, boolean autoRange) {
    JFreeChart chart = charts.get(name);
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.getRangeAxis().setAutoRange(autoRange);
}

From source file:com.itemanalysis.jmetrik.graph.irt.IrtPlotPanel.java

public void setOrdinateLabel(String name, String label) {
    JFreeChart chart = charts.get(name);
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.getRangeAxis().setLabel(label);
}

From source file:mls.FramePlot.java

private JFreeChart createChartVarianza(final XYDataset datasetVarianza) {
    final JFreeChart result = ChartFactory.createXYLineChart("Varianza campionaria", "n", "vc", datasetVarianza,
            PlotOrientation.VERTICAL, false, true, false);
    final XYPlot plot = result.getXYPlot();
    ValueAxis axis = plot.getDomainAxis();
    axis.setAutoRange(true);//from   w ww.jav a 2s. c o m
    axis.setFixedAutoRange(1500);

    axis = plot.getRangeAxis();
    axis.setAutoRange(true);
    axis.setRange(10, 100);
    plot.getRenderer().setSeriesPaint(0, Color.MAGENTA);
    return result;
}