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:grafici.FattureTimeSeriesChart.java

/**
 * Creates a dataset, consisting of two series of monthly data.
 * /*www .  j a  v  a  2  s . c o m*/
 * @return The dataset.
 */
private static XYDataset createDataset(int tipo) {
    TimeSeriesCollection dataset = new TimeSeriesCollection();
    ArrayList<Fattura> list = FatturaDAO.getFatture();
    try {
        for (Fattura item : list) {
            TimeSeries s1 = new TimeSeries("Serie");
            s1.add(new Month(item.getData().getMonth() + 1, item.getData().getYear() + 1900),
                    item.getImporto());
            dataset.addSeries(s1);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return dataset;

}

From source file:edu.unibonn.plotting.TimeSeriesPlotter_Sensors.java

private XYDataset createDataset(ArrayList<Cluster_KMeans> clusters, LocalDateTime from) {
    final TimeSeriesCollection dataset = new TimeSeriesCollection();

    for (int i = 0; i < clusters.size(); i++) {
        Cluster_KMeans current_cluster = clusters.get(i);
        ArrayList<Sensor> member_time_series = current_cluster.getMembership();

        for (Iterator iterator = member_time_series.iterator(); iterator.hasNext();) {
            final TimeSeries s1 = new TimeSeries("Cluster_" + current_cluster.getCluster_id(), Hour.class);

            Sensor current_series = (Sensor) iterator.next();

            for (int j = 0; j < current_series.getDimensions(); j++) {
                LocalDateTime current_record_time = current_series.getInitial_record_time().plusHours(j);
                s1.add(new Hour(current_record_time.getHour(), current_record_time.getDayOfMonth(),
                        current_record_time.getMonthValue(), current_record_time.getYear()),
                        current_series.getMeasurement(j));
            }//from   w w  w  .ja  v a  2  s. com

            dataset.addSeries(s1);
        }
    }

    dataset.setDomainIsPointsInTime(true);

    return dataset;
}

From source file:com.jbombardier.reports.OldReportGenerator.java

public void generate(Map<InetSocketAddress, ResultsPackage> agentResults, File reportsDir) {
    Chunker chunker = new Chunker();

    Log.set(Log.LEVEL_DEBUG);/*from   ww  w. jav  a 2  s .  c o m*/

    Set<String> totalsTransactionNames = new HashSet<String>();
    Set<String> perAgentTransactionNames = new HashSet<String>();
    Set<String> perAgentPerThreadTransactionNames = new HashSet<String>();
    Set<String> agentStrings = new HashSet<String>();

    Set<InetSocketAddress> keySet = agentResults.keySet();
    for (InetSocketAddress inetSocketAddress : keySet) {
        String agentString = inetSocketAddress.getHostName();
        Log.debug("Process result from agent " + agentString);
        agentStrings.add(agentString);

        ResultsPackage resultsPerThread = agentResults.get(inetSocketAddress);

        Set<String> threadNames = resultsPerThread.getThreadResults().keySet();
        for (String threadName : threadNames) {
            Log.debug("Processing result for thread name ", threadName);
            ThreadResults results = resultsPerThread.getThreadResults().get(threadName);

            Set<String> transactionIDs = results.keySet();
            for (String transactionID : transactionIDs) {
                Log.debug("Processing transactionID '" + transactionID + "'");
                String agentKey = agentString + "." + transactionID + ".elapsed";
                String agentThreadKey = agentString + "." + threadName + "." + transactionID + ".elapsed";
                String totalKey = "total." + transactionID + ".elapsed";

                totalsTransactionNames.add(totalKey);
                perAgentTransactionNames.add(agentKey);
                perAgentPerThreadTransactionNames.add(agentThreadKey);

                AggregatedResultSeries aggregatedResultSeries = results.get(transactionID);
                List<AggregatedResult> aggregatedResults = aggregatedResultSeries.getResults();
                for (AggregatedResult result : aggregatedResults) {
                    Log.debug(result.toString());
                    chunker.onNewResult(agentKey, result.time, result.mean() * 1e-6f);
                    chunker.onNewResult(totalKey, result.time, result.mean() * 1e-6f);
                }
            }
        }
    }

    // The first chart is the [all agents, all threads, all transactions] mean transaction time chart
    TimeSeriesCollection timeSeriesCollection = extractTimeSeries(chunker, totalsTransactionNames,
            Statistic.Mean);
    render("All transactions mean per second elapsed times", timeSeriesCollection,
            new File(reportsDir, "all.transactions.elapsed.png"));

    // The second chart is the [all agents, all threads, all transactions] transaction count chart
    timeSeriesCollection = extractTimeSeries(chunker, totalsTransactionNames, Statistic.Count);
    render("All transactions per second counts", timeSeriesCollection,
            new File(reportsDir, "all.transactions.count.png"));

    // Now lets do the same for each agent
    for (final String agent : agentStrings) {
        TimeSeriesCollection agentTimeSeriesCollection = new TimeSeriesCollection();
        for (String perAgentPerThreadTransactionName : perAgentTransactionNames) {
            if (perAgentPerThreadTransactionName.startsWith(agent)) {
                List<Chunk> timeOrderedResults = chunker
                        .getTimeOrderedResults(perAgentPerThreadTransactionName);
                TimeSeries extractTimeSeries = extractTimeSeries(timeOrderedResults,
                        perAgentPerThreadTransactionName, Statistic.Mean);
                agentTimeSeriesCollection.addSeries(extractTimeSeries);
            }
        }

        render(agent + " transactions mean per second elapsed times", agentTimeSeriesCollection,
                new File(reportsDir, agent + ".transactions.elapsed.png"));
    }

    // Lets have a stab at writing out some csv stuff
    writePerSecondResults(reportsDir, chunker, totalsTransactionNames);
}

From source file:grafici.MediciTimeSeriesChart.java

/**
 * Creates a dataset, consisting of two series of monthly data.
 * /*w w  w  .  j a  v  a  2s.  c  o  m*/
 * @return The dataset.
 */
private static XYDataset createDataset(int tipo) {
    TimeSeriesCollection dataset = new TimeSeriesCollection();
    System.out.println("medico time graph");
    // anno 2010
    try {
        TimeSeries s1 = new TimeSeries("2010");
        for (Object item : MedicoDAO.getPrestazioni(2010)) {
            Prestazione item1 = (Prestazione) ((Object[]) item)[0];
            if (s1.getDataItem(new Day(item1.getId().getDataTurno())) == null)
                s1.addOrUpdate(new Day(item1.getId().getDataTurno()), 1);
            else
                s1.addOrUpdate(new Day(item1.getId().getDataTurno()),
                        s1.getDataItem(new Day(item1.getId().getDataTurno())).getValue().intValue() + 1);

        }
        dataset.addSeries(s1);
    } catch (Exception e) {
        e.printStackTrace();
    }
    return dataset;

}

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

private void initialize() {
    JScrollPane tableScrollPane = new JScrollPane(monitorTable);
    tableScrollPane.setPreferredSize(new Dimension(300, 300));
    JScrollPane transactionTypesScrollPane = new JScrollPane();
    leftDockPanel = new JPanel();
    leftDockPanel.setLayout(new MigLayout("fill"));
    transactionTypesPanel = new JPanel();
    transactionTypesPanel.setLayout(new MigLayout("wrap 3"));
    rightPanel = new JPanel();
    rightPanel.setLayout(new MigLayout("fill"));
    rightPanel.setPreferredSize(new Dimension(640, 480));

    transactionTypesScrollPane.setViewportView(transactionTypesPanel);
    transactionTypesScrollPane.setBorder(BorderFactory.createTitledBorder("Transaction types"));
    transactionTypesScrollPane.setPreferredSize(new Dimension(360, 300));

    throughputCollection = new TimeSeriesCollection();
    throughputChartPanel = new ChartPanel(createThroughputChart(throughputCollection));

    latencyCollection = new TimeSeriesCollection();
    latencyChartPanel = new ChartPanel(createAverageLatencyChart(latencyCollection));

    leftDockPanel.add(tableScrollPane, "wrap, grow");
    leftDockPanel.add(transactionTypesScrollPane, "grow");

    rightPanel.add(throughputChartPanel, "grow, wrap");
    rightPanel.add(latencyChartPanel, "grow");

    this.add(leftDockPanel, "dock west, growy");
    this.add(rightPanel, "grow");
}

From source file:org.jtotus.gui.graph.GraphPrinter.java

private XYPlot createSubPlot(String plotName, GraphSeriesType type) {

    final TimeSeriesCollection collection = new TimeSeriesCollection();
    final NumberAxis range = new NumberAxis("Value");
    final XYPlot newSubPlot = new XYPlot(collection, null, range, this.getRenderer(type));

    newSubPlot.setDomainCrosshairVisible(true);
    newSubPlot.setRangeCrosshairVisible(true);
    newSubPlot.setDomainGridlinesVisible(true);

    if (!plotMap.containsKey(plotName)) {
        plotMap.put(plotName, newSubPlot);
        mainPlot.add(newSubPlot);/*from   w  w  w.  jav a2  s . c  o  m*/
        return newSubPlot;
    }

    return null;
}

From source file:in.BBAT.presenter.DualAxisDemo2.java

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

    final TimeSeries s1 = new TimeSeries("CPU", Millisecond.class);
    for (CpuUsageEntity ent : ScreenShotView.testCase.getCpuUsageValues()) {
        s1.addOrUpdate(new Millisecond(new Date(ent.getTime())), ent.getPercent());
    }

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

    return dataset;

}

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

private static XYDataset createDataset() {
    TimeSeries timeseries = new TimeSeries("US$ Treasury Yields");
    Day day = new Day(1, 12, 2005);
    Day day1 = new Day(1, 2, 2006);
    Day day2 = new Day(1, 5, 2006);
    Day day3 = new Day(1, 12, 2006);
    Day day4 = new Day(1, 12, 2007);
    Day day5 = new Day(1, 12, 2008);
    Day day6 = new Day(1, 12, 2010);
    Day day7 = new Day(1, 12, 2012);
    Day day8 = new Day(1, 12, 2015);
    Day day9 = new Day(1, 12, 2025);
    timeseries.add(day, 3.79D);/*  www.ja  v  a2 s  .c  om*/
    timeseries.add(day1, 3.9950000000000001D);
    timeseries.add(day2, 4.2599999999999998D);
    timeseries.add(day3, 4.3224999999999998D);
    timeseries.add(day4, 4.4474999999999998D);
    timeseries.add(day5, 4.4749999999999996D);
    timeseries.add(day6, 4.5199999999999996D);
    timeseries.add(day7, 4.5599999999999996D);
    timeseries.add(day8, 4.625D);
    timeseries.add(day9, 4.9050000000000002D);
    TimeSeriesCollection timeseriescollection = new TimeSeriesCollection();
    timeseriescollection.addSeries(timeseries);
    return timeseriescollection;
}

From source file:tools.descartes.bungee.chart.ChartGenerator.java

public static JFreeChart allocationChart(List<ResourceAllocation> allocations) {
    final TimeSeriesCollection dataset = new TimeSeriesCollection();
    final TimeSeries series = createTimeSeries(allocations, "Resource Allocation");
    dataset.addSeries(series);//w  w w. jav a 2s .  c o m
    return createTimeSeriesChart(createAllocationPlot(dataset));
}

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);//from  www .j  av  a2 s.  co 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;
}