Example usage for org.jfree.data.xy DefaultXYDataset addSeries

List of usage examples for org.jfree.data.xy DefaultXYDataset addSeries

Introduction

In this page you can find the example usage for org.jfree.data.xy DefaultXYDataset addSeries.

Prototype

public void addSeries(Comparable seriesKey, double[][] data) 

Source Link

Document

Adds a series or if a series with the same key already exists replaces the data for that series, then sends a DatasetChangeEvent to all registered listeners.

Usage

From source file:LoggerGUI.MainFrame.java

private static XYDataset createDataset() {

    DefaultXYDataset ds = new DefaultXYDataset();

    double[][] data = { { 0.1, 0.2, 0.3 }, { 1, 2, 3 } };

    ds.addSeries("series1", data);

    return ds;//from   ww w .  j  a  v a 2s.c o  m
}

From source file:helpers.Plots.java

public static void plotSimpleLineXY(ArrayList<double[][]> data, ArrayList<String> seriesName, String title,
        String xname, String yname) {
    DefaultXYDataset ds = new DefaultXYDataset();

    for (int i = 0; i < data.size(); i++) {
        System.out.println(data.get(i)[0][0]);
        ds.addSeries(seriesName.get(i), data.get(i));
    }/*from w  w  w.  j a  v  a 2 s  .c o  m*/

    JFreeChart chart = ChartFactory.createXYLineChart(title, xname, yname, ds, PlotOrientation.VERTICAL, true,
            true, false);
    ChartFrame frame = new ChartFrame(title, chart);
    frame.pack();
    frame.setVisible(true);
}

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

private static XYDataset createDataset() {
    DefaultXYDataset defaultxydataset = new DefaultXYDataset();
    double ad[] = { 1.0D, 2D, 3D, 4D, 5D, 6D, 7D, 8D };
    double ad1[] = { 8D, 7D, 6D, 5D, 4D, 3D, 2D, 1.0D };
    double ad2[][] = { ad, ad1 };
    defaultxydataset.addSeries("Series 1", ad2);
    double ad3[] = { 1.0D, 2D, 3D, 4D, 5D, 6D, 7D, 8D };
    double ad4[] = { 1.0D, 2D, 3D, 4D, 5D, 6D, 7D, 8D };
    double ad5[][] = { ad3, ad4 };
    defaultxydataset.addSeries("Series 2", ad5);
    return defaultxydataset;
}

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

public static XYDataset createDataset() {
    DefaultXYDataset defaultxydataset = new DefaultXYDataset();
    double ad[] = { 1.7D, 2.2000000000000002D, 2.7000000000000002D, 3D, 3.2000000000000002D };
    double ad1[] = { 4D, 3D, 6D, 1.0D, 9D };
    double ad2[][] = { ad, ad1 };
    defaultxydataset.addSeries("Series 1", ad2);
    double ad3[] = { 2.1000000000000001D, 2.2000000000000002D, 2.3999999999999999D, 2.7000000000000002D,
            3.2000000000000002D };//  w w w  .java 2s  .c  om
    double ad4[] = { 4.5D, 6D, 4D, 8D, 5.0999999999999996D };
    double ad5[][] = { ad3, ad4 };
    defaultxydataset.addSeries("Series 2", ad5);
    return defaultxydataset;
}

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

private static XYDataset createDataset() {
    DefaultXYDataset defaultxydataset = new DefaultXYDataset();
    double ad[] = new double[1000];
    double ad1[] = new double[1000];
    for (int i = 0; i < 1000; i++) {
        ad[i] = Math.random() + 1.0D;
        ad1[i] = Math.random() + 1.0D;
    }//from   w w w  .j av a2  s . co m

    double ad2[][] = { ad, ad1 };
    defaultxydataset.addSeries("Series 1", ad2);
    return defaultxydataset;
}

From source file:net.bioclipse.chart.ChartUtils.java

/**
 * Displays data in a scatter plot//from  w ww .j a  va  2 s  .co m
 * 
 * @param xValues x values of points
 * @param yValues y values of points
 * @param xLabel X axis label
 * @param yLabel Y axis label
 * @param title plot title
 */
public static void scatterPlot(double[] xValues, double[] yValues, String xLabel, String yLabel, String title) {
    setupData(xValues, yValues, xLabel, yLabel, title);
    DefaultXYDataset dataset = new DefaultXYDataset();
    dataset.addSeries(1, values);
    chart = ChartFactory.createScatterPlot(title, xLabel, yLabel, dataset, PlotOrientation.VERTICAL, false,
            false, false);
    view.display(chart);
    ChartUtils.currentPlotType = ChartConstants.SCATTER_PLOT;
}

From source file:net.bioclipse.chart.ChartUtils.java

/**
 * Plot time series//from  w  w  w .ja va 2 s .  c  o m
 * 
 * @param dataValues
 * @param timeValues
 * @param xLabel X axis label
 * @param yLabel Y axis label
 * @param title Chart title
 * @param dataSource 
 * @param indices 
 */
public static void timeSeries(double[] dataValues, double[] timeValues, String xLabel, String yLabel,
        String title, int[] indices, IEditorPart dataSource) {
    setupData(dataValues, timeValues, xLabel, yLabel, title);
    DefaultXYDataset dataset = new DefaultXYDataset();
    dataset.addSeries(1, values);
    chart = ChartFactory.createTimeSeriesChart(title, xLabel, yLabel, (XYDataset) dataset, false, false, false);

    ChartDescriptor descriptor = new ChartDescriptor(dataSource, indices, ChartConstants.TIME_SERIES, xLabel,
            yLabel);
    chartManager.put(chart, descriptor);

    view.display(chart);
    ChartUtils.currentPlotType = ChartConstants.TIME_SERIES;
}

From source file:net.bioclipse.chart.ChartUtils.java

/**
 * Displays data in a scatter plot//  w  w  w .jav  a  2  s  . com
 * 
 * @param xValues x values of points
 * @param yValues y values of points
 * @param xLabel X axis label
 * @param yLabel Y axis label
 * @param title plot title
 * @param indices 
 * @param dataSource The editor from which the charts data comes from, used so indices are mapped to the right editor 
 */
public static void scatterPlot(double[] xValues, double[] yValues, String xLabel, String yLabel, String title,
        int[] indices, IEditorPart dataSource) {
    setupData(xValues, yValues, xLabel, yLabel, title);
    DefaultXYDataset dataset = new DefaultXYDataset();
    dataset.addSeries(1, values);

    chart = ChartFactory.createScatterPlot(title, xLabel, yLabel, dataset, PlotOrientation.VERTICAL, false,
            false, false);

    ChartDescriptor descriptor = new ChartDescriptor(dataSource, indices, ChartConstants.SCATTER_PLOT, xLabel,
            yLabel);

    chartManager.put(chart, descriptor);

    view.display(chart);
}

From source file:org.hxzon.demo.jfreechart.PolarChartDemo.java

private static XYDataset createDataset2() {

    DefaultXYDataset dataset = new DefaultXYDataset();
    //{{theta1,theta2,theta3, },{radius1,radius2,radius3,}}
    double[][] series1 = new double[2][30];
    for (int i = 0; i < 30; i++) {
        series1[0][i] = 90 + i * 10;//from   w w  w.j  a v  a 2 s  . c  o m
        series1[1][i] = i * 10;
    }
    double[][] series2 = new double[2][30];
    for (int i = 0; i < 30; i++) {
        series2[0][i] = i * 10;
        series2[1][i] = 100;
    }
    dataset.addSeries("series 1", series1);
    dataset.addSeries("series 2", series2);

    return dataset;
}

From source file:uk.ac.leeds.ccg.andyt.projects.moses.process.RegressionReport.java

public static JFreeChart getYEqualsXLineChart(double[][] data, String xAxisLabel_String,
        String yAxisLabel_String) {
    JFreeChart a_XYLineChart = null;/*from w  w  w .  j av  a  2  s .  com*/
    String title = null;
    boolean legend = false;
    boolean tooltips = false;
    boolean urls = false;
    double[][] lineChartData = new double[2][2];
    lineChartData[0][0] = Double.MAX_VALUE;// min_CASObservedData;
    lineChartData[0][1] = Double.MIN_VALUE;// max_CASObservedData;
    lineChartData[1][0] = Double.MAX_VALUE;// min_SARExpectedData;
    lineChartData[1][1] = Double.MIN_VALUE;// max_SARExpectedData;
    for (int j = 0; j < data[0].length; j++) {
        lineChartData[0][0] = Math.min(lineChartData[0][0], data[0][j]);
        lineChartData[0][1] = Math.max(lineChartData[0][1], data[0][j]);
        lineChartData[1][0] = Math.min(lineChartData[1][0], data[1][j]);
        lineChartData[1][1] = Math.max(lineChartData[1][1], data[1][j]);
    }
    lineChartData[1][0] = lineChartData[0][0];
    lineChartData[0][1] = Math.min(lineChartData[1][1], lineChartData[0][1]);
    lineChartData[1][1] = lineChartData[0][1];
    System.out.println("min lineChartData[0][0] " + lineChartData[0][0]);
    System.out.println("max lineChartData[0][1] " + lineChartData[0][1]);
    System.out.println("min lineChartData[1][0] " + lineChartData[1][0]);
    System.out.println("max lineChartData[1][1] " + lineChartData[1][1]);
    DefaultXYDataset a_DefaultXYDataset = new DefaultXYDataset();
    a_DefaultXYDataset.addSeries("y = x", lineChartData);
    a_XYLineChart = ChartFactory.createXYLineChart(title, xAxisLabel_String, yAxisLabel_String,
            a_DefaultXYDataset, PlotOrientation.HORIZONTAL, legend, tooltips, urls);
    return a_XYLineChart;
}