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, boolean notify) 

Source Link

Document

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

Usage

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

private static XYDataset createDataset() {
    boolean notify = false;

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

    TimeSeries s2 = new TimeSeries(series2Name);
    s2.add(new Month(2, 2001), 129.6, notify);
    s2.add(new Month(3, 2001), 123.2, notify);
    s2.add(new Month(4, 2001), 117.2, notify);
    s2.add(new Month(5, 2001), 124.1, notify);
    s2.add(new Month(6, 2001), 122.6, notify);
    s2.add(new Month(7, 2001), 119.2, notify);
    s2.add(new Month(8, 2001), 116.5, notify);
    s2.add(new Month(9, 2001), 112.7, notify);
    s2.add(new Month(10, 2001), 101.5, notify);
    s2.add(new Month(11, 2001), 106.1, notify);
    s2.add(new Month(12, 2001), 110.3, notify);
    s2.add(new Month(1, 2002), 111.7, notify);
    s2.add(new Month(2, 2002), 111.0, notify);
    s2.add(new Month(3, 2002), 109.6, notify);
    s2.add(new Month(4, 2002), 113.2, notify);
    s2.add(new Month(5, 2002), 111.6, notify);
    s2.add(new Month(6, 2002), 108.8, notify);
    s2.add(new Month(7, 2002), 101.6, notify);

    TimeSeries s3 = new TimeSeries(series3Name);
    s3.add(new Month(2, 2001), 1129.6, notify);
    s3.add(new Month(3, 2001), 1123.2, notify);
    s3.add(new Month(4, 2001), 1117.2, notify);
    s3.add(new Month(5, 2001), 1124.1, notify);
    s3.add(new Month(6, 2001), 1122.6, notify);
    s3.add(new Month(7, 2001), 1119.2, notify);
    s3.add(new Month(8, 2001), 1116.5, notify);
    s3.add(new Month(9, 2001), 1112.7, notify);
    s3.add(new Month(10, 2001), 1101.5, notify);
    s3.add(new Month(11, 2001), 1106.1, notify);
    s3.add(new Month(12, 2001), 1110.3, notify);
    s3.add(new Month(1, 2002), 1111.7, notify);
    s3.add(new Month(2, 2002), 1111.0, notify);
    s3.add(new Month(3, 2002), 1109.6, notify);
    s3.add(new Month(4, 2002), 1113.2, notify);
    s3.add(new Month(5, 2002), 1111.6, notify);
    s3.add(new Month(6, 2002), 1108.8, notify);
    s3.add(new Month(7, 2002), 1101.6, notify);

    TimeSeriesCollection dataset = new TimeSeriesCollection();
    dataset.addSeries(s3);/*w w w  .  j  av  a  2s.  co  m*/
    dataset.addSeries(s2);
    dataset.addSeries(s1);

    return dataset;
}

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

private static XYDataset createDataset1() {
    boolean notify = false;

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

    TimeSeries s2 = new TimeSeries(series2Name);
    s2.add(new Month(2, 2001), 129.6, notify);
    s2.add(new Month(3, 2001), 123.2, notify);
    s2.add(new Month(4, 2001), 117.2, notify);
    s2.add(new Month(5, 2001), 124.1, notify);
    s2.add(new Month(6, 2001), 122.6, notify);
    s2.add(new Month(7, 2001), 119.2, notify);
    s2.add(new Month(8, 2001), 116.5, notify);
    s2.add(new Month(9, 2001), 112.7, notify);
    s2.add(new Month(10, 2001), 101.5, notify);
    s2.add(new Month(11, 2001), 106.1, notify);
    s2.add(new Month(12, 2001), 110.3, notify);
    s2.add(new Month(1, 2002), 111.7, notify);
    s2.add(new Month(2, 2002), 111.0, notify);
    s2.add(new Month(3, 2002), 109.6, notify);
    s2.add(new Month(4, 2002), 113.2, notify);
    s2.add(new Month(5, 2002), 111.6, notify);
    s2.add(new Month(6, 2002), 108.8, notify);
    s2.add(new Month(7, 2002), 101.6, notify);

    TimeSeries s3 = new TimeSeries(series3Name);
    s3.add(new Month(2, 2001), 1129.6, notify);
    s3.add(new Month(3, 2001), 1123.2, notify);
    s3.add(new Month(4, 2001), 1117.2, notify);
    s3.add(new Month(5, 2001), 1124.1, notify);
    s3.add(new Month(6, 2001), 1122.6, notify);
    s3.add(new Month(7, 2001), 1119.2, notify);
    s3.add(new Month(8, 2001), 1116.5, notify);
    s3.add(new Month(9, 2001), 1112.7, notify);
    s3.add(new Month(10, 2001), 1101.5, notify);
    s3.add(new Month(11, 2001), 1106.1, notify);
    s3.add(new Month(12, 2001), 1110.3, notify);
    s3.add(new Month(1, 2002), 1111.7, notify);
    s3.add(new Month(2, 2002), 1111.0, notify);
    s3.add(new Month(3, 2002), 1109.6, notify);
    s3.add(new Month(4, 2002), 1113.2, notify);
    s3.add(new Month(5, 2002), 1111.6, notify);
    s3.add(new Month(6, 2002), 1108.8, notify);
    s3.add(new Month(7, 2002), 1101.6, notify);

    TimeSeriesCollection dataset = new TimeSeriesCollection();
    dataset.addSeries(s3);//  w  ww .  jav  a2s  .  c  o  m
    dataset.addSeries(s2);
    dataset.addSeries(s1);

    return dataset;
}

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

private static XYDataset createDataset2() {
    boolean notify = false;

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

    TimeSeries s2 = new TimeSeries(series2Name);
    s2.add(new Month(2, 2001), 129.6, notify);
    s2.add(new Month(3, 2001), 123.2, notify);
    s2.add(new Month(4, 2001), 117.2, notify);
    s2.add(new Month(5, 2001), 124.1, notify);
    s2.add(new Month(6, 2001), 122.6, notify);
    s2.add(new Month(7, 2001), 119.2, notify);
    s2.add(new Month(8, 2001), 116.5, notify);
    s2.add(new Month(9, 2001), 112.7, notify);
    s2.add(new Month(10, 2001), 101.5, notify);
    s2.add(new Month(11, 2001), 106.1, notify);
    s2.add(new Month(12, 2001), 110.3, notify);
    s2.add(new Month(1, 2002), 111.7, notify);
    s2.add(new Month(2, 2002), 111.0, notify);
    s2.add(new Month(3, 2002), 109.6, notify);
    s2.add(new Month(4, 2002), 113.2, notify);
    s2.add(new Month(5, 2002), 111.6, notify);
    s2.add(new Month(6, 2002), 108.8, notify);
    s2.add(new Month(7, 2002), 101.6, notify);

    TimeSeries s3 = new TimeSeries(series3Name);
    s3.add(new Month(2, 2001), 2129.6, notify);
    s3.add(new Month(3, 2001), 2123.2, notify);
    s3.add(new Month(4, 2001), 2117.2, notify);
    s3.add(new Month(5, 2001), 2124.1, notify);
    s3.add(new Month(6, 2001), 2122.6, notify);
    s3.add(new Month(7, 2001), 2119.2, notify);
    s3.add(new Month(8, 2001), 2116.5, notify);
    s3.add(new Month(9, 2001), 2112.7, notify);
    s3.add(new Month(10, 2001), 2101.5, notify);
    s3.add(new Month(11, 2001), 2106.1, notify);
    s3.add(new Month(12, 2001), 2110.3, notify);
    s3.add(new Month(1, 2002), 2111.7, notify);
    s3.add(new Month(2, 2002), 2111.0, notify);
    s3.add(new Month(3, 2002), 2109.6, notify);
    s3.add(new Month(4, 2002), 2113.2, notify);
    s3.add(new Month(5, 2002), 2111.6, notify);
    s3.add(new Month(6, 2002), 2108.8, notify);
    s3.add(new Month(7, 2002), 2101.6, notify);

    TimeSeriesCollection dataset = new TimeSeriesCollection();
    dataset.addSeries(s3);//from   w  w w .ja v a 2s  . c om
    dataset.addSeries(s2);
    dataset.addSeries(s1);

    return dataset;
}

From source file:com.devoteam.srit.xmlloader.core.report.derived.DerivedCounter.java

public JFreeChart getTimeChart() {
    double[] graphTable = this.counter.graphDataset.getGraphArray();

    double[] weightTable = null;
    if (this instanceof StatValue) {
        weightTable = ((StatValue) this).eventCounter.graphDataset.getGraphArray();
    }/*  www  .java 2  s .  c  o m*/

    TimeSeries timeSeries = new TimeSeries("", FixedMillisecond.class);

    double hits = 0;

    long offset;
    boolean absoluteDate = Config.getConfigByName("tester.properties").getBoolean("stats.CHARTS_ABSOLUTE_DATE",
            false);
    if (absoluteDate) {
        offset = reportZeroTimestamp;
    } else {
        offset = 0;
    }
    for (int i = 0; i < graphTable.length; i++) {
        long timestamp = offset + i * this.counter.graphDataset.graphParameters.graphPeriod;
        timeSeries.add(new FixedMillisecond(timestamp), graphTable[i], false);
    }

    JFreeChart chart = ChartFactory.createXYAreaChart(null, // chart title
            null, // domain axis label
            null, // range axis label
            new TimeSeriesCollection(timeSeries), // data
            PlotOrientation.VERTICAL, // orientation
            false, // include legend
            false, // tooltips
            false // urls
    );
    if (null != mean && null != std_dv) {
        chart.getXYPlot().addRangeMarker(new ValueMarker(mean));
        IntervalMarker intervalMarker = new IntervalMarker(mean - std_dv / 2, mean + std_dv / 2);
        intervalMarker.setAlpha(0.3f);
        chart.getXYPlot().addRangeMarker(intervalMarker);
    }

    chart.getXYPlot().setDomainAxis(new DateAxis());
    DateAxis axis = (DateAxis) chart.getXYPlot().getDomainAxis();
    DateFormat dateFormat;

    if (absoluteDate) {
        dateFormat = new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss");
        axis.setVerticalTickLabels(true);
    } else {
        dateFormat = new SimpleDateFormat("HH:mm:ss");
        dateFormat.setTimeZone(new SimpleTimeZone(0, "GMT"));
    }
    axis.setDateFormatOverride(dateFormat);

    chart.setBackgroundPaint(Color.WHITE);
    return chart;
}