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.softinica.maven.jmeter.report.analyser.ResponseSizeAnalyzer.java

@Override
protected JFreeChart createChart(PageDefinition definition, Input input) {
    Map<String, Map<Long, Long>> allSeries = new HashMap<String, Map<Long, Long>>();
    for (Sample sample : input.getSamples()) {
        Map<Long, Long> duration = allSeries.get(sample.getLabel());
        if (duration == null) {
            duration = new HashMap<Long, Long>();
            allSeries.put(sample.getLabel(), duration);
        }//from  w ww.  j  a  v  a 2 s .  c o m
        duration.put((sample.getTimestamp() + (long) sample.getValue()), (long) sample.getByteCount());
    }
    TimeSeriesCollection dataset = new TimeSeriesCollection();
    for (String label : allSeries.keySet()) {
        Map<Long, Long> duration = allSeries.get(label);
        TimeSeries series = new TimeSeries(label);
        for (Long key : duration.keySet()) {
            series.addOrUpdate(new Millisecond(new Date(key)), duration.get(key));
        }
        dataset.addSeries(series);
    }

    return ChartFactory.createTimeSeriesChart(definition.getTitle(), "Time", "Size(bytes)", dataset);
}

From source file:net.sf.statcvs.output.xml.chart.TimeLineChart.java

/**
 * @param filename//from w  ww  .ja  v a  2s  .  co  m
 * @param title
 */
public TimeLineChart(String filename, String title) {
    super(filename, title);

    Paint[] colors = new Paint[1];
    colors[0] = Color.blue;

    tsc = new TimeSeriesCollection();
    //collection.addSeries(createTimeSeries(timeline));

    //String range = timeline.getRangeLabel();
    String domain = I18n.tr("Date");

    setChart(ChartFactory.createTimeSeriesChart(Settings.getProjectName(), I18n.tr("Date"), rangeLabel,
            (XYDataset) tsc, true, true, false));

    //getChart().getPlot().setSeriesPaint(colors);

    XYPlot plot = getChart().getXYPlot();
    ValueAxis axis = plot.getDomainAxis();
    axis.setVerticalTickLabels(true);
    plot.setRenderer(new XYStepRenderer());
}

From source file:org.softinica.maven.jmeter.report.analyser.RequestDurationAnalyzer.java

@Override
protected JFreeChart createChart(PageDefinition definition, Input input) {
    Map<String, Map<Long, Long>> allSeries = new HashMap<String, Map<Long, Long>>();
    for (Sample sample : input.getSamples()) {
        Map<Long, Long> duration = allSeries.get(sample.getLabel());
        if (duration == null) {
            duration = new HashMap<Long, Long>();
            allSeries.put(sample.getLabel(), duration);
        }//from   www  .  j a  va2s  .  c o m
        duration.put((sample.getTimestamp() + (long) sample.getValue()), (long) sample.getValue());
    }
    TimeSeriesCollection dataset = new TimeSeriesCollection();
    for (String label : allSeries.keySet()) {
        Map<Long, Long> duration = allSeries.get(label);
        TimeSeries series = new TimeSeries(label);
        for (Long key : duration.keySet()) {
            series.addOrUpdate(new Millisecond(new Date(key)), duration.get(key));
        }
        dataset.addSeries(series);
    }

    return ChartFactory.createTimeSeriesChart(definition.getTitle(), "Time", "Duration", dataset);
}

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

private static IntervalXYDataset createDataset() {
    TimeSeries timeseries = new TimeSeries("Completion");
    timeseries.add(new Day(19, 1, 2007), 3343000D);
    timeseries.add(new Day(20, 1, 2007), 3420000D);
    timeseries.add(new Day(21, 1, 2007), 3515000D);
    timeseries.add(new Day(22, 1, 2007), 3315000D);
    timeseries.add(new Day(23, 1, 2007), 3490000D);
    timeseries.add(new Day(24, 1, 2007), 3556000D);
    timeseries.add(new Day(25, 1, 2007), 3383000D);
    timeseries.add(new Day(26, 1, 2007), 3575000D);
    TimeSeriesCollection timeseriescollection = new TimeSeriesCollection();
    timeseriescollection.addSeries(timeseries);
    return timeseriescollection;
}

From source file:net.sf.profiler4j.console.AllocDiffPanel.java

public AllocDiffPanel(int maxAgeMillis) {
    super(new BorderLayout());

    totalSeries = new TimeSeries("Allocs/Sec", Millisecond.class);
    totalSeries.setMaximumItemAge(maxAgeMillis);

    TimeSeriesCollection seriesCollection = new TimeSeriesCollection();
    seriesCollection.addSeries(totalSeries);

    NumberAxis numberAxis = new NumberAxis("Allocs/Sec");
    numberAxis.setLabelFont(new Font("SansSerif", 0, 14));
    numberAxis.setTickLabelFont(new Font("SansSerif", 0, 12));
    numberAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    DateAxis dateAxis = new DateAxis("Time");
    dateAxis.setTickLabelFont(new Font("SansSerif", 0, 12));
    dateAxis.setLabelFont(new Font("SansSerif", 0, 14));
    dateAxis.setAutoRange(true);/*from w w  w  .  j  a  v a2s .c om*/
    dateAxis.setLowerMargin(0);
    dateAxis.setUpperMargin(0);
    dateAxis.setTickLabelsVisible(true);
    dateAxis.setDateFormatOverride(new SimpleDateFormat("HH:mm:ss"));

    XYLineAndShapeRenderer lineRenderer = new XYLineAndShapeRenderer(true, false);
    lineRenderer.setSeriesPaint(0, Color.RED);
    lineRenderer.setSeriesPaint(1, Color.GREEN.darker());
    lineRenderer.setStroke(new BasicStroke(2F, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND));

    XYPlot xyplot = new XYPlot(seriesCollection, dateAxis, numberAxis, lineRenderer);
    xyplot.setBackgroundPaint(Color.WHITE);
    xyplot.setDomainGridlinePaint(Color.LIGHT_GRAY);
    xyplot.setRangeGridlinePaint(Color.LIGHT_GRAY);
    xyplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D));

    JFreeChart chart = new JFreeChart("Object Allocactions in Remote JVM",
            new Font("SansSerif", Font.PLAIN, 18), xyplot, true);
    chart.setBackgroundPaint(Color.white);

    ChartPanel panel = new ChartPanel(chart);
    panel.setBorder(createCompoundBorder(createEmptyBorder(8, 8, 8, 8), createLineBorder(Color.LIGHT_GRAY)));
    add(panel);
    setBorder(createEmptyBorder(8, 8, 8, 8));
}

From source file:org.softinica.maven.jmeter.report.analyser.ThroughputAnalyzer.java

@Override
protected JFreeChart createChart(PageDefinition definition, Input input) {
    Map<String, Multiset<Long>> allSeries = new HashMap<String, Multiset<Long>>();
    for (Sample sample : input.getSamples()) {
        Multiset<Long> rps = allSeries.get(sample.getLabel());
        if (rps == null) {
            rps = TreeMultiset.create();
            allSeries.put(sample.getLabel(), rps);
        }//from   w  w w .ja  v  a2  s  .c  o m
        rps.add(((sample.getTimestamp() + (long) sample.getValue()) / 1000) * 1000);
    }
    TimeSeriesCollection dataset = new TimeSeriesCollection();
    for (String label : allSeries.keySet()) {
        Multiset<Long> rps = allSeries.get(label);
        TimeSeries series = new TimeSeries(label);
        for (Long key : rps) {
            series.addOrUpdate(new Second(new Date(key)), rps.count(key));
        }
        dataset.addSeries(series);
    }

    return ChartFactory.createTimeSeriesChart(definition.getTitle(), "Time", "Requests/second", dataset);
}

From source file:org.mustbe.consulo.xprofiler.ui.mainPanel.MemoryPlotPanel.java

public MemoryPlotPanel(int maxAge, String title) {
    super(new BorderLayout());

    totalSeries = new TimeSeries("Committed Memory");
    totalSeries.setMaximumItemAge(maxAge);
    usedSeries = new TimeSeries("Used Memory");
    usedSeries.setMaximumItemAge(maxAge);
    TimeSeriesCollection seriesCollection = new TimeSeriesCollection();
    seriesCollection.addSeries(totalSeries);
    seriesCollection.addSeries(usedSeries);

    NumberAxis numberAxis = new NumberAxis("Memory (KB)");

    numberAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    DateAxis dateAxis = new DateAxis("Time");

    dateAxis.setAutoRange(true);/*from   w w  w .j  ava  2s  . c  o m*/
    dateAxis.setLowerMargin(0);
    dateAxis.setUpperMargin(0);
    dateAxis.setTickLabelsVisible(true);
    dateAxis.setDateFormatOverride(new SimpleDateFormat("HH:mm:ss"));

    XYLineAndShapeRenderer lineRenderer = new XYLineAndShapeRenderer(true, false);
    lineRenderer.setSeriesPaint(0, JBColor.RED);
    lineRenderer.setSeriesPaint(1, JBColor.GREEN);
    lineRenderer.setDefaultStroke(new BasicStroke(2F, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND));

    XYPlot xyplot = new XYPlot(seriesCollection, dateAxis, numberAxis, lineRenderer);
    xyplot.setBackgroundPainter(new ColorPainter(JBColor.white));
    xyplot.setDomainGridlinePaint(JBColor.LIGHT_GRAY);
    xyplot.setRangeGridlinePaint(JBColor.LIGHT_GRAY);
    xyplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D));

    JFreeChart chart = new JFreeChart(title, new Font("SansSerif", Font.PLAIN, 14), xyplot, true);
    chart.setBackgroundPainter(new ColorPainter(JBColor.white));

    add(new ChartPanel(chart, 300, 300, 0, 0, Integer.MAX_VALUE, Integer.MAX_VALUE, true, true, false, false,
            false, false), BorderLayout.CENTER);
}

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

private static XYDataset createDataset() {
    TimeSeries timeseries = new TimeSeries("Bugs");
    timeseries.add(new Day(27, 6, 2005), 478474D);
    timeseries.add(new Day(24, 1, 2006), 633804D);
    timeseries.add(new Day(28, 4, 2006), 694096D);
    timeseries.add(new Day(12, 5, 2006), 704680D);
    timeseries.add(new Day(16, 5, 2006), 709599D);
    timeseries.add(new Day(21, 6, 2006), 734754D);
    timeseries.add(new Day(27, 7, 2006), 760008D);
    TimeSeriesCollection timeseriescollection = new TimeSeriesCollection();
    timeseriescollection.addSeries(timeseries);
    return timeseriescollection;
}

From source file:de.berlios.statcvs.xml.chart.AbstractTimeSeriesChart.java

/**
 * @param filename/*from  w w  w. j a  va  2 s . c o m*/
 * @param title
 */
public AbstractTimeSeriesChart(ReportSettings settings, String filename, String title, String rangeLabel) {
    super(settings, filename, title);

    tsc = new TimeSeriesCollection();

    setChart(ChartFactory.createTimeSeriesChart(settings.getProjectName(), I18n.tr("Date"), rangeLabel, tsc,
            true, true, false));

    //Paint[] colors = new Paint[1];
    //colors[0] = Color.blue;
    //getChart().getPlot().setSeriesPaint(colors);

    // setup axis
    XYPlot plot = getChart().getXYPlot();
    ValueAxis axis = plot.getDomainAxis();
    axis.setVerticalTickLabels(true);
    plot.setRenderer(new XYStepRenderer());

    // the 4th color is yellow which has almost no contrast to the white 
    // background color, therefore we use a different color
    plot.getRenderer().setSeriesPaint(0, Color.red);
    plot.getRenderer().setSeriesPaint(1, Color.blue);
    plot.getRenderer().setSeriesPaint(2, Color.green);
    plot.getRenderer().setSeriesPaint(3, Color.magenta);
    plot.getRenderer().setSeriesPaint(4, Color.orange);
    plot.getRenderer().setSeriesPaint(5, Color.cyan);
    plot.getRenderer().setSeriesPaint(6, Color.pink);
}

From source file:diplomawork.model.JPEGSaver.java

/**
 * Save plot to file//w ww .j  a v  a2  s. co m
 */
public void saveDiagramToJPeG() {
    int startIndexForTimeSeries = (timeSeries.getItemCount() >= 5) ? timeSeries.getItemCount() - 5 : 0;
    TimeSeries timeSeries = this.timeSeries;
    try {
        timeSeries = this.timeSeries.createCopy(startIndexForTimeSeries, this.timeSeries.getItemCount() - 1);
    } catch (CloneNotSupportedException ex) {
        Logger.getLogger(JPEGSaver.class.getName()).log(Level.SEVERE, null, ex);
    }

    TimeSeriesCollection dataset = new TimeSeriesCollection();
    dataset.addSeries(timeSeries);
    JFreeChart chart = ChartFactory.createTimeSeriesChart(null, null, null, dataset, // data
            false, // create legend?
            true, // generate tooltips?
            false // generate URLs?
    );
    saveChartToFile(chart, false);
}