Example usage for org.jfree.data.time TimeSeriesCollection TimeSeriesCollection

List of usage examples for org.jfree.data.time TimeSeriesCollection TimeSeriesCollection

Introduction

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

Prototype

public TimeSeriesCollection() 

Source Link

Document

Constructs an empty dataset, tied to the default timezone.

Usage

From source file:org.tolven.analysis.bean.PercentTimeSeriesBean.java

private JFreeChart getChart(String dataSeriesTitle, String targetSeriesTitle, List<MenuData> snapshots,
        Date fromDate, Date toDate, Class<?> intervalUnitClass) {
    TimeSeries dataTimeSeries = new TimeSeries(dataSeriesTitle);
    TimeSeries targetTimeSeries = null;/*  w w w. j a v  a 2  s  .  c om*/
    if (targetSeriesTitle != null) {
        targetTimeSeries = new TimeSeries(targetSeriesTitle);
    }
    for (MenuData snapshot : snapshots) {
        Date snapshotDate = snapshot.getDate01();
        long nSnapshotresultsNumerator = snapshot.getLongField("normCount");
        long nSnapshotresultsDenominator = snapshot.getLongField("allCount");
        Double value = null;
        if (nSnapshotresultsDenominator == 0) {
            value = 0d;
        } else {
            value = 1d * nSnapshotresultsNumerator / nSnapshotresultsDenominator;
        }
        RegularTimePeriod regTimePeriod = RegularTimePeriod.createInstance(intervalUnitClass, snapshotDate,
                TimeZone.getDefault());
        dataTimeSeries.addOrUpdate(regTimePeriod, value);
        if (targetTimeSeries != null) {
            Double targetPercent = snapshot.getDoubleField("targetPercent") / 100;
            targetTimeSeries.addOrUpdate(regTimePeriod, targetPercent);
        }
    }
    TimeSeriesCollection timeSeriesCollection = new TimeSeriesCollection();
    timeSeriesCollection.addSeries(dataTimeSeries);
    if (targetTimeSeries != null) {
        timeSeriesCollection.addSeries(targetTimeSeries);
    }
    XYDataset xyDataset = (XYDataset) timeSeriesCollection;
    JFreeChart chart = ChartFactory.createTimeSeriesChart(null, // title
            null, // x-axis label
            null, // y-axis label
            xyDataset, // data
            true, // create legend?
            false, // generate tooltips?
            false // generate URLs?
    );
    chart.setBackgroundPaint(Color.white);
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.white);
    plot.setRangeGridlinesVisible(true);
    plot.setRangeGridlinePaint(Color.BLACK);
    plot.setDomainGridlinesVisible(false);
    XYItemRenderer r = plot.getRenderer();
    XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r;
    renderer.setBaseShapesVisible(true);
    renderer.setBaseShapesFilled(true);
    renderer.setSeriesShape(0, new Ellipse2D.Double(-3, -3, 6, 6));
    renderer.setSeriesPaint(0, Color.BLUE);
    renderer.setSeriesShape(1, new Rectangle2D.Double(-3, -3, 6, 6));
    renderer.setSeriesPaint(1, Color.RED);
    NumberAxis vaxis = (NumberAxis) plot.getRangeAxis();
    vaxis.setAutoRange(true);
    vaxis.setAxisLineVisible(true);
    vaxis.setNumberFormatOverride(NumberFormat.getPercentInstance());
    vaxis.setTickMarksVisible(true);
    DateAxis daxis = (DateAxis) plot.getDomainAxis();
    daxis.setRange(fromDate, toDate);
    if (intervalUnitClass == Month.class) {
        DateFormatSymbols dateFormatSymbols = new DateFormatSymbols();
        dateFormatSymbols
                .setShortMonths(new String[] { "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D" });
        daxis.setDateFormatOverride(new SimpleDateFormat("MMM", dateFormatSymbols));
    }
    return chart;
}

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);//from  ww w .j a va  2 s.  com
    dataset.addSeries(s2);
    dataset.addSeries(s1);

    return dataset;
}

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);//from   w w w. jav  a  2  s.c  o  m
    dataset.addSeries(s2);
    dataset.addSeries(s1);

    return dataset;
}

From source file:aplicacion.asterisk.manager.logic.TimeSeriesChartDemo1.java

/**
 * Creates a dataset, consisting of two series of monthly data.
 *
 * @return The dataset./*from   www.j  ava  2  s  .co  m*/
 */
private static XYDataset createDataset() {

    TimeSeries s1 = new TimeSeries("L&G European Index Trust");
    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);
    /*
            TimeSeries s2 = new TimeSeries("L&G UK Index Trust");
            s2.add(new Month(2, 2001), 129.6);
            s2.add(new Month(3, 2001), 123.2);
            s2.add(new Month(4, 2001), 117.2);
            s2.add(new Month(5, 2001), 124.1);
            s2.add(new Month(6, 2001), 122.6);
            s2.add(new Month(7, 2001), 119.2);
            s2.add(new Month(8, 2001), 116.5);
            s2.add(new Month(9, 2001), 112.7);
            s2.add(new Month(10, 2001), 101.5);
            s2.add(new Month(11, 2001), 106.1);
            s2.add(new Month(12, 2001), 110.3);
            s2.add(new Month(1, 2002), 111.7);
            s2.add(new Month(2, 2002), 111.0);
            s2.add(new Month(3, 2002), 109.6);
            s2.add(new Month(4, 2002), 113.2);
            s2.add(new Month(5, 2002), 111.6);
            s2.add(new Month(6, 2002), 108.8);
            s2.add(new Month(7, 2002), 101.6);*/

    // ******************************************************************
    //  More than 150 demo applications are included with the JFreeChart
    //  Developer Guide...for more information, see:
    //
    //  >   http://www.object-refinery.com/jfreechart/guide.html
    //
    // ******************************************************************

    TimeSeriesCollection dataset = new TimeSeriesCollection();
    dataset.addSeries(s1);
    //dataset.addSeries(s2);

    return dataset;

}

From source file:serverrobot.DynamicGraph.java

public TimeSeriesCollection createPlatformPitchCollection() {
    final TimeSeriesCollection coll = new TimeSeriesCollection();
    coll.addSeries(pitchAcc);/*from  w  ww .ja  v a  2 s. c  o m*/
    return coll;
}

From source file:net.sf.clichart.chart.AbstractChartBuilderTest.java

public void testGetChart() throws InvalidDataException {
    setInitialiseSeriesColumnExpectations(HEADERS);
    Options options = new OptionsBean();
    m_control.expectAndReturn(m_delegate.getChartImpl(options), ChartFactory.createTimeSeriesChart("title",
            "xTitle", "yTitle", new TimeSeriesCollection(), true, false, false));
    m_control.expectAndReturn(null, m_delegate.getToolTipGenerator());

    m_control.replay();//from  ww  w  . jav a  2 s .c  om

    m_chartBuilder.headerParsed(HEADERS);
    m_chartBuilder.getChart(options);

    m_control.verify();
}

From source file:org.spf4j.perf.impl.chart.Charts.java

private static TimeSeriesCollection createTimeSeriesCollection(final String[] measurementNames,
        final long[] timestamps, final double[][] measurements) {
    TimeSeriesCollection timeseriescollection = new TimeSeriesCollection();
    for (int i = 0; i < measurementNames.length; i++) {
        TimeSeries tseries = new TimeSeries(measurementNames[i]);
        for (int j = 0; j < timestamps.length; j++) {
            FixedMillisecond ts = new FixedMillisecond(timestamps[j]);
            tseries.add(ts, measurements[i][j]);
        }/*from   ww  w.j a v  a  2  s.c o  m*/
        timeseriescollection.addSeries(tseries);
    }
    return timeseriescollection;
}

From source file:test.integ.be.fedict.performance.util.PerformanceResultDialog.java

private JFreeChart getMemoryChart(int intervalSize, List<MemoryData> memory) {

    if (null == memory || memory.isEmpty()) {
        return null;
    }/*ww w. ja  v  a 2 s .  c om*/

    JFreeChart chart;

    TimeSeries freeSeries = new TimeSeries("Free");
    TimeSeries maxSeries = new TimeSeries("Max");
    TimeSeries totalSeries = new TimeSeries("Total");

    memory.remove(memory.size() - 1);

    for (MemoryData memoryEntry : memory) {
        freeSeries.add(new Second(memoryEntry.getDate()), memoryEntry.getFreeMemory());

        maxSeries.add(new Second(memoryEntry.getDate()), memoryEntry.getMaxMemory());

        totalSeries.add(new Second(memoryEntry.getDate()), memoryEntry.getTotalMemory());
    }

    TimeSeriesCollection dataset = new TimeSeriesCollection();
    dataset.addSeries(freeSeries);
    dataset.addSeries(maxSeries);
    dataset.addSeries(totalSeries);
    chart = ChartFactory.createTimeSeriesChart("eID Trust Service Memory Usage History",
            "Time (interval size " + intervalSize + " msec)", "Memory", dataset, true, false, false);

    chart.addSubtitle(new TextTitle(
            memory.get(0).getDate().toString() + " - " + memory.get(memory.size() - 1).getDate().toString()));

    chart.setBackgroundPaint(Color.WHITE);
    XYPlot plot = chart.getXYPlot();
    plot.setBackgroundPaint(Color.WHITE);
    DateAxis axis = (DateAxis) plot.getDomainAxis();
    axis.setDateFormatOverride(new SimpleDateFormat("HH:mm:ss"));
    ValueAxis valueAxis = plot.getRangeAxis();
    valueAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    plot.setRangeGridlinePaint(Color.black);
    plot.setDomainGridlinePaint(Color.black);
    plot.setRenderer(renderer);

    return chart;
}

From source file:org.jfree.experimental.chart.demo.XYTitleAnnotationDemo1.java

/**
 * Creates a dataset, consisting of two series of monthly data.
 *
 * @return The dataset./*from  www . jav  a 2s .c om*/
 */
private static XYDataset createDataset() {

    TimeSeries s1 = new TimeSeries("L&G European Index Trust", 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);

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

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

    return dataset;

}

From source file:serverrobot.DynamicGraph.java

public TimeSeriesCollection createXPositionCollection() {
    final TimeSeriesCollection coll = new TimeSeriesCollection();
    coll.addSeries(setPointX);/*from w w w.j a  va 2  s  . c o m*/
    coll.addSeries(actPointX);
    return coll;
}