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

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

Introduction

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

Prototype

public TimeSeries(Comparable name) 

Source Link

Document

Creates a new (empty) time series.

Usage

From source file:imc.graficaIMC.java

public void iejmplo() {
    TimeSeries s1 = new TimeSeries("Entrenamiento Actual");
    s1.add(new Month(2, 2001), 181.8);
    //s1.add(new Week(1, 1), null);
    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);

    TimeSeries s3 = new TimeSeries("andres2255");
    s3.add(new Month(2, 2001), 129.6);

    s3.add(new Month(10, 2001), 106.1);
    s3.add(new Month(1, 2002), 111.7);
    s3.add(new Month(2, 2002), 111.0);
    datos.addSeries(s1);//from   w w w. ja va  2s .c  o  m
    datos.addSeries(s2);
    datos.addSeries(s3);

    grafica = ChartFactory.createTimeSeriesChart("titulo", "etiquetas X", "etiquetaY", datos, true, true,
            false);
    /// 
    grafica.setBackgroundPaint(Color.white);

    XYPlot plot = (XYPlot) grafica.getPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);
    plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    plot.setDomainCrosshairVisible(true);
    plot.setRangeCrosshairVisible(true);

    XYItemRenderer r = plot.getRenderer();
    if (r instanceof XYLineAndShapeRenderer) {
        XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r;
        renderer.setBaseShapesVisible(true);
        renderer.setBaseShapesFilled(true);
        renderer.setDrawSeriesLineAsPath(true);
    }

    DateAxis axis = (DateAxis) plot.getDomainAxis();
    axis.setDateFormatOverride(new SimpleDateFormat("MMM-yyyy"));
}

From source file:org.jfree.data.time.TimeSeriesTest.java

/**
 * Some checks for the delete(int, int) method.
 *///from   w w w. j  av a2  s .com
@Test
public void testDelete3() {
    TimeSeries s1 = new TimeSeries("S1");
    s1.add(new Year(2011), 1.1);
    s1.add(new Year(2012), 2.2);
    s1.add(new Year(2013), 3.3);
    s1.add(new Year(2014), 4.4);
    s1.add(new Year(2015), 5.5);
    s1.add(new Year(2016), 6.6);
    s1.delete(2, 5);
    assertEquals(2, s1.getItemCount());
    assertEquals(new Year(2011), s1.getTimePeriod(0));
    assertEquals(new Year(2012), s1.getTimePeriod(1));
    assertEquals(1.1, s1.getMinY(), EPSILON);
    assertEquals(2.2, s1.getMaxY(), EPSILON);
}

From source file:pt.lsts.neptus.console.bathymLayer.TidePanel.java

@Override
public void initSubPanel() {
    storedMenuPath = I18n.text("Tools") + ">" + I18n.text("Tides") + ">"
            + I18n.textf("Using '%file'", GeneralPreferences.tidesFile.getName());
    tidesItem = addMenuItem(storedMenuPath, null, new ActionListener() {
        @Override//from  w ww . j  av a 2 s .c  o  m
        public void actionPerformed(ActionEvent e) {
            JMenuItem menu = (JMenuItem) e.getSource();
            Thread t = new Thread("Tide chooser") {
                @Override
                public void run() {
                    try {
                        File usedTidesSource = GeneralPreferences.tidesFile;
                        String currentSource = usedTidesSource == null || !usedTidesSource.exists() ? null
                                : usedTidesSource.getName();
                        Date startDate = new Date(System.currentTimeMillis() - 2 * DateTimeUtil.DAY);
                        Date endDate = new Date(System.currentTimeMillis() + 3 * DateTimeUtil.DAY);
                        String harbor = TidePredictionFactory.showTidesSourceChooserGuiPopup(getConsole(),
                                currentSource, startDate, endDate);
                        if (harbor != null && !harbor.isEmpty()
                                && TidePredictionFactory.getTidesSourceFileFrom(harbor).exists()) {
                            GeneralPreferences.tidesFile = TidePredictionFactory.getTidesSourceFileFrom(harbor);
                            GeneralPreferences.saveProperties();
                            preferencesUpdated();
                            // Force the tide file reload
                            TidePredictionFactory.getTideLevel(System.currentTimeMillis());
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                    } finally {
                        menu.setEnabled(true);
                    }
                }
            };
            t.setDaemon(true);
            menu.setEnabled(false);
            t.run();
        }
    });
    //        tidesItem.setEnabled(false);

    addMenuItem(I18n.text("Tools") + ">" + I18n.text("Tides") + ">" + I18n.text("Update Predictions"), null,
            new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    JMenuItem menu = (JMenuItem) e.getSource();
                    Thread t = new Thread("Tide fetcher") {
                        public void run() {
                            try {
                                String harbor = TidePredictionFactory.fetchData(getConsole());
                                if (harbor != null && !harbor.isEmpty()) {
                                    File used = GeneralPreferences.tidesFile;
                                    File f = new File(ConfigFetch.getConfFolder() + "/tides/" + harbor + "."
                                            + TidePredictionFactory.defaultTideFormat);
                                    if (f.exists() && !f.getAbsolutePath().equals(used.getAbsolutePath())) {
                                        int resp = GuiUtils.confirmDialog(getConsole(),
                                                I18n.text("Tide Predictions"),
                                                I18n.textf(
                                                        "The selected location does not match the current location in use (%harbor). Do you wish to set the current location as %selection?",
                                                        used.getName(),
                                                        harbor + "." + TidePredictionFactory.defaultTideFormat),
                                                ModalityType.DOCUMENT_MODAL);

                                        if (resp == JOptionPane.YES_OPTION) {
                                            GeneralPreferences.tidesFile = f;
                                            GeneralPreferences.saveProperties();
                                            preferencesUpdated();
                                            // Force the tide file reload
                                            TidePredictionFactory.getTideLevel(System.currentTimeMillis());
                                        }
                                    }
                                }
                            } catch (Exception e) {
                                e.printStackTrace();
                            } finally {
                                menu.setEnabled(true);
                            }
                        };
                    };
                    t.setDaemon(true);
                    menu.setEnabled(false);
                    t.start();
                }
            });

    ts = new TimeSeries(I18n.text("Tide level"));
    tsc.addSeries(ts);

    for (double i = -12; i < 12; i += 0.25) {
        Date d = new Date(System.currentTimeMillis() + (long) (i * 1000 * 3600));
        ts.addOrUpdate(new Millisecond(d), TidePredictionFactory.getTideLevel(d));
    }
    timeSeriesChart.getXYPlot().addDomainMarker(marker);
    levelMarker.setValue(TidePredictionFactory.getTideLevel(new Date()));
    timeSeriesChart.getXYPlot().addRangeMarker(levelMarker);
}

From source file:org.matsim.contrib.drt.analysis.DynModeTripsAnalyser.java

public static void analyseWaitTimes(String fileName, List<DynModeTrip> trips, int binsize_s) {
    Collections.sort(trips);/*  www .j a  v  a  2  s  .  co  m*/
    if (trips.size() == 0)
        return;
    int startTime = ((int) (trips.get(0).getDepartureTime() / binsize_s)) * binsize_s;
    int endTime = ((int) (trips.get(trips.size() - 1).getDepartureTime() / binsize_s) + binsize_s) * binsize_s;
    Map<Double, List<DynModeTrip>> splitTrips = splitTripsIntoBins(trips, startTime, endTime, binsize_s);

    DecimalFormat format = new DecimalFormat();
    format.setDecimalFormatSymbols(new DecimalFormatSymbols(Locale.US));
    format.setMinimumIntegerDigits(1);
    format.setMaximumFractionDigits(2);
    format.setGroupingUsed(false);

    SimpleDateFormat sdf2 = new SimpleDateFormat("HH:mm:ss");

    BufferedWriter bw = IOUtils.getBufferedWriter(fileName + ".csv");
    TimeSeriesCollection dataset = new TimeSeriesCollection();
    TimeSeriesCollection datasetrequ = new TimeSeriesCollection();
    TimeSeries averageWaitC = new TimeSeries("average");
    TimeSeries medianWait = new TimeSeries("median");
    TimeSeries p_5Wait = new TimeSeries("5th percentile");
    TimeSeries p_95Wait = new TimeSeries("95th percentile");
    TimeSeries requests = new TimeSeries("Ride requests");

    try {
        bw.write("timebin;trips;average_wait;min;p_5;p_25;median;p_75;p_95;max");
        for (Entry<Double, List<DynModeTrip>> e : splitTrips.entrySet()) {
            long rides = 0;
            double averageWait = 0;
            double min = 0;
            double p_5 = 0;
            double p_25 = 0;
            double median = 0;
            double p_75 = 0;
            double p_95 = 0;
            double max = 0;
            if (!e.getValue().isEmpty()) {
                DescriptiveStatistics stats = new DescriptiveStatistics();
                for (DynModeTrip t : e.getValue()) {
                    stats.addValue(t.getWaitTime());
                }
                rides = stats.getN();
                averageWait = stats.getMean();
                min = stats.getMin();
                p_5 = stats.getPercentile(5);
                p_25 = stats.getPercentile(25);
                median = stats.getPercentile(50);
                p_75 = stats.getPercentile(75);
                p_95 = stats.getPercentile(95);
                max = stats.getMax();

            }
            Minute h = new Minute(sdf2.parse(Time.writeTime(e.getKey())));

            medianWait.addOrUpdate(h, Double.valueOf(median));
            averageWaitC.addOrUpdate(h, Double.valueOf(averageWait));
            p_5Wait.addOrUpdate(h, Double.valueOf(p_5));
            p_95Wait.addOrUpdate(h, Double.valueOf(p_95));
            requests.addOrUpdate(h, rides * 3600. / binsize_s);// normalised [req/h]
            bw.newLine();
            bw.write(Time.writeTime(e.getKey()) + ";" + rides + ";" + format.format(averageWait) + ";"
                    + format.format(min) + ";" + format.format(p_5) + ";" + format.format(p_25) + ";"
                    + format.format(median) + ";" + format.format(p_75) + ";" + format.format(p_95) + ";"
                    + format.format(max));

        }
        bw.flush();
        bw.close();
        dataset.addSeries(averageWaitC);
        dataset.addSeries(medianWait);
        dataset.addSeries(p_5Wait);
        dataset.addSeries(p_95Wait);
        datasetrequ.addSeries(requests);
        JFreeChart chart = chartProfile(splitTrips.size(), dataset, "Waiting times", "Wait time (s)");
        JFreeChart chart2 = chartProfile(splitTrips.size(), datasetrequ, "Ride requests per hour",
                "Requests per hour (req/h)");
        ChartSaveUtils.saveAsPNG(chart, fileName, 1500, 1000);
        ChartSaveUtils.saveAsPNG(chart2, fileName + "_requests", 1500, 1000);

    } catch (IOException | ParseException e) {

        e.printStackTrace();
    }

}

From source file:DashboardInterface.LaunchGraph.java

private XYDataset createDataset4(int offset) {
    long dateMili = 0L;

    TimeSeries s1 = new TimeSeries("");
    s1.add(new Second(new Date(dateMili)), 110);
    s1.add(new Second(new Date(dateMili + offset)), 110);
    TimeSeriesCollection dataset = new TimeSeriesCollection();
    dataset.addSeries(s1);//from ww  w.java2s  .co m

    return dataset;

}

From source file:org.adempiere.apps.graph.ChartBuilder.java

private void addData(MChartDatasource ds) {

    String value = ds.getValueColumn();
    String category;/*  w w w  .  j ava 2  s .  c o m*/
    String unit = "D";

    if (!chartModel.isTimeSeries())
        category = ds.getCategoryColumn();
    else {
        if (chartModel.getTimeUnit().equals(MChart.TIMEUNIT_Week)) {
            unit = "W";
        } else if (chartModel.getTimeUnit().equals(MChart.TIMEUNIT_Month)) {
            unit = "MM";
        } else if (chartModel.getTimeUnit().equals(MChart.TIMEUNIT_Quarter)) {
            unit = "Q";
        } else if (chartModel.getTimeUnit().equals(MChart.TIMEUNIT_Year)) {
            unit = "Y";
        }

        category = " TRUNC(" + ds.getDateColumn() + ", '" + unit + "') ";
    }

    String series = DB.TO_STRING(ds.getName());
    boolean hasSeries = false;
    if (ds.getSeriesColumn() != null) {
        series = ds.getSeriesColumn();
        hasSeries = true;
    }

    String where = ds.getWhereClause();
    if (!Util.isEmpty(where)) {
        where = Env.parseContext(Env.getCtx(), chartModel.getWindowNo(), where, true);
    }

    boolean hasWhere = false;

    String sql = "SELECT " + value + ", " + category + ", " + series + " FROM " + ds.getFromClause();
    if (!Util.isEmpty(where)) {
        sql += " WHERE " + where;
        hasWhere = true;
    }

    Date currentDate = Env.getContextAsDate(Env.getCtx(), "#Date");
    Date startDate = null;
    Date endDate = null;

    int scope = chartModel.getTimeScope();
    int offset = ds.getTimeOffset();

    if (chartModel.isTimeSeries() && scope != 0) {
        offset += -scope;
        startDate = increment(currentDate, chartModel.getTimeUnit(), offset);
        endDate = increment(startDate, chartModel.getTimeUnit(), scope);
    }

    if (startDate != null && endDate != null) {
        sql += hasWhere ? " AND " : " WHERE ";
        sql += category + ">=TRUNC(" + DB.TO_DATE(new Timestamp(startDate.getTime())) + ", '" + unit
                + "') AND ";
        sql += category + "<=TRUNC(" + DB.TO_DATE(new Timestamp(endDate.getTime())) + ", '" + unit + "') ";
    }

    if (sql.indexOf('@') >= 0) {
        sql = Env.parseContext(Env.getCtx(), 0, sql, false, true);
    }

    MRole role = MRole.getDefault(Env.getCtx(), false);
    sql = role.addAccessSQL(sql, null, true, false);

    if (hasSeries)
        sql += " GROUP BY " + series + ", " + category + " ORDER BY " + series + ", " + category;
    else
        sql += " GROUP BY " + category + " ORDER BY " + category;

    log.log(Level.FINE, sql);

    PreparedStatement pstmt = null;
    ResultSet rs = null;
    TimeSeries tseries = null;
    Dataset dataset = getDataset();

    try {
        pstmt = DB.prepareStatement(sql, null);
        rs = pstmt.executeQuery();
        while (rs.next()) {

            String key = rs.getString(2);
            String seriesName = rs.getString(3);
            if (seriesName == null)
                seriesName = ds.getName();
            String queryWhere = "";
            if (hasWhere)
                queryWhere += where + " AND ";

            queryWhere += series + " = " + DB.TO_STRING(seriesName) + " AND " + category + " = ";

            if (chartModel.isTimeSeries() && dataset instanceof TimeSeriesCollection) {

                if (tseries == null || !tseries.getKey().equals(seriesName)) {
                    if (tseries != null)
                        ((TimeSeriesCollection) dataset).addSeries(tseries);

                    tseries = new TimeSeries(seriesName);
                }

                Date date = rs.getDate(2);
                RegularTimePeriod period = null;

                if (chartModel.getTimeUnit().equals(MChart.TIMEUNIT_Day))
                    period = new Day(date);
                else if (chartModel.getTimeUnit().equals(MChart.TIMEUNIT_Week))
                    period = new Week(date);
                else if (chartModel.getTimeUnit().equals(MChart.TIMEUNIT_Month))
                    period = new Month(date);
                else if (chartModel.getTimeUnit().equals(MChart.TIMEUNIT_Quarter))
                    period = new Quarter(date);
                else if (chartModel.getTimeUnit().equals(MChart.TIMEUNIT_Year))
                    period = new Year(date);

                tseries.add(period, rs.getBigDecimal(1));
                key = period.toString();
                queryWhere += DB.TO_DATE(new Timestamp(date.getTime()));
            } else {
                queryWhere += DB.TO_STRING(key);
            }

            MQuery query = new MQuery(ds.getAD_Table_ID());
            String keyCol = MTable.get(Env.getCtx(), ds.getAD_Table_ID()).getKeyColumns()[0];
            String whereClause = keyCol + " IN (SELECT " + ds.getKeyColumn() + " FROM " + ds.getFromClause()
                    + " WHERE " + queryWhere + " )";
            query.addRestriction(whereClause.toString());
            query.setRecordCount(1);

            HashMap<String, MQuery> map = getQueries();

            if (dataset instanceof DefaultPieDataset) {
                ((DefaultPieDataset) dataset).setValue(key, rs.getBigDecimal(1));
                map.put(key, query);
            } else if (dataset instanceof DefaultCategoryDataset) {
                ((DefaultCategoryDataset) dataset).addValue(rs.getBigDecimal(1), seriesName, key);
                map.put(seriesName + "__" + key, query);
            } else if (dataset instanceof TimeSeriesCollection) {
                map.put(seriesName + "__" + key, query);
            }
        }
    } catch (SQLException e) {
        throw new DBException(e, sql);
    } finally {
        DB.close(rs, pstmt);
        rs = null;
        pstmt = null;
    }

    if (tseries != null)
        ((TimeSeriesCollection) dataset).addSeries(tseries);

}

From source file:org.jfree.data.time.TimeSeriesCollectionTest.java

/**
 * Some tests for the indexOf() method.//from  w  w w .  jav a2s. c om
 */
@Test
public void testIndexOf() {
    TimeSeries s1 = new TimeSeries("S1");
    TimeSeries s2 = new TimeSeries("S2");
    TimeSeriesCollection dataset = new TimeSeriesCollection();
    assertEquals(-1, dataset.indexOf(s1));
    assertEquals(-1, dataset.indexOf(s2));

    dataset.addSeries(s1);
    assertEquals(0, dataset.indexOf(s1));
    assertEquals(-1, dataset.indexOf(s2));

    dataset.addSeries(s2);
    assertEquals(0, dataset.indexOf(s1));
    assertEquals(1, dataset.indexOf(s2));

    dataset.removeSeries(s1);
    assertEquals(-1, dataset.indexOf(s1));
    assertEquals(0, dataset.indexOf(s2));

    TimeSeries s2b = new TimeSeries("S2");
    assertEquals(0, dataset.indexOf(s2b));
}

From source file:eu.planets_project.tb.impl.chart.ExperimentChartServlet.java

/**
 * Creates a sample time series chart./*  ww w .ja  v a 2 s .c  om*/
 *
 * @return a time series chart.
 */
private JFreeChart createTimeSeriesChart() {

    // here we just populate a series with random data...
    TimeSeries series = new TimeSeries("Random Data");
    Day current = new Day(1, MonthConstants.JANUARY, 2001);
    for (int i = 0; i < 100; i++) {
        series.add(current, Math.random() * 100);
        current = (Day) current.next();
    }

    XYDataset data = new TimeSeriesCollection(series);

    JFreeChart chart = ChartFactory.createTimeSeriesChart("Time Series Chart", "Date", "Rate", data, true, true,
            false);

    return chart;

}

From source file:ecg.ecgshow.ECGShowUI.java

private void createPressureData(long timeZone) {
    PressureData = new JPanel();
    PressuredateAxises = new DateAxis[1];
    SystolicPressureSeries = new TimeSeries[2];
    DiastolicPressureSeries = new TimeSeries[2];

    TimeSeriesCollection timeseriescollection = new TimeSeriesCollection();
    SystolicPressureSeries[0] = new TimeSeries("");
    SystolicPressureSeries[0].setMaximumItemAge(timeZone);
    SystolicPressureSeries[0].setMaximumItemCount(500);
    SystolicPressureSeries[1] = new TimeSeries("");
    SystolicPressureSeries[1].setMaximumItemAge(timeZone);
    SystolicPressureSeries[1].setMaximumItemCount(2);
    timeseriescollection.addSeries(SystolicPressureSeries[0]);
    timeseriescollection.addSeries(SystolicPressureSeries[1]);

    PressuredateAxises[0] = new DateAxis("");
    PressuredateAxises[0].setTickLabelFont(new Font("SansSerif", 0, (int) (HEIGHT * 0.016)));
    PressuredateAxises[0].setLabelFont(new Font("SansSerif", 0, (int) (HEIGHT * 0.018)));
    PressuredateAxises[0].setTickLabelsVisible(true);
    PressuredateAxises[0].setVisible(false);

    DiastolicPressureSeries[0] = new TimeSeries("");
    DiastolicPressureSeries[0].setMaximumItemAge(timeZone);
    DiastolicPressureSeries[0].setMaximumItemCount(500);
    DiastolicPressureSeries[1] = new TimeSeries("");
    DiastolicPressureSeries[1].setMaximumItemAge(timeZone);
    DiastolicPressureSeries[1].setMaximumItemCount(2);
    timeseriescollection.addSeries(DiastolicPressureSeries[0]);
    timeseriescollection.addSeries(DiastolicPressureSeries[1]);

    NumberAxis numberaxis = new NumberAxis("Pressure");
    numberaxis.setTickLabelFont(new Font("SansSerif", 0, (int) (HEIGHT * 0.016)));
    numberaxis.setLabelFont(new Font("SansSerif", 0, (int) (HEIGHT * 0.018)));
    numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    numberaxis.setVisible(false);/*  ww w  .j a v a 2 s  .  co  m*/
    numberaxis.setLowerBound(0D);
    numberaxis.setUpperBound(200D);

    XYLineAndShapeRenderer xylineandshaperenderer = new XYLineAndShapeRenderer(true, false);
    xylineandshaperenderer.setSeriesPaint(0, Color.GREEN); //
    xylineandshaperenderer.setSeriesStroke(0, new BasicStroke(2)); //
    xylineandshaperenderer.setSeriesPaint(1, Color.LIGHT_GRAY); //
    xylineandshaperenderer.setSeriesStroke(1, new BasicStroke(5));

    xylineandshaperenderer.setSeriesPaint(2, Color.ORANGE); //
    xylineandshaperenderer.setSeriesStroke(2, new BasicStroke(2)); //
    xylineandshaperenderer.setSeriesPaint(3, Color.LIGHT_GRAY); //
    xylineandshaperenderer.setSeriesStroke(3, new BasicStroke(5));

    //XYPlot xyplot = new XYPlot(timeseriescollection, PressuredateAxises[0], numberaxis, xylineandshaperenderer);
    XYPlot xyplot = new XYPlot(timeseriescollection, dateAxises[0], numberaxis, xylineandshaperenderer);

    xyplot.setBackgroundPaint(Color.LIGHT_GRAY);
    xyplot.setDomainGridlinePaint(Color.LIGHT_GRAY);
    xyplot.setRangeGridlinePaint(Color.LIGHT_GRAY);
    xyplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D));
    xyplot.setBackgroundPaint(Color.BLACK);

    JFreeChart jfreechart = new JFreeChart(xyplot);
    jfreechart.setBackgroundPaint(new Color(237, 237, 237));//?
    jfreechart.getLegend().setVisible(false);

    ChartPanel chartpanel = new ChartPanel(jfreechart, (int) (WIDTH * 0.155), (int) (HEIGHT * 0.18), 0, 0,
            Integer.MAX_VALUE, Integer.MAX_VALUE, true, true, false, true, false, false);

    chartpanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0) //??0
            , BorderFactory.createEmptyBorder() //????
    ));
    chartpanel.setMouseZoomable(false);
    PressureData.add(chartpanel);

}

From source file:com.jonas.testing.jfreechart.demos.DemoDatasetFactory.java

/**
 * Returns a time series of the daily USD/GBP exchange rates in 2001 (to date), for use in
 * the JFreeChart demonstration application.
 * <P>/*from w w  w. ja v a2s .  c  o  m*/
 * You wouldn't normally create a time series in this way.  Typically, values would
 * be read from a database.
 *
 * @return a time series.
 *
 */
public static TimeSeries createUSDTimeSeries() {

    final TimeSeries t1 = new TimeSeries("USD/GBP");
    try {
        t1.add(new Day(2, MonthConstants.JANUARY, 2001), 1.4956);
        t1.add(new Day(3, MonthConstants.JANUARY, 2001), new Double(1.5047));
        t1.add(new Day(4, MonthConstants.JANUARY, 2001), new Double(1.4931));
        t1.add(new Day(5, MonthConstants.JANUARY, 2001), new Double(1.4955));
        t1.add(new Day(8, MonthConstants.JANUARY, 2001), new Double(1.4994));
        t1.add(new Day(9, MonthConstants.JANUARY, 2001), new Double(1.4911));
        t1.add(new Day(10, MonthConstants.JANUARY, 2001), new Double(1.4903));
        t1.add(new Day(11, MonthConstants.JANUARY, 2001), new Double(1.4947));
        t1.add(new Day(12, MonthConstants.JANUARY, 2001), new Double(1.4784));
        t1.add(new Day(15, MonthConstants.JANUARY, 2001), new Double(1.4787));
        t1.add(new Day(16, MonthConstants.JANUARY, 2001), new Double(1.4702));
        t1.add(new Day(17, MonthConstants.JANUARY, 2001), new Double(1.4729));
        t1.add(new Day(18, MonthConstants.JANUARY, 2001), new Double(1.4760));
        t1.add(new Day(19, MonthConstants.JANUARY, 2001), new Double(1.4685));
        t1.add(new Day(22, MonthConstants.JANUARY, 2001), new Double(1.4609));
        t1.add(new Day(23, MonthConstants.JANUARY, 2001), new Double(1.4709));
        t1.add(new Day(24, MonthConstants.JANUARY, 2001), new Double(1.4576));
        t1.add(new Day(25, MonthConstants.JANUARY, 2001), new Double(1.4589));
        t1.add(new Day(26, MonthConstants.JANUARY, 2001), new Double(1.4568));
        t1.add(new Day(29, MonthConstants.JANUARY, 2001), new Double(1.4566));
        t1.add(new Day(30, MonthConstants.JANUARY, 2001), new Double(1.4604));
        t1.add(new Day(31, MonthConstants.JANUARY, 2001), new Double(1.4616));
        t1.add(new Day(1, MonthConstants.FEBRUARY, 2001), new Double(1.4777));
        t1.add(new Day(2, MonthConstants.FEBRUARY, 2001), new Double(1.4687));
        t1.add(new Day(5, MonthConstants.FEBRUARY, 2001), new Double(1.4753));
        t1.add(new Day(6, MonthConstants.FEBRUARY, 2001), new Double(1.4605));
        t1.add(new Day(7, MonthConstants.FEBRUARY, 2001), new Double(1.4619));
        t1.add(new Day(8, MonthConstants.FEBRUARY, 2001), new Double(1.4453));
        t1.add(new Day(9, MonthConstants.FEBRUARY, 2001), new Double(1.4463));
        t1.add(new Day(12, MonthConstants.FEBRUARY, 2001), new Double(1.4521));
        t1.add(new Day(13, MonthConstants.FEBRUARY, 2001), new Double(1.4517));
        t1.add(new Day(14, MonthConstants.FEBRUARY, 2001), new Double(1.4601));
        t1.add(new Day(15, MonthConstants.FEBRUARY, 2001), new Double(1.4500));
        t1.add(new Day(16, MonthConstants.FEBRUARY, 2001), new Double(1.4517));
        t1.add(new Day(19, MonthConstants.FEBRUARY, 2001), new Double(1.4459));
        t1.add(new Day(20, MonthConstants.FEBRUARY, 2001), new Double(1.4449));
        t1.add(new Day(21, MonthConstants.FEBRUARY, 2001), new Double(1.4447));
        t1.add(new Day(22, MonthConstants.FEBRUARY, 2001), new Double(1.4465));
        t1.add(new Day(23, MonthConstants.FEBRUARY, 2001), new Double(1.4487));
        t1.add(new Day(26, MonthConstants.FEBRUARY, 2001), new Double(1.4417));
        t1.add(new Day(27, MonthConstants.FEBRUARY, 2001), new Double(1.4420));
        t1.add(new Day(28, MonthConstants.FEBRUARY, 2001), new Double(1.4421));
        t1.add(new Day(1, MonthConstants.MARCH, 2001), new Double(1.4547));
        t1.add(new Day(2, MonthConstants.MARCH, 2001), new Double(1.4741));
        t1.add(new Day(5, MonthConstants.MARCH, 2001), new Double(1.4686));
        t1.add(new Day(6, MonthConstants.MARCH, 2001), new Double(1.4667));
        t1.add(new Day(7, MonthConstants.MARCH, 2001), new Double(1.4618));
        t1.add(new Day(8, MonthConstants.MARCH, 2001), new Double(1.4685));
        t1.add(new Day(9, MonthConstants.MARCH, 2001), new Double(1.4677));
        t1.add(new Day(12, MonthConstants.MARCH, 2001), new Double(1.4660));
        t1.add(new Day(13, MonthConstants.MARCH, 2001), new Double(1.4526));
        t1.add(new Day(14, MonthConstants.MARCH, 2001), new Double(1.4483));
        t1.add(new Day(15, MonthConstants.MARCH, 2001), new Double(1.4441));
        t1.add(new Day(16, MonthConstants.MARCH, 2001), new Double(1.4303));
        t1.add(new Day(19, MonthConstants.MARCH, 2001), new Double(1.4259));
        t1.add(new Day(20, MonthConstants.MARCH, 2001), new Double(1.4283));
        t1.add(new Day(21, MonthConstants.MARCH, 2001), new Double(1.4293));
        t1.add(new Day(22, MonthConstants.MARCH, 2001), new Double(1.4192));
        t1.add(new Day(23, MonthConstants.MARCH, 2001), new Double(1.4293));
        t1.add(new Day(26, MonthConstants.MARCH, 2001), new Double(1.4334));
        t1.add(new Day(27, MonthConstants.MARCH, 2001), new Double(1.4371));
        t1.add(new Day(28, MonthConstants.MARCH, 2001), new Double(1.4347));
        t1.add(new Day(29, MonthConstants.MARCH, 2001), new Double(1.4362));
        t1.add(new Day(30, MonthConstants.MARCH, 2001), new Double(1.4217));
        t1.add(new Day(2, MonthConstants.APRIL, 2001), new Double(1.4205));
        t1.add(new Day(3, MonthConstants.APRIL, 2001), new Double(1.4270));
        t1.add(new Day(4, MonthConstants.APRIL, 2001), new Double(1.4333));
        t1.add(new Day(5, MonthConstants.APRIL, 2001), new Double(1.4287));
        t1.add(new Day(6, MonthConstants.APRIL, 2001), new Double(1.4395));
        t1.add(new Day(9, MonthConstants.APRIL, 2001), new Double(1.4494));
        t1.add(new Day(10, MonthConstants.APRIL, 2001), new Double(1.4385));
        t1.add(new Day(11, MonthConstants.APRIL, 2001), new Double(1.4348));
        t1.add(new Day(12, MonthConstants.APRIL, 2001), new Double(1.4402));
        t1.add(new Day(17, MonthConstants.APRIL, 2001), new Double(1.4314));
        t1.add(new Day(18, MonthConstants.APRIL, 2001), new Double(1.4197));
        t1.add(new Day(19, MonthConstants.APRIL, 2001), new Double(1.4365));
        t1.add(new Day(20, MonthConstants.APRIL, 2001), new Double(1.4416));
        t1.add(new Day(23, MonthConstants.APRIL, 2001), new Double(1.4396));
        t1.add(new Day(24, MonthConstants.APRIL, 2001), new Double(1.4360));
        t1.add(new Day(25, MonthConstants.APRIL, 2001), new Double(1.4397));
        t1.add(new Day(26, MonthConstants.APRIL, 2001), new Double(1.4402));
        t1.add(new Day(27, MonthConstants.APRIL, 2001), new Double(1.4366));
        t1.add(new Day(30, MonthConstants.APRIL, 2001), new Double(1.4309));
        t1.add(new Day(1, MonthConstants.MAY, 2001), new Double(1.4324));
        t1.add(new Day(2, MonthConstants.MAY, 2001), new Double(1.4336));
        t1.add(new Day(3, MonthConstants.MAY, 2001), new Double(1.4329));
        t1.add(new Day(4, MonthConstants.MAY, 2001), new Double(1.4375));
        t1.add(new Day(8, MonthConstants.MAY, 2001), new Double(1.4321));
        t1.add(new Day(9, MonthConstants.MAY, 2001), new Double(1.4219));
        t1.add(new Day(10, MonthConstants.MAY, 2001), new Double(1.4226));
        t1.add(new Day(11, MonthConstants.MAY, 2001), new Double(1.4199));
        t1.add(new Day(14, MonthConstants.MAY, 2001), new Double(1.4183));
        t1.add(new Day(15, MonthConstants.MAY, 2001), new Double(1.4218));
        t1.add(new Day(16, MonthConstants.MAY, 2001), new Double(1.4295));
        t1.add(new Day(17, MonthConstants.MAY, 2001), new Double(1.4296));
        t1.add(new Day(18, MonthConstants.MAY, 2001), new Double(1.4296));
        t1.add(new Day(21, MonthConstants.MAY, 2001), new Double(1.4366));
        t1.add(new Day(22, MonthConstants.MAY, 2001), new Double(1.4283));
        t1.add(new Day(23, MonthConstants.MAY, 2001), new Double(1.4244));
        t1.add(new Day(24, MonthConstants.MAY, 2001), new Double(1.4102));
        t1.add(new Day(25, MonthConstants.MAY, 2001), new Double(1.4205));
        t1.add(new Day(29, MonthConstants.MAY, 2001), new Double(1.4183));
        t1.add(new Day(30, MonthConstants.MAY, 2001), new Double(1.4230));
        t1.add(new Day(31, MonthConstants.MAY, 2001), new Double(1.4201));
        t1.add(new Day(1, MonthConstants.JUNE, 2001), new Double(1.4148));
        t1.add(new Day(4, MonthConstants.JUNE, 2001), new Double(1.4142));
        t1.add(new Day(5, MonthConstants.JUNE, 2001), new Double(1.4095));
        t1.add(new Day(6, MonthConstants.JUNE, 2001), new Double(1.3938));
        t1.add(new Day(7, MonthConstants.JUNE, 2001), new Double(1.3886));
        t1.add(new Day(8, MonthConstants.JUNE, 2001), new Double(1.3798));
        t1.add(new Day(11, MonthConstants.JUNE, 2001), new Double(1.3726));
        t1.add(new Day(12, MonthConstants.JUNE, 2001), new Double(1.3788));
        t1.add(new Day(13, MonthConstants.JUNE, 2001), new Double(1.3878));
        t1.add(new Day(14, MonthConstants.JUNE, 2001), new Double(1.4002));
        t1.add(new Day(15, MonthConstants.JUNE, 2001), new Double(1.4033));
        t1.add(new Day(18, MonthConstants.JUNE, 2001), new Double(1.4038));
        t1.add(new Day(19, MonthConstants.JUNE, 2001), new Double(1.4023));
        t1.add(new Day(20, MonthConstants.JUNE, 2001), new Double(1.3952));
        t1.add(new Day(21, MonthConstants.JUNE, 2001), new Double(1.4142));
        t1.add(new Day(22, MonthConstants.JUNE, 2001), new Double(1.4114));
        t1.add(new Day(25, MonthConstants.JUNE, 2001), new Double(1.4141));
        t1.add(new Day(26, MonthConstants.JUNE, 2001), new Double(1.4157));
        t1.add(new Day(27, MonthConstants.JUNE, 2001), new Double(1.4136));
        t1.add(new Day(28, MonthConstants.JUNE, 2001), new Double(1.4089));
        t1.add(new Day(29, MonthConstants.JUNE, 2001), new Double(1.4066));
        t1.add(new Day(2, MonthConstants.JULY, 2001), new Double(1.4154));
        t1.add(new Day(3, MonthConstants.JULY, 2001), new Double(1.4072));
        t1.add(new Day(4, MonthConstants.JULY, 2001), new Double(1.4064));
        t1.add(new Day(5, MonthConstants.JULY, 2001), new Double(1.3995));
        t1.add(new Day(6, MonthConstants.JULY, 2001), new Double(1.4070));
        t1.add(new Day(9, MonthConstants.JULY, 2001), new Double(1.4094));
        t1.add(new Day(10, MonthConstants.JULY, 2001), new Double(1.4113));
        t1.add(new Day(11, MonthConstants.JULY, 2001), new Double(1.4143));
        t1.add(new Day(12, MonthConstants.JULY, 2001), new Double(1.4061));
        t1.add(new Day(13, MonthConstants.JULY, 2001), new Double(1.4008));
        t1.add(new Day(16, MonthConstants.JULY, 2001), new Double(1.3999));
        t1.add(new Day(17, MonthConstants.JULY, 2001), new Double(1.4003));
        t1.add(new Day(18, MonthConstants.JULY, 2001), new Double(1.4155));
        t1.add(new Day(19, MonthConstants.JULY, 2001), new Double(1.4165));
        t1.add(new Day(20, MonthConstants.JULY, 2001), new Double(1.4282));
        t1.add(new Day(23, MonthConstants.JULY, 2001), new Double(1.4190));
        t1.add(new Day(24, MonthConstants.JULY, 2001), new Double(1.4200));
        t1.add(new Day(25, MonthConstants.JULY, 2001), new Double(1.4276));
        t1.add(new Day(26, MonthConstants.JULY, 2001), new Double(1.4275));
        t1.add(new Day(27, MonthConstants.JULY, 2001), new Double(1.4233));
        t1.add(new Day(30, MonthConstants.JULY, 2001), new Double(1.4246));
        t1.add(new Day(31, MonthConstants.JULY, 2001), new Double(1.4254));
        t1.add(new Day(1, MonthConstants.AUGUST, 2001), new Double(1.4319));
        t1.add(new Day(2, MonthConstants.AUGUST, 2001), new Double(1.4321));
        t1.add(new Day(3, MonthConstants.AUGUST, 2001), new Double(1.4293));
        t1.add(new Day(6, MonthConstants.AUGUST, 2001), new Double(1.4190));
        t1.add(new Day(7, MonthConstants.AUGUST, 2001), new Double(1.4176));
        t1.add(new Day(8, MonthConstants.AUGUST, 2001), new Double(1.4139));
        t1.add(new Day(9, MonthConstants.AUGUST, 2001), new Double(1.4214));
        t1.add(new Day(10, MonthConstants.AUGUST, 2001), new Double(1.4266));
        t1.add(new Day(11, MonthConstants.AUGUST, 2001), new Double(1.4220));
        t1.add(new Day(12, MonthConstants.AUGUST, 2001), new Double(1.4210));
        t1.add(new Day(15, MonthConstants.AUGUST, 2001), new Double(1.4383));
        t1.add(new Day(16, MonthConstants.AUGUST, 2001), new Double(1.4431));
        t1.add(new Day(17, MonthConstants.AUGUST, 2001), new Double(1.4445));
        t1.add(new Day(20, MonthConstants.AUGUST, 2001), new Double(1.4444));
        t1.add(new Day(21, MonthConstants.AUGUST, 2001), new Double(1.4483));
        t1.add(new Day(22, MonthConstants.AUGUST, 2001), new Double(1.4556));
        t1.add(new Day(23, MonthConstants.AUGUST, 2001), new Double(1.4468));
        t1.add(new Day(24, MonthConstants.AUGUST, 2001), new Double(1.4464));
        t1.add(new Day(28, MonthConstants.AUGUST, 2001), new Double(1.4483));
        t1.add(new Day(29, MonthConstants.AUGUST, 2001), new Double(1.4519));
        t1.add(new Day(30, MonthConstants.AUGUST, 2001), new Double(1.4494));
        t1.add(new Day(31, MonthConstants.AUGUST, 2001), new Double(1.4505));
        t1.add(new Day(3, MonthConstants.SEPTEMBER, 2001), new Double(1.4519));
        t1.add(new Day(4, MonthConstants.SEPTEMBER, 2001), new Double(1.4460));
        t1.add(new Day(5, MonthConstants.SEPTEMBER, 2001), new Double(1.4526));
        t1.add(new Day(6, MonthConstants.SEPTEMBER, 2001), new Double(1.4527));
        t1.add(new Day(7, MonthConstants.SEPTEMBER, 2001), new Double(1.4617));
        t1.add(new Day(10, MonthConstants.SEPTEMBER, 2001), new Double(1.4583));
        t1.add(new Day(11, MonthConstants.SEPTEMBER, 2001), new Double(1.4693));
        t1.add(new Day(12, MonthConstants.SEPTEMBER, 2001), new Double(1.4633));
        t1.add(new Day(13, MonthConstants.SEPTEMBER, 2001), new Double(1.4690));
        t1.add(new Day(14, MonthConstants.SEPTEMBER, 2001), new Double(1.4691));
        t1.add(new Day(17, MonthConstants.SEPTEMBER, 2001), new Double(1.4668));
        t1.add(new Day(18, MonthConstants.SEPTEMBER, 2001), new Double(1.4624));
        t1.add(new Day(19, MonthConstants.SEPTEMBER, 2001), new Double(1.4678));
        t1.add(new Day(20, MonthConstants.SEPTEMBER, 2001), new Double(1.4657));
        t1.add(new Day(21, MonthConstants.SEPTEMBER, 2001), new Double(1.4575));
        t1.add(new Day(24, MonthConstants.SEPTEMBER, 2001), new Double(1.4646));
        t1.add(new Day(25, MonthConstants.SEPTEMBER, 2001), new Double(1.4699));
        t1.add(new Day(26, MonthConstants.SEPTEMBER, 2001), new Double(1.4749));
        t1.add(new Day(27, MonthConstants.SEPTEMBER, 2001), new Double(1.4756));
        t1.add(new Day(28, MonthConstants.SEPTEMBER, 2001), new Double(1.4699));
        t1.add(new Day(1, MonthConstants.OCTOBER, 2001), new Double(1.4784));
        t1.add(new Day(2, MonthConstants.OCTOBER, 2001), new Double(1.4661));
        t1.add(new Day(3, MonthConstants.OCTOBER, 2001), new Double(1.4767));
        t1.add(new Day(4, MonthConstants.OCTOBER, 2001), new Double(1.4770));
        t1.add(new Day(5, MonthConstants.OCTOBER, 2001), new Double(1.4810));
        t1.add(new Day(8, MonthConstants.OCTOBER, 2001), new Double(1.4743));
        t1.add(new Day(9, MonthConstants.OCTOBER, 2001), new Double(1.4667));
        t1.add(new Day(10, MonthConstants.OCTOBER, 2001), new Double(1.4505));
        t1.add(new Day(11, MonthConstants.OCTOBER, 2001), new Double(1.4434));
        t1.add(new Day(12, MonthConstants.OCTOBER, 2001), new Double(1.4504));
        t1.add(new Day(15, MonthConstants.OCTOBER, 2001), new Double(1.4471));
        t1.add(new Day(16, MonthConstants.OCTOBER, 2001), new Double(1.4474));
        t1.add(new Day(17, MonthConstants.OCTOBER, 2001), new Double(1.4512));
        t1.add(new Day(18, MonthConstants.OCTOBER, 2001), new Double(1.4445));
        t1.add(new Day(19, MonthConstants.OCTOBER, 2001), new Double(1.4384));
        t1.add(new Day(22, MonthConstants.OCTOBER, 2001), new Double(1.4275));
        t1.add(new Day(23, MonthConstants.OCTOBER, 2001), new Double(1.4212));
        t1.add(new Day(24, MonthConstants.OCTOBER, 2001), new Double(1.4233));
        t1.add(new Day(25, MonthConstants.OCTOBER, 2001), new Double(1.4297));
        t1.add(new Day(26, MonthConstants.OCTOBER, 2001), new Double(1.4328));
        t1.add(new Day(29, MonthConstants.OCTOBER, 2001), new Double(1.4515));
        t1.add(new Day(30, MonthConstants.OCTOBER, 2001), new Double(1.4564));
        t1.add(new Day(31, MonthConstants.OCTOBER, 2001), new Double(1.4541));
        t1.add(new Day(1, MonthConstants.NOVEMBER, 2001), new Double(1.4624));
        t1.add(new Day(2, MonthConstants.NOVEMBER, 2001), new Double(1.4632));
        t1.add(new Day(5, MonthConstants.NOVEMBER, 2001), new Double(1.4570));
        t1.add(new Day(6, MonthConstants.NOVEMBER, 2001), new Double(1.4588));
        t1.add(new Day(7, MonthConstants.NOVEMBER, 2001), new Double(1.4646));
        t1.add(new Day(8, MonthConstants.NOVEMBER, 2001), new Double(1.4552));
        t1.add(new Day(9, MonthConstants.NOVEMBER, 2001), new Double(1.4579));
        t1.add(new Day(12, MonthConstants.NOVEMBER, 2001), new Double(1.4575));
        t1.add(new Day(13, MonthConstants.NOVEMBER, 2001), new Double(1.4429));
        t1.add(new Day(14, MonthConstants.NOVEMBER, 2001), new Double(1.4425));
        t1.add(new Day(15, MonthConstants.NOVEMBER, 2001), new Double(1.4318));
        t1.add(new Day(16, MonthConstants.NOVEMBER, 2001), new Double(1.4291));
        t1.add(new Day(19, MonthConstants.NOVEMBER, 2001), new Double(1.4140));
        t1.add(new Day(20, MonthConstants.NOVEMBER, 2001), new Double(1.4173));
        t1.add(new Day(21, MonthConstants.NOVEMBER, 2001), new Double(1.4132));
        t1.add(new Day(22, MonthConstants.NOVEMBER, 2001), new Double(1.4131));
        t1.add(new Day(23, MonthConstants.NOVEMBER, 2001), new Double(1.4083));
        t1.add(new Day(26, MonthConstants.NOVEMBER, 2001), new Double(1.4122));
        t1.add(new Day(27, MonthConstants.NOVEMBER, 2001), new Double(1.4136));
        t1.add(new Day(28, MonthConstants.NOVEMBER, 2001), new Double(1.4239));
        t1.add(new Day(29, MonthConstants.NOVEMBER, 2001), new Double(1.4225));
        t1.add(new Day(30, MonthConstants.NOVEMBER, 2001), new Double(1.4260));
    } catch (Exception e) {
        System.err.println(e.getMessage());
    }
    return t1;
}