Example usage for org.jfree.data.time TimeSeries add

List of usage examples for org.jfree.data.time TimeSeries add

Introduction

In this page you can find the example usage for org.jfree.data.time TimeSeries add.

Prototype

public void add(RegularTimePeriod period, Number value) 

Source Link

Document

Adds a new data item to the series and sends a org.jfree.data.general.SeriesChangeEvent to all registered listeners.

Usage

From source file:DualAxisDemo2.java

/**
 * Creates a sample dataset.//from w  w w  .j  av  a 2  s  .com
 *
 * @return The dataset.
 */
private XYDataset createDataset1() {

    final TimeSeries s1 = new TimeSeries("Random Data 1", Month.class);
    s1.add(new Month(2, 2001), 181.8);
    s1.add(new Month(3, 2001), 167.3);
    s1.add(new Month(4, 2001), 153.8);
    s1.add(new Month(5, 2001), 167.6);
    s1.add(new Month(6, 2001), 158.8);
    s1.add(new Month(7, 2001), 148.3);
    s1.add(new Month(8, 2001), 153.9);
    s1.add(new Month(9, 2001), 142.7);
    s1.add(new Month(10, 2001), 123.2);
    s1.add(new Month(11, 2001), 131.8);
    s1.add(new Month(12, 2001), 139.6);
    s1.add(new Month(1, 2002), 142.9);
    s1.add(new Month(2, 2002), 138.7);
    s1.add(new Month(3, 2002), 137.3);
    s1.add(new Month(4, 2002), 143.9);
    s1.add(new Month(5, 2002), 139.8);
    s1.add(new Month(6, 2002), 137.0);
    s1.add(new Month(7, 2002), 132.8);

    final TimeSeriesCollection dataset = new TimeSeriesCollection();
    dataset.addSeries(s1);

    return dataset;

}

From source file:DualAxisDemo2.java

/**
 * Creates a sample dataset./*from  w ww.jav  a 2s  .  c  o m*/
 *
 * @return The dataset.
 */
private XYDataset createDataset2() {

    final TimeSeries s2 = new TimeSeries("Random Data 2", Month.class);
    s2.add(new Month(2, 2001), 429.6);
    s2.add(new Month(3, 2001), 323.2);
    s2.add(new Month(4, 2001), 417.2);
    s2.add(new Month(5, 2001), 624.1);
    s2.add(new Month(6, 2001), 422.6);
    s2.add(new Month(7, 2001), 619.2);
    s2.add(new Month(8, 2001), 416.5);
    s2.add(new Month(9, 2001), 512.7);
    s2.add(new Month(10, 2001), 501.5);
    s2.add(new Month(11, 2001), 306.1);
    s2.add(new Month(12, 2001), 410.3);
    s2.add(new Month(1, 2002), 511.7);
    s2.add(new Month(2, 2002), 611.0);
    s2.add(new Month(3, 2002), 709.6);
    s2.add(new Month(4, 2002), 613.2);
    s2.add(new Month(5, 2002), 711.6);
    s2.add(new Month(6, 2002), 708.8);
    s2.add(new Month(7, 2002), 501.6);

    final TimeSeriesCollection dataset = new TimeSeriesCollection();
    dataset.addSeries(s2);

    return dataset;

}

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

/**
 * Creates a sample dataset.//  www.  j  ava  2 s  . co  m
 *
 * @return Series 2.
 */
private XYDataset createDataset2() {

    // create dataset 2...
    final TimeSeries series2 = new TimeSeries("Series 2", Day.class);

    series2.add(new Day(3, SerialDate.MARCH, 2002), 16853.2);
    series2.add(new Day(4, SerialDate.MARCH, 2002), 19642.3);
    series2.add(new Day(5, SerialDate.MARCH, 2002), 18253.5);
    series2.add(new Day(6, SerialDate.MARCH, 2002), 15352.3);
    series2.add(new Day(7, SerialDate.MARCH, 2002), 13532.0);
    series2.add(new Day(8, SerialDate.MARCH, 2002), 12635.3);
    series2.add(new Day(9, SerialDate.MARCH, 2002), 13998.2);
    series2.add(new Day(10, SerialDate.MARCH, 2002), 11943.2);
    series2.add(new Day(11, SerialDate.MARCH, 2002), 16943.9);
    series2.add(new Day(12, SerialDate.MARCH, 2002), 17843.2);
    series2.add(new Day(13, SerialDate.MARCH, 2002), 16495.3);
    series2.add(new Day(14, SerialDate.MARCH, 2002), 17943.6);
    series2.add(new Day(15, SerialDate.MARCH, 2002), 18500.7);
    series2.add(new Day(16, SerialDate.MARCH, 2002), 19595.9);

    return new TimeSeriesCollection(series2);

}

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

/**
 * Creates a sample dataset.//w ww  . ja v  a 2 s .co m
 *
 * @return The dataset.
 */
private IntervalXYDataset createDataset1() {

    // create dataset 1...
    final TimeSeries series1 = new TimeSeries("Series 1", Day.class);
    series1.add(new Day(1, SerialDate.MARCH, 2002), 12353.3);
    series1.add(new Day(2, SerialDate.MARCH, 2002), 13734.4);
    series1.add(new Day(3, SerialDate.MARCH, 2002), 14525.3);
    series1.add(new Day(4, SerialDate.MARCH, 2002), 13984.3);
    series1.add(new Day(5, SerialDate.MARCH, 2002), 12999.4);
    series1.add(new Day(6, SerialDate.MARCH, 2002), 14274.3);
    series1.add(new Day(7, SerialDate.MARCH, 2002), 15943.5);
    series1.add(new Day(8, SerialDate.MARCH, 2002), 14845.3);
    series1.add(new Day(9, SerialDate.MARCH, 2002), 14645.4);
    series1.add(new Day(10, SerialDate.MARCH, 2002), 16234.6);
    series1.add(new Day(11, SerialDate.MARCH, 2002), 17232.3);
    series1.add(new Day(12, SerialDate.MARCH, 2002), 14232.2);
    series1.add(new Day(13, SerialDate.MARCH, 2002), 13102.2);
    series1.add(new Day(14, SerialDate.MARCH, 2002), 14230.2);
    series1.add(new Day(15, SerialDate.MARCH, 2002), 11235.2);

    return new TimeSeriesCollection(series1);

}

From source file:org.sunzoft.sunstock.StockMain.java

protected XYDataset initChartData() {
    TimeSeries ts1 = new TimeSeries("?");
    for (AccountStatus td : profits) {
        ts1.add(new Day(Integer.parseInt(td.date.substring(6)), Integer.parseInt(td.date.substring(4, 6)),
                Integer.parseInt(td.date.substring(0, 4))), (td.market - td.capital));
    }//from w w  w.jav  a 2s .c om
    TimeSeriesCollection localTimeSeriesCollection = new TimeSeriesCollection();
    localTimeSeriesCollection.addSeries(ts1);
    //localTimeSeriesCollection.addSeries(ts2);
    return localTimeSeriesCollection;
}

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

/**
 * Creates a sample dataset.//from w w w .ja va  2  s  .com
 *
 * @return The dataset.
 */
private XYDataset createDataset2() {

    // create dataset 2...
    final TimeSeries series2 = new TimeSeries("Series 2", Day.class);

    series2.add(new Day(3, SerialDate.MARCH, 2002), 16853.2);
    series2.add(new Day(4, SerialDate.MARCH, 2002), 19642.3);
    series2.add(new Day(5, SerialDate.MARCH, 2002), 18253.5);
    series2.add(new Day(6, SerialDate.MARCH, 2002), 15352.3);
    series2.add(new Day(7, SerialDate.MARCH, 2002), 13532.0);
    series2.add(new Day(8, SerialDate.MARCH, 2002), 12635.3);
    series2.add(new Day(9, SerialDate.MARCH, 2002), 13998.2);
    series2.add(new Day(10, SerialDate.MARCH, 2002), 11943.2);
    series2.add(new Day(11, SerialDate.MARCH, 2002), 16943.9);
    series2.add(new Day(12, SerialDate.MARCH, 2002), 17843.2);
    series2.add(new Day(13, SerialDate.MARCH, 2002), 16495.3);
    series2.add(new Day(14, SerialDate.MARCH, 2002), 17943.6);
    series2.add(new Day(15, SerialDate.MARCH, 2002), 18500.7);
    series2.add(new Day(16, SerialDate.MARCH, 2002), 19595.9);

    final TimeSeriesCollection tsc = new TimeSeriesCollection(series2);
    return tsc;

}

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

/**
 * Creates a sample dataset./*from w ww.  ja  v  a2  s  . c  o m*/
 *
 * @return Series 1.
 */
private IntervalXYDataset createDataset1() {

    // create dataset 1...
    final TimeSeries series1 = new TimeSeries("Series 1", Day.class);
    series1.add(new Day(1, SerialDate.MARCH, 2002), 12353.3);
    series1.add(new Day(2, SerialDate.MARCH, 2002), 13734.4);
    series1.add(new Day(3, SerialDate.MARCH, 2002), 14525.3);
    series1.add(new Day(4, SerialDate.MARCH, 2002), 13984.3);
    series1.add(new Day(5, SerialDate.MARCH, 2002), 12999.4);
    series1.add(new Day(6, SerialDate.MARCH, 2002), 14274.3);
    series1.add(new Day(7, SerialDate.MARCH, 2002), 15943.5);
    series1.add(new Day(8, SerialDate.MARCH, 2002), 14845.3);
    series1.add(new Day(9, SerialDate.MARCH, 2002), 14645.4);
    series1.add(new Day(10, SerialDate.MARCH, 2002), 16234.6);
    series1.add(new Day(11, SerialDate.MARCH, 2002), 17232.3);
    series1.add(new Day(12, SerialDate.MARCH, 2002), 14232.2);
    series1.add(new Day(13, SerialDate.MARCH, 2002), 13102.2);
    series1.add(new Day(14, SerialDate.MARCH, 2002), 14230.2);
    series1.add(new Day(15, SerialDate.MARCH, 2002), 11235.2);

    final TimeSeriesCollection collection = new TimeSeriesCollection(series1);
    collection.setDomainIsPointsInTime(false); // this tells the time series collection that
                                               // we intend the data to represent time periods
                                               // NOT points in time.  This is required when
                                               // determining the min/max values in the
                                               // dataset's domain.
    return collection;

}

From source file:uk.co.bssd.reporting.chart.TimeSeriesChart.java

private XYDataset convertDataset(String seriesName, TimedDatapoints<T> timedDatapoints) {
    TimeSeries series = new TimeSeries(seriesName);
    for (TimedDatapoint<T> timedDatapoint : timedDatapoints) {
        Millisecond regularTimePeriod = new Millisecond(timedDatapoint.timestamp().toDate());
        series.add(regularTimePeriod, timedDatapoint.value());
    }/*  ww  w . j a v a  2  s  . c om*/
    return new TimeSeriesCollection(series);
}

From source file:edu.ucla.stat.SOCR.chart.demo.XYBarChartDemo1.java

/**
 * Creates a sample dataset.//from   w w  w .  java  2s . c  om
 */
protected IntervalXYDataset createDataset(boolean isDemo) {
    if (isDemo) {
        TimeSeries t1 = new TimeSeries("Executions", "Year", "Count", Year.class);
        try {
            t1.add(new Year(1976), new Integer(0));
            t1.add(new Year(1977), new Integer(1));
            t1.add(new Year(1978), new Integer(0));
            t1.add(new Year(1979), new Integer(2));
            t1.add(new Year(1980), new Integer(0));
            t1.add(new Year(1981), new Integer(1));
            t1.add(new Year(1982), new Integer(2));
            t1.add(new Year(1983), new Integer(5));
            t1.add(new Year(1984), new Integer(21));
            t1.add(new Year(1985), new Integer(18));
            t1.add(new Year(1986), new Integer(18));
            t1.add(new Year(1987), new Integer(25));
            t1.add(new Year(1988), new Integer(11));
            t1.add(new Year(1989), new Integer(16));
            t1.add(new Year(1990), new Integer(23));
            t1.add(new Year(1991), new Integer(14));
            t1.add(new Year(1992), new Integer(31));
            t1.add(new Year(1993), new Integer(38));
            t1.add(new Year(1994), new Integer(31));
            t1.add(new Year(1995), new Integer(56));
            t1.add(new Year(1996), new Integer(45));
            t1.add(new Year(1997), new Integer(74));
            t1.add(new Year(1998), new Integer(68));
            t1.add(new Year(1999), new Integer(98));
            t1.add(new Year(2000), new Integer(85));
            t1.add(new Year(2001), new Integer(66));
            t1.add(new Year(2002), new Integer(71));
            t1.add(new Year(2003), new Integer(65));

        } catch (Exception e) {
            System.err.println(e.getMessage());
        }
        TimeSeriesCollection tsc = new TimeSeriesCollection(t1);
        // tsc.setDomainIsPointsInTime(false);
        return tsc;
    } else
        return super.createDataset(false);
}

From source file:OverlaidXYPlotDemo2.java

/**
 * Creates a sample dataset.//from   w  ww  .j  a va2s .c om
 *
 * @return The dataset.
 */
private IntervalXYDataset createDataset1() {

    // create dataset 1...
    final TimeSeries series1 = new TimeSeries("Series 1", Day.class);
    series1.add(new Day(1, SerialDate.MARCH, 2002), 12353.3);
    series1.add(new Day(2, SerialDate.MARCH, 2002), 13734.4);
    series1.add(new Day(3, SerialDate.MARCH, 2002), 14525.3);
    series1.add(new Day(4, SerialDate.MARCH, 2002), 13984.3);
    series1.add(new Day(5, SerialDate.MARCH, 2002), 12999.4);
    series1.add(new Day(6, SerialDate.MARCH, 2002), 14274.3);
    series1.add(new Day(7, SerialDate.MARCH, 2002), 15943.5);
    series1.add(new Day(8, SerialDate.MARCH, 2002), 14845.3);
    series1.add(new Day(9, SerialDate.MARCH, 2002), 14645.4);
    series1.add(new Day(10, SerialDate.MARCH, 2002), 16234.6);
    series1.add(new Day(11, SerialDate.MARCH, 2002), 17232.3);
    series1.add(new Day(12, SerialDate.MARCH, 2002), 14232.2);
    series1.add(new Day(13, SerialDate.MARCH, 2002), 13102.2);
    series1.add(new Day(14, SerialDate.MARCH, 2002), 14230.2);
    series1.add(new Day(15, SerialDate.MARCH, 2002), 11235.2);

    final TimeSeriesCollection result = new TimeSeriesCollection(series1);
    return result;

}