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

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

Introduction

In this page you can find the example usage for org.jfree.data.xy DefaultXYZDataset 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:org.jfree.chart.demo.XYBlockChartDemo2.java

private static XYZDataset createDataset() {
    double ad[] = new double[2400];
    double ad1[] = new double[2400];
    double ad2[] = new double[2400];
    Object obj = new Day();
    for (int i = 0; i < 100; i++) {
        double d = 1.0D;
        for (int j = 0; j < 24; j++) {
            if (Math.random() < 0.10000000000000001D)
                d = Math.random() * 4D;
            ad[i * 24 + j] = ((RegularTimePeriod) (obj)).getFirstMillisecond();
            ad1[i * 24 + j] = j;/*w  ww  . jav a2 s.  c o  m*/
            ad2[i * 24 + j] = d;
        }

        obj = ((RegularTimePeriod) (obj)).next();
    }

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

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

private static XYZDataset createDataset() {
    double ad[] = new double[840];
    double ad1[] = new double[840];
    double ad2[] = new double[840];
    double ad3[][] = { ad, ad1, ad2 };
    for (int i = 0; i < 60; i++) {
        for (int j1 = 8; j1 < 22; j1++)
            setValue(ad3, i, j1, 0.0D);//from   w  ww.j a  v a2 s  .c om

    }

    for (int j = 8; j < 12; j++) {
        for (int k1 = 13; k1 < 48; k1++)
            setValue(ad3, k1, j, 1.0D);

    }

    for (int k = 12; k < 20; k++) {
        for (int l1 = 23; l1 < 43; l1++)
            setValue(ad3, l1, k, 1.0D);

    }

    setValue(ad3, 2, 20, 2D);
    setValue(ad3, 5, 20, 3D);
    setValue(ad3, 6, 20, 3D);
    setValue(ad3, 7, 20, 3D);
    setValue(ad3, 8, 20, 3D);
    setValue(ad3, 9, 20, 3D);
    setValue(ad3, 11, 20, 3D);
    setValue(ad3, 17, 20, 2D);
    setValue(ad3, 18, 20, 2D);
    setValue(ad3, 19, 20, 2D);
    setValue(ad3, 20, 20, 2D);
    setValue(ad3, 22, 20, 2D);
    setValue(ad3, 25, 20, 2D);
    setValue(ad3, 28, 20, 2D);
    setValue(ad3, 35, 20, 2D);
    for (int l = 40; l < 60; l++)
        setValue(ad3, l, 20, 3D);

    for (int i1 = 23; i1 < 43; i1++)
        setValue(ad3, i1, 21, 1.0D);

    DefaultXYZDataset defaultxyzdataset = new DefaultXYZDataset();
    defaultxyzdataset.addSeries("Series 1", ad3);
    return defaultxyzdataset;
}

From source file:com.dreikraft.axbo.timeseries.TimeSeriesUtil.java

/**
 * Create a XYZ dataset from a time series with Y.
 *
 * @param source//from  w  ww. j av a  2  s . c  om
 * @return
 */
public static final XYZDataset createXYZTimeSeries(final TimeSeries source) {

    final RegularTimePeriod lastTimePeriod = source.getTimePeriod(source.getItemCount() - 1);
    // process all timeperiods including empty ones
    RegularTimePeriod t = source.getTimePeriod(0);
    final List<Double> zValuesList = new LinkedList<>();
    while (!(t.getFirstMillisecond() > lastTimePeriod.getFirstMillisecond())) {
        zValuesList.add(getValue(source, t));
        t = t.next();
    }
    final double[] xValues = new double[zValuesList.size()];
    final double[] yValues = new double[zValuesList.size()];
    final double[] zValues = new double[zValuesList.size()];
    t = source.getTimePeriod(0);
    for (int i = 0; i < zValuesList.size(); i++) {
        xValues[i] = t.getFirstMillisecond();
        yValues[i] = 0;
        zValues[i] = zValuesList.get(i);
        t = t.next();
    }
    final DefaultXYZDataset target = new DefaultXYZDataset();
    target.addSeries(0, new double[][] { xValues, yValues, zValues });

    return target;
}

From source file:com.javafxpert.neuralnetviz.scenario.PlotUtil.java

/**Create data for the background data set
 *//*www  .  j ava2s. c  om*/
private static XYZDataset createBackgroundData(INDArray backgroundIn, INDArray backgroundOut) {
    int nRows = backgroundIn.rows();
    double[] xValues = new double[nRows];
    double[] yValues = new double[nRows];
    double[] zValues = new double[nRows];
    for (int i = 0; i < nRows; i++) {
        xValues[i] = backgroundIn.getDouble(i, 0);
        yValues[i] = backgroundIn.getDouble(i, 1);
        zValues[i] = backgroundOut.getDouble(i);

    }

    DefaultXYZDataset dataset = new DefaultXYZDataset();
    dataset.addSeries("Series 1", new double[][] { xValues, yValues, zValues });
    return dataset;
}

From source file:cv.mikusher.freechart.BubbleChart.java

public static XYZDataset createDataset() {
    DefaultXYZDataset defaultxyzdataset = new DefaultXYZDataset();

    double ad[] = { 30, 40, 50, 60, 70, 80 };
    double ad1[] = { 10, 20, 30, 40, 50, 60 };
    double ad2[] = { 4, 5, 10, 8, 9, 6 };
    double ad3[][] = { ad, ad1, ad2 };
    defaultxyzdataset.addSeries("Series 1", ad3);

    return defaultxyzdataset;
}

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

public static XYZDataset createDataset() {
    DefaultXYZDataset defaultxyzdataset = new DefaultXYZDataset();
    double ad[] = { 2.1000000000000001D, 2.2999999999999998D, 2.2999999999999998D, 2.2000000000000002D,
            2.2000000000000002D, 1.8D, 1.8D, 1.8999999999999999D, 2.2999999999999998D, 3.7999999999999998D };
    double ad1[] = { 14.1D, 11.1D, 10D, 8.8000000000000007D, 8.6999999999999993D, 8.4000000000000004D,
            5.4000000000000004D, 4.0999999999999996D, 4.0999999999999996D, 25D };
    double ad2[] = { 2.3999999999999999D, 2.7000000000000002D, 2.7000000000000002D, 2.2000000000000002D,
            2.2000000000000002D, 2.2000000000000002D, 2.1000000000000001D, 2.2000000000000002D,
            1.6000000000000001D, 4D };//from  w ww .j a  va  2  s .co  m
    double ad3[][] = { ad, ad1, ad2 };
    defaultxyzdataset.addSeries("Series 1", ad3);
    return defaultxyzdataset;
}

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

public static XYZDataset createDataset() {
    DefaultXYZDataset defaultxyzdataset = new DefaultXYZDataset();
    double ad[] = { 2.1000000000000001D, 2.2999999999999998D, 2.2999999999999998D, 2.2000000000000002D,
            2.2000000000000002D, 1.8D, 1.8D, 1.8999999999999999D, 2.2999999999999998D, 2.7999999999999998D };
    double ad1[] = { 14.1D, 17.100000000000001D, 10D, 8.8000000000000007D, 8.6999999999999993D,
            8.4000000000000004D, 5.4000000000000004D, 4.0999999999999996D, 4.0999999999999996D, 25D };
    double ad2[] = { 2.3999999999999999D, 2.7000000000000002D, 1.7D, 2.2000000000000002D, 1.3D,
            2.2000000000000002D, 2.1000000000000001D, 3.2000000000000002D, 1.6000000000000001D,
            3.3999999999999999D };//from w  ww .  ja v a2s . c om
    double ad3[][] = { ad, ad1, ad2 };
    defaultxyzdataset.addSeries("Series 1", ad3);
    return defaultxyzdataset;
}

From source file:jamel.gui.charts.InstantXYZScatterChart.java

/**
 * Update the chart./*from   w w  w . j a  va 2  s . c  om*/
 * @param minDate the min date.
 * @param maxDate the max date.
 */
public void setTimeRange(Date minDate, Date maxDate) {
    double[][] data = Circuit.getCircuit().getCrossSectionSeries().get(xLabel, yLabel, zLabel);
    if (data == null)
        return;
    if (data[2].length == 0)
        return;
    double min = 0;
    double max = data[2][0];
    for (int count = 1; count < data[2].length; count++) {
        if (data[2][count] > max)
            max = data[2][count];
    }
    setColorScale(min, max);
    DefaultXYZDataset dataset = new DefaultXYZDataset();
    dataset.addSeries("Data test", data);
    try {
        this.getXYPlot().setDataset(1, dataset);
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:edu.gmu.cs.sim.util.media.chart.BubbleChartGenerator.java

public SeriesAttributes addSeries(double[][] values, String name,
        final org.jfree.data.general.SeriesChangeListener stopper) {
    DefaultXYZDataset dataset = (DefaultXYZDataset) (getSeriesDataset());
    int i = dataset.getSeriesCount();
    dataset.addSeries(new UniqueString(name), values);

    // need to have added the dataset BEFORE calling this since it'll try to change the name of the series
    BubbleChartSeriesAttributes csa = new BubbleChartSeriesAttributes(this, name, i, values, stopper);
    seriesAttributes.add(csa, name);/*from w  w  w. ja  v a2s .c  om*/

    revalidate();
    update();

    // won't update properly unless I force it here by letting all the existing scheduled events to go through.  Dumb design.  :-(
    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            update();
        }
    });

    return csa;
}

From source file:org.jfree.data.xy.DefaultXYZDatasetTest.java

/**
 * Some tests for the addSeries() method.
 *///from  w w w  .ja  v  a  2 s  . c o m
@Test
public void testAddSeries() {
    DefaultXYZDataset d = new DefaultXYZDataset();
    d.addSeries("S1", new double[][] { { 1.0 }, { 2.0 }, { 3.0 } });
    assertEquals(1, d.getSeriesCount());
    assertEquals("S1", d.getSeriesKey(0));

    // check that adding a series will overwrite the old series
    d.addSeries("S1", new double[][] { { 11.0 }, { 12.0 }, { 13.0 } });
    assertEquals(1, d.getSeriesCount());
    assertEquals(12.0, d.getYValue(0, 0), EPSILON);

    // check null key
    boolean pass = false;
    try {
        d.addSeries(null, new double[][] { { 1.0 }, { 2.0 }, { 3.0 } });
    } catch (IllegalArgumentException e) {
        pass = true;
    }
    assertTrue(pass);
}