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

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

Introduction

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

Prototype

public TimeSeriesDataItem addOrUpdate(RegularTimePeriod period, Number value) 

Source Link

Document

Adds or updates an item in the times series and sends a SeriesChangeEvent to all registered listeners.

Usage

From source file:org.mwc.cmap.LiveDataMonitor.views.LiveDataMonitor.java

/**
 * a watchable item has been selected, better show it
 * //from  www . ja  v a2 s .co  m
 * @param attribute
 *          what we're going to watch
 */
private void storeDataset(final IAttribute attribute, final Object index) {
    final Vector<DataDoublet> data = attribute.getHistoricValues(index);

    // is there any data in it?
    if (data.size() == 0) {
        _chart.setTitle(attribute.getName());
        _chart.getXYPlot().setDataset(null);
    } else {
        final TimeSeriesCollection dataset = new TimeSeriesCollection();
        final TimeSeries series = new TimeSeries(attribute.getName());

        for (final Iterator<DataDoublet> iterator = data.iterator(); iterator.hasNext();) {
            final DataDoublet thisD = (DataDoublet) iterator.next();
            final Object thisVal = thisD.getValue();
            if (thisVal instanceof Number) {
                series.addOrUpdate(new Millisecond(new Date(thisD.getTime())), (Number) thisD.getValue());
            }
        }
        // did it work?
        if (!series.isEmpty()) {
            dataset.addSeries(series);
            _chart.getXYPlot().setDataset(dataset);
            _chart.setTitle(attribute.getName());
            _chart.getXYPlot().getRangeAxis().setLabel(attribute.getUnits());
        }
    }
}

From source file:com.hazelcast.monitor.server.MChartGenerator.java

@Override
protected void afterPlot(List<? super InstanceStatistics> list, JFreeChart chart, XYPlot plot) {
    NumberAxis sizeAxis = (NumberAxis) plot.getRangeAxis(0);
    Font labelFont = sizeAxis.getLabelFont();
    Paint labelPaint = sizeAxis.getLabelPaint();
    TimeSeries tm = new TimeSeries("memory");
    for (int i = 0; i < list.size(); i++) {
        double memory = 0;
        MapStatistics mapStatistics = (MapStatistics) list.get(i);
        for (MapStatistics.LocalMapStatistics localMapStatistics : mapStatistics.getListOfLocalStats()) {
            memory = memory + localMapStatistics.ownedEntryMemoryCost + localMapStatistics.backupEntryMemoryCost
                    + localMapStatistics.markedAsRemovedMemoryCost;
        }//from   w ww  .j  a v  a2s  . c o m
        double mem = new Double(memory / (double) (1024 * 1024));
        tm.addOrUpdate(new Second(((MapStatistics) list.get(i)).getCreatedDate()), mem);
    }
    NumberAxis memoryAxis = new NumberAxis("memory (MB)");
    memoryAxis.setAutoRange(true);
    memoryAxis.setAutoRangeIncludesZero(false);
    plot.setDataset(1, new TimeSeriesCollection(tm));
    plot.setRangeAxis(1, memoryAxis);
    plot.mapDatasetToRangeAxis(1, 1);
    plot.setRenderer(1, new StandardXYItemRenderer());
    plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);
    increaseRange(memoryAxis);
    memoryAxis.setLabelFont(labelFont);
    memoryAxis.setLabelPaint(labelPaint);
}

From source file:dbseer.gui.panel.DBSeerLiveMonitorPanel.java

public synchronized void setCurrentAverageLatency(long time, int index, double latency) {
    synchronized (LiveMonitorInfo.LOCK) {
        DefaultTableModel model = (DefaultTableModel) monitorTable.getModel();
        if (model.getRowCount() <= 2 + (index * ROW_PER_TX_TYPE + 1)) {
            model.addRow(new Object[] { "", "" });
        }//from www  .  ja va2 s  . c  om
        model.setValueAt(String.format("%.1f", latency), 2 + (index * ROW_PER_TX_TYPE) + 1, 1);
        if (numTransactionType < index + 1) {
            String newName = "Type " + (index + 1);
            transactionNames.add(newName);
            numTransactionType = index + 1;

            JLabel newLabel = new JLabel(newName);
            JButton renameButton = new JButton("Rename");
            JButton viewSampleButton = new JButton("View Examples");
            //            JButton enableDisableButton;
            //            if (DBSeerGUI.liveDataset.isTransactionEnabled(index))
            //            {
            //               enableDisableButton = new JButton("Disable");
            //            }
            //            else
            //            {
            //               enableDisableButton = new JButton("Enable");
            //            }

            renameButton.addActionListener(this);
            viewSampleButton.addActionListener(this);
            //            enableDisableButton.addActionListener(this);

            transactionTypesPanel.add(newLabel);
            transactionTypesPanel.add(renameButton);
            transactionTypesPanel.add(viewSampleButton);
            //            transactionTypesPanel.add(enableDisableButton);

            transactionLabels.add(newLabel);
            transactionRenameButtons.add(renameButton);
            transactionViewSampleButtons.add(viewSampleButton);
            //            transactionEnableDisableButtons.add(enableDisableButton);

            throughputCollection.addSeries(new TimeSeries(newName, Millisecond.class));
            latencyCollection.addSeries(new TimeSeries(newName, Millisecond.class));

            this.revalidate();
            this.repaint();
        }
        model.setValueAt(
                String.format("Current average latency of '%s' transactions", transactionNames.get(index)),
                2 + (index * ROW_PER_TX_TYPE) + 1, 0);

        if (index < latencyCollection.getSeriesCount()) {
            TimeSeries series = latencyCollection.getSeries(index);
            //            series.add(new Millisecond(), latency);
            series.addOrUpdate(new Millisecond(new Date(time * 1000)), latency);
        }
    }
}

From source file:dbseer.gui.panel.DBSeerLiveMonitorPanel.java

public synchronized void setCurrentTPS(long time, int index, double tps) {
    synchronized (LiveMonitorInfo.LOCK) {
        DefaultTableModel model = (DefaultTableModel) monitorTable.getModel();
        if (model.getRowCount() <= 2 + (index * ROW_PER_TX_TYPE)) {
            model.addRow(new Object[] { "", "" });
        }/*  ww  w.ja  va 2s  . c o  m*/
        model.setValueAt(String.format("%.1f", tps), 2 + (index * ROW_PER_TX_TYPE), 1);
        if (numTransactionType < index + 1) {
            String newName = "Type " + (index + 1);
            transactionNames.add(newName);
            numTransactionType = index + 1;

            JLabel newLabel = new JLabel(newName);
            JButton renameButton = new JButton("Rename");
            JButton viewSampleButton = new JButton("View Examples");
            //            JButton enableDisableButton;
            //            if (DBSeerGUI.liveDataset.isTransactionEnabled(index))
            //            {
            //               enableDisableButton = new JButton("Disable");
            //            }
            //            else
            //            {
            //               enableDisableButton = new JButton("Enable");
            //            }

            renameButton.addActionListener(this);
            viewSampleButton.addActionListener(this);
            //            enableDisableButton.addActionListener(this);

            transactionTypesPanel.add(newLabel);
            transactionTypesPanel.add(renameButton);
            transactionTypesPanel.add(viewSampleButton);
            //            transactionTypesPanel.add(enableDisableButton);

            transactionLabels.add(newLabel);
            transactionRenameButtons.add(renameButton);
            transactionViewSampleButtons.add(viewSampleButton);
            //            transactionEnableDisableButtons.add(enableDisableButton);

            for (DBSeerDataSet dataset : DBSeerGUI.liveDatasets) {
                dataset.addTransactionType("Type " + numTransactionType);
            }

            //         TimeSeriesCollection newThroughputCollection = new TimeSeriesCollection(new TimeSeries(newName, Millisecond.class));
            //         TimeSeriesCollection collection = (TimeSeriesCollection) throughputChartPanel.getChart().getXYPlot().getDataset();
            throughputCollection.addSeries(new TimeSeries(newName, Millisecond.class));
            latencyCollection.addSeries(new TimeSeries(newName, Millisecond.class));

            //         throughputChartPanel.getChart().getXYPlot().setDataset(index, newThroughputCollection);

            this.revalidate();
            this.repaint();
        }
        model.setValueAt(String.format("Current TPS of '%s' transactions", transactionNames.get(index)),
                2 + (index * ROW_PER_TX_TYPE), 0);

        //      TimeSeriesCollection collection = (TimeSeriesCollection) throughputChartPanel.getChart().getXYPlot().getDataset();
        if (index < throughputCollection.getSeriesCount()) {
            TimeSeries series = throughputCollection.getSeries(index);
            //            series.add(new Millisecond(), tps);
            series.addOrUpdate(new Millisecond(new Date(time * 1000)), tps);
        }
    }
}

From source file:ec.ui.view.RevisionSaSeriesView.java

private void addSeries(TimeSeriesCollection chartSeries, TsData data) {
    TimeSeries chartTs = new TimeSeries("");
    for (int i = 0; i < data.getDomain().getLength(); ++i) {
        if (DescriptiveStatistics.isFinite(data.get(i))) {
            Day day = new Day(data.getDomain().get(i).middle());
            chartTs.addOrUpdate(day, data.get(i));
        }//from   ww w.jav  a  2s .  c  o  m
    }
    chartSeries.addSeries(chartTs);
}

From source file:org.activequant.util.charting.Chart.java

/**
 * method to add a line series chart to the current chart. 
 * @param title// www  .j av  a 2s. c  o  m
 * @param dateAndValues
 */
public void addLineSeriesChart(String title, List<Tuple<TimeStamp, Double>> dateAndValues) {

    // creating a new jfree chart time series object. 
    final TimeSeries ts = new TimeSeries(title, Millisecond.class);

    // iterate over the incoming value tuples and add them.  
    for (Tuple<TimeStamp, Double> tuple : dateAndValues) {
        TimeSeriesDataItem item = new TimeSeriesDataItem(new Millisecond(tuple.getObject1().getDate()),
                tuple.getObject2());
        ts.addOrUpdate(item.getPeriod(), item.getValue());
    }

    datasets.add(ts);

    // 
    final TimeSeriesCollection dataset = new TimeSeriesCollection(ts);

    // add it to the chart plot. 
    final XYPlot plot1 = chart.getXYPlot();

    // disable all shape rendering. 
    final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer.setDrawOutlines(false);
    renderer.setUseOutlinePaint(false);
    renderer.setShapesVisible(false);
    // finally add the data set to chart 
    plot1.setDataset(datasets.size(), dataset);
    plot1.setRenderer(datasets.size(), renderer);
}

From source file:virgil.meanback.HistoryInfo.java

public XYDataset getDataSet(Stock stock, List<String[]> list) throws Exception {
    TimeSeriesCollection timeseriescollection = new TimeSeriesCollection();
    TimeSeries time1 = new TimeSeries("MD20");
    TimeSeries time2 = new TimeSeries("K");
    SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
    for (int i = 0; i < list.size(); i++) {
        String[] s = (String[]) list.get(i);
        Date d = format.parse(s[0]);
        Calendar cc = Calendar.getInstance();
        cc.setTime(d);/* w  w w .j  a  v  a  2s .  c  o m*/
        double db = Double.parseDouble(stock.getList().get(i).getClose());
        Day day = new Day(d);
        time1.addOrUpdate(day, db);
        double dayclose = Double.parseDouble(stock.getList().get(i).getClose());
        time2.addOrUpdate(day, dayclose);
    }
    timeseriescollection.addSeries(time1);
    timeseriescollection.addSeries(time2);
    return timeseriescollection;
}

From source file:LineChart.java

private static JFreeChart createDataset(JTable table) {
    TimeZone tz = TimeZone.getTimeZone("GMT");

    XYDataset ds = null;// w  ww .  j a v a 2 s . c  om

    if (table.getColumnCount() > 0) {
        Class klass = table.getColumnClass(0);

        if ((klass == Date.class) || (klass == Time.class) || (klass == c.Month.class)
                || (klass == c.Minute.class) || (klass == c.Second.class) || (klass == Timestamp.class)) {
            TimeSeriesCollection tsc = new TimeSeriesCollection();

            for (int col = 1; col < table.getColumnCount(); col++) {
                TimeSeries series = null;

                try {
                    if (klass == Date.class) {
                        series = new TimeSeries(table.getColumnName(col), Day.class);

                        for (int row = 0; row < table.getRowCount(); row++) {
                            Date date = (Date) table.getValueAt(row, 0);
                            Day day = new Day(date, tz);

                            Object o = table.getValueAt(row, col);
                            if (o instanceof Number) {
                                ((TimeSeries) series).addOrUpdate(day, (Number) table.getValueAt(row, col));
                            }
                        }
                    } else if (klass == Time.class) {
                        series = new TimeSeries(table.getColumnName(col), Millisecond.class);

                        for (int row = 0; row < table.getRowCount(); row++) {
                            Time time = (Time) table.getValueAt(row, 0);
                            Millisecond ms = new Millisecond(time, tz);

                            //    Millisecond ms = new Millisecond(time);
                            Object o = table.getValueAt(row, col);
                            if (o instanceof Number) {
                                series.addOrUpdate(ms, (Number) table.getValueAt(row, col));
                            }
                        }
                    } else if (klass == Timestamp.class) {
                        series = new TimeSeries(table.getColumnName(col), Millisecond.class);

                        for (int row = 0; row < table.getRowCount(); row++) {
                            Timestamp time = (Timestamp) table.getValueAt(row, 0);
                            Millisecond ms = new Millisecond(time, tz);

                            Object o = table.getValueAt(row, col);
                            if (o instanceof Number) {
                                series.addOrUpdate(ms, (Number) table.getValueAt(row, col));
                            }

                        }
                    } else if (klass == c.Month.class) {
                        series = new TimeSeries(table.getColumnName(col), Month.class);

                        for (int row = 0; row < table.getRowCount(); row++) {
                            c.Month time = (c.Month) table.getValueAt(row, 0);
                            int m = time.i + 24000;
                            int y = m / 12;
                            m = 1 + m % 12;

                            Month month = new Month(m, y);

                            Object o = table.getValueAt(row, col);
                            if (o instanceof Number) {
                                series.addOrUpdate(month, (Number) table.getValueAt(row, col));
                            }

                        }
                    } else if (klass == c.Second.class) {
                        series = new TimeSeries(table.getColumnName(col), Second.class);

                        for (int row = 0; row < table.getRowCount(); row++) {
                            c.Second time = (c.Second) table.getValueAt(row, 0);

                            Second second = new Second(time.i % 60, time.i / 60, 0, 1, 1, 2001);

                            Object o = table.getValueAt(row, col);
                            if (o instanceof Number) {
                                series.addOrUpdate(second, (Number) table.getValueAt(row, col));
                            }

                        }
                    } else if (klass == c.Minute.class) {
                        series = new TimeSeries(table.getColumnName(col), Minute.class);

                        for (int row = 0; row < table.getRowCount(); row++) {
                            c.Minute time = (c.Minute) table.getValueAt(row, 0);

                            Minute minute = new Minute(time.i % 60, time.i / 60, 1, 1, 2001);

                            Object o = table.getValueAt(row, col);
                            if (o instanceof Number) {
                                series.addOrUpdate(minute, (Number) table.getValueAt(row, col));
                            }
                        }
                    }
                } catch (SeriesException e) {
                    System.err.println("Error adding to series");
                }

                if (series.getItemCount() > 0)
                    tsc.addSeries(series);
            }

            ds = tsc;
        } else if ((klass == double.class) || (klass == int.class) || (klass == short.class)
                || (klass == long.class) || (klass == Time.class)) {
            XYSeriesCollection xysc = new XYSeriesCollection();

            for (int col = 1; col < table.getColumnCount(); col++) {
                XYSeries series = null;

                try {
                    series = new XYSeries(table.getColumnName(col));

                    for (int row = 0; row < table.getRowCount(); row++) {
                        Number x = (Number) table.getValueAt(row, 0);

                        Object y = table.getValueAt(row, col);
                        if (y instanceof Number) {
                            series.add(x, (Number) y);
                        }
                    }
                } catch (SeriesException e) {
                    System.err.println("Error adding to series");
                }

                if (series.getItemCount() > 0)
                    xysc.addSeries(series);
            }

            ds = xysc;
        }
    }

    if (ds != null) {
        boolean legend = false;

        if (ds.getSeriesCount() > 1) {
            legend = true;
        }

        if (ds instanceof XYSeriesCollection) {
            return ChartFactory.createXYLineChart("", "", "", ds, PlotOrientation.VERTICAL, legend, true, true);
        } else if (ds instanceof TimeSeriesCollection)
            return ChartFactory.createTimeSeriesChart("", "", "", ds, legend, true, true);
    }

    return null;
}

From source file:org.miloss.fgsms.services.rs.impl.reports.os.NetworkIOReport.java

@Override
public void generateReport(OutputStreamWriter data, List<String> urls, String path, List<String> files,
        TimeRange range, String currentuser, SecurityWrapper classification, WebServiceContext ctx)
        throws IOException {

    Connection con = Utility.getPerformanceDBConnection();
    try {/* ww w  .  j a va2 s .c  o m*/
        PreparedStatement cmd = null;
        ResultSet rs = null;
        DefaultCategoryDataset set = new DefaultCategoryDataset();
        JFreeChart chart = null;
        data.append("<hr /><h2>").append(GetDisplayName()).append("</h2>");
        data.append("This represents the network throughput rates of a machine over time.<br />");
        data.append(
                "<table class=\"table table-hover\"><tr><th>URI</th><th>Average Send Rate</th><th>Average Recieve Rate</th></tr>");

        TimeSeriesCollection col = new TimeSeriesCollection();
        for (int i = 0; i < urls.size(); i++) {
            if (!isPolicyTypeOf(urls.get(i), PolicyType.MACHINE)) {
                continue;
            }
            //https://github.com/mil-oss/fgsms/issues/112
            if (!UserIdentityUtil.hasReadAccess(currentuser, "getReport", urls.get(i), classification, ctx)) {
                continue;
            }
            String url = Utility.encodeHTML(BaseReportGenerator.getPolicyDisplayName(urls.get(i)));
            data.append("<tr><td>").append(url).append("</td>");
            double average = 0;
            try {
                cmd = con.prepareStatement(
                        "select avg(sendkbs) from rawdatanic where uri=? and utcdatetime > ? and utcdatetime < ?;");
                cmd.setString(1, urls.get(i));
                cmd.setLong(2, range.getStart().getTimeInMillis());
                cmd.setLong(3, range.getEnd().getTimeInMillis());
                rs = cmd.executeQuery();

                if (rs.next()) {
                    average = rs.getDouble(1);

                }
            } catch (Exception ex) {
                log.log(Level.WARN, null, ex);
            } finally {
                DBUtils.safeClose(rs);
                DBUtils.safeClose(cmd);
            }

            data.append("<td>").append(average + "").append("</td>");
            average = 0;
            try {
                cmd = con.prepareStatement(
                        "select avg(receivekbs) from rawdatanic where uri=? and utcdatetime > ? and utcdatetime < ?;");
                cmd.setString(1, urls.get(i));
                cmd.setLong(2, range.getStart().getTimeInMillis());
                cmd.setLong(3, range.getEnd().getTimeInMillis());
                rs = cmd.executeQuery();

                if (rs.next()) {
                    average = rs.getDouble(1);

                }
            } catch (Exception ex) {
                log.log(Level.WARN, null, ex);
            } finally {
                DBUtils.safeClose(rs);
                DBUtils.safeClose(cmd);
            }
            data.append("<td>").append(average + "").append("</td></tr>");

            //ok now get the raw data....
            TimeSeriesContainer tsc = new TimeSeriesContainer();
            try {
                cmd = con.prepareStatement(
                        "select receivekbs, sendkbs, utcdatetime, nicid from rawdatanic where uri=? and utcdatetime > ? and utcdatetime < ?;");
                cmd.setString(1, urls.get(i));
                cmd.setLong(2, range.getStart().getTimeInMillis());
                cmd.setLong(3, range.getEnd().getTimeInMillis());
                rs = cmd.executeQuery();

                while (rs.next()) {

                    TimeSeries ts = tsc.Get(url + " " + rs.getString("nicid") + " RX", Millisecond.class);
                    TimeSeries ts2 = tsc.Get(url + " " + rs.getString("nicid") + " TX", Millisecond.class);
                    GregorianCalendar gcal = new GregorianCalendar();
                    gcal.setTimeInMillis(rs.getLong(3));
                    Millisecond m = new Millisecond(gcal.getTime());
                    ts.addOrUpdate(m, rs.getLong(1));
                    ts2.addOrUpdate(m, rs.getLong(2));
                }
            } catch (Exception ex) {
                log.log(Level.WARN, null, ex);
            } finally {
                DBUtils.safeClose(rs);
                DBUtils.safeClose(cmd);
            }
            for (int ik = 0; ik < tsc.data.size(); ik++) {
                col.addSeries(tsc.data.get(ik));
            }

        }

        chart = org.jfree.chart.ChartFactory.createTimeSeriesChart(GetDisplayName(), "Timestamp", "Rate", col,
                true, false, false);

        data.append("</table>");
        try {
            // if (set.getRowCount() != 0) {
            ChartUtilities.saveChartAsPNG(new File(
                    path + getFilePathDelimitor() + "image_" + this.getClass().getSimpleName() + ".png"), chart,
                    1500, 400);
            data.append("<img src=\"image_").append(this.getClass().getSimpleName()).append(".png\">");
            files.add(path + getFilePathDelimitor() + "image_" + this.getClass().getSimpleName() + ".png");
            // }
        } catch (IOException ex) {
            log.log(Level.ERROR, "Error saving chart image for request", ex);
        }
    } catch (Exception ex) {
        log.log(Level.ERROR, null, ex);
    } finally {
        DBUtils.safeClose(con);
    }

}

From source file:org.miloss.fgsms.services.rs.impl.reports.broker.ConsumersByQueueOrTopic.java

@Override
public void generateReport(OutputStreamWriter data, List<String> urls, String path, List<String> files,
        TimeRange range, String currentuser, SecurityWrapper classification, WebServiceContext ctx)
        throws IOException {

    Connection con = Utility.getPerformanceDBConnection();
    try {/*from w w  w. j av a 2s . c  om*/
        PreparedStatement cmd = null;
        ResultSet rs = null;
        DefaultCategoryDataset set = new DefaultCategoryDataset();
        JFreeChart chart = null;

        data.append("<hr /><h2>").append(GetDisplayName()).append("</h2>");
        data.append(
                "This represents the average number of consumers for all channels (topics/queues/etc) on a specific message broker.<br />");
        data.append(
                "<table class=\"table table-hover\"><tr><th>URI</th><th>Channel</th><th>Average Consumer Count</th></tr>");

        TimeSeriesCollection col = new TimeSeriesCollection();
        for (int i = 0; i < urls.size(); i++) {
            if (!isPolicyTypeOf(urls.get(i), PolicyType.STATISTICAL)) {
                continue;
            }
            //https://github.com/mil-oss/fgsms/issues/112
            if (!UserIdentityUtil.hasReadAccess(currentuser, "getReport", urls.get(i), classification, ctx)) {
                continue;
            }
            String url = Utility.encodeHTML(BaseReportGenerator.getPolicyDisplayName(urls.get(i)));
            try {
                data.append("<tr><td>").append(Utility.encodeHTML(urls.get(i))).append("</td>");
                double average = 0;
                try {
                    cmd = con.prepareStatement(
                            "select avg(activeconsumercount), host, canonicalname from brokerhistory where host=? and utcdatetime > ? and utcdatetime < ? group by canonicalname, host;");
                    cmd.setString(1, urls.get(i));
                    cmd.setLong(2, range.getStart().getTimeInMillis());
                    cmd.setLong(3, range.getEnd().getTimeInMillis());
                    rs = cmd.executeQuery();

                    if (rs.next()) {
                        average = rs.getDouble(1);

                    }
                } catch (Exception ex) {
                    log.log(Level.WARN, null, ex);
                } finally {
                    DBUtils.safeClose(rs);
                    DBUtils.safeClose(cmd);
                }

                data.append("<td>").append(average + "").append("</td>");

                try {
                    //ok now get the raw data....
                    cmd = con.prepareStatement(
                            "select utcdatetime,activeconsumercount, canonicalname from brokerhistory where host=? and utcdatetime > ? and utcdatetime < ?;");
                    cmd.setString(1, urls.get(i));
                    cmd.setLong(2, range.getStart().getTimeInMillis());
                    cmd.setLong(3, range.getEnd().getTimeInMillis());
                    rs = cmd.executeQuery();
                    TimeSeries ts = new TimeSeries(urls.get(i), Millisecond.class);
                    while (rs.next()) {

                        //set.addValue(rs.getLong(1), urls.get(i), rs.getString("canonicalname"));
                        GregorianCalendar gcal = new GregorianCalendar();
                        gcal.setTimeInMillis(rs.getLong(1));
                        Millisecond m = new Millisecond(gcal.getTime());

                        ts.addOrUpdate(m, rs.getLong(2));

                    }
                    col.addSeries(ts);
                } catch (Exception ex) {
                    log.log(Level.WARN, null, ex);
                } finally {
                    DBUtils.safeClose(rs);
                    DBUtils.safeClose(cmd);
                }

            } catch (Exception ex) {
                log.log(Level.ERROR, "Error opening or querying the database.", ex);
            }

        }
        chart = org.jfree.chart.ChartFactory.createTimeSeriesChart(GetDisplayName(), "Timestamp", "Count", col,
                true, false, false);

        data.append("</table>");
        try {
            ChartUtilities.saveChartAsPNG(new File(
                    path + getFilePathDelimitor() + "image_" + this.getClass().getSimpleName() + ".png"), chart,
                    1500, 400);
            data.append("<img src=\"image_").append(this.getClass().getSimpleName()).append(".png\">");
            files.add(path + getFilePathDelimitor() + "image_" + this.getClass().getSimpleName() + ".png");
        } catch (IOException ex) {
            log.log(Level.ERROR, "Error saving chart image for request", ex);
        }
    } catch (Exception ex) {
        log.log(Level.ERROR, null, ex);
    } finally {
        DBUtils.safeClose(con);
    }
}