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:org.jfree.chart.demo.RelativeDateFormatDemo1.java

private static XYDataset createDataset() {
    TimeSeries timeseries = new TimeSeries("Heart Rate");
    timeseries.add(new Second(45, 6, 9, 1, 10, 2006), 143D);
    timeseries.add(new Second(33, 8, 9, 1, 10, 2006), 167D);
    timeseries.add(new Second(10, 10, 9, 1, 10, 2006), 189D);
    timeseries.add(new Second(19, 12, 9, 1, 10, 2006), 156D);
    timeseries.add(new Second(5, 15, 9, 1, 10, 2006), 176D);
    timeseries.add(new Second(12, 16, 9, 1, 10, 2006), 183D);
    timeseries.add(new Second(6, 18, 9, 1, 10, 2006), 138D);
    timeseries.add(new Second(11, 20, 9, 1, 10, 2006), 102D);
    TimeSeriesCollection timeseriescollection = new TimeSeriesCollection();
    timeseriescollection.addSeries(timeseries);
    return timeseriescollection;
}

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:org.jfree.chart.demo.MemoryUsageDemo.java

public MemoryUsageDemo(int i) {
    super(new BorderLayout());
    total = new TimeSeries("Total Memory");
    total.setMaximumItemAge(i);//from w w  w . j  a v a 2s .  com
    free = new TimeSeries("Free Memory");
    free.setMaximumItemAge(i);
    TimeSeriesCollection timeseriescollection = new TimeSeriesCollection();
    timeseriescollection.addSeries(total);
    timeseriescollection.addSeries(free);
    DateAxis dateaxis = new DateAxis("Time");
    NumberAxis numberaxis = new NumberAxis("Memory");
    dateaxis.setTickLabelFont(new Font("SansSerif", 0, 12));
    numberaxis.setTickLabelFont(new Font("SansSerif", 0, 12));
    dateaxis.setLabelFont(new Font("SansSerif", 0, 14));
    numberaxis.setLabelFont(new Font("SansSerif", 0, 14));
    XYLineAndShapeRenderer xylineandshaperenderer = new XYLineAndShapeRenderer(true, false);
    xylineandshaperenderer.setSeriesPaint(0, Color.red);
    xylineandshaperenderer.setSeriesPaint(1, Color.green);
    xylineandshaperenderer.setSeriesStroke(0, new BasicStroke(3F, 0, 2));
    xylineandshaperenderer.setSeriesStroke(1, new BasicStroke(3F, 0, 2));
    XYPlot xyplot = new XYPlot(timeseriescollection, dateaxis, numberaxis, xylineandshaperenderer);
    xyplot.setBackgroundPaint(Color.lightGray);
    xyplot.setDomainGridlinePaint(Color.white);
    xyplot.setRangeGridlinePaint(Color.white);
    xyplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D));
    dateaxis.setAutoRange(true);
    dateaxis.setLowerMargin(0.0D);
    dateaxis.setUpperMargin(0.0D);
    dateaxis.setTickLabelsVisible(true);
    numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    JFreeChart jfreechart = new JFreeChart("JVM Memory Usage", new Font("SansSerif", 1, 24), xyplot, true);
    jfreechart.setBackgroundPaint(Color.white);
    ChartPanel chartpanel = new ChartPanel(jfreechart, true);
    chartpanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4),
            BorderFactory.createLineBorder(Color.black)));
    add(chartpanel);
}

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

private static IntervalXYDataset createDataset() {
    TimeSeries timeseries = new TimeSeries("Temperature");
    timeseries.add(new Day(1, 4, 2006), 14.5D);
    timeseries.add(new Day(2, 4, 2006), 11.5D);
    timeseries.add(new Day(3, 4, 2006), 13.699999999999999D);
    timeseries.add(new Day(4, 4, 2006), 10.5D);
    timeseries.add(new Day(5, 4, 2006), 14.9D);
    timeseries.add(new Day(6, 4, 2006), 15.699999999999999D);
    timeseries.add(new Day(7, 4, 2006), 11.5D);
    timeseries.add(new Day(8, 4, 2006), 9.5D);
    timeseries.add(new Day(9, 4, 2006), 10.9D);
    timeseries.add(new Day(10, 4, 2006), 14.1D);
    timeseries.add(new Day(11, 4, 2006), 12.300000000000001D);
    timeseries.add(new Day(12, 4, 2006), 14.300000000000001D);
    timeseries.add(new Day(13, 4, 2006), 19D);
    timeseries.add(new Day(14, 4, 2006), 17.899999999999999D);
    TimeSeriesCollection timeseriescollection = new TimeSeriesCollection();
    timeseriescollection.addSeries(timeseries);
    return timeseriescollection;
}

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 a  v a2s  . 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:uk.co.bssd.reporting.chart.TimeSeriesChart.java

private XYDataset convertDataset(String seriesName, TimedDatapoints<T> timedDatapoints) {
    TimeSeries series = new TimeSeries(seriesName);
    for (TimedDatapoint<T> timedDatapoint : timedDatapoints) {
        Millisecond regularTimePeriod = new Millisecond(timedDatapoint.timestamp().toDate());
        series.add(regularTimePeriod, timedDatapoint.value());
    }//  w w w  .  j  a  v  a2  s . com
    return new TimeSeriesCollection(series);
}

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 .  ja va2 s.  com
        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:org.mwc.debrief.sensorfusion.views.MouseClickSolutionDemo.java

/**
 * @param title//from  w  w  w  .j  ava 2  s .com
 *            the frame title.
 */
public MouseClickSolutionDemo(final String title) {
    super(title);

    final TimeSeries s1 = new TimeSeries("Series to click");
    s1.add(new Month(2, 2001), 181.8);
    s1.add(new Month(3, 2001), 167.3);
    s1.add(new Month(4, 2001), 153.8);
    s1.add(new Month(5, 2001), 167.6);
    s1.add(new Month(6, 2001), 152.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);

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

    final JFreeChart chart = ChartFactory.createTimeSeriesChart("[Alt]-click to switch orientation", // title
            "Time axis", // x-axis label
            "Value axis", // y-axis label
            dataset, // data
            false, // create legend?
            false, // generate tooltips?
            false // generate URLs?
    );

    //FIX IS HERE
    fixProblem(chart);

    final ChartPanel chartPanel = new ChartPanel(chart);

    chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));

    chartPanel.addChartMouseListener(new ChartMouseListener() {
        public void chartMouseMoved(final ChartMouseEvent arg0) {
        }

        public void chartMouseClicked(final ChartMouseEvent arg0) {
            System.out.println("clicked on:" + arg0.getEntity());

            if (arg0.getTrigger().isAltDown()) {
                if (chart.getXYPlot().getOrientation() == PlotOrientation.HORIZONTAL)
                    chart.getXYPlot().setOrientation(PlotOrientation.VERTICAL);
                else
                    chart.getXYPlot().setOrientation(PlotOrientation.HORIZONTAL);
            }
        }
    });
    setContentPane(chartPanel);
}

From source file:org.yccheok.jstock.gui.charting.DynamicChart.java

/** Creates new form DynamicChart */
public DynamicChart() {
    this.price = new TimeSeries("Price");
    // Sets the maximumItemAge attribute, which specifies the maximum age of data items in the series
    // (in terms of the RegularTimePeriod type used by this series). Whenever a new data value is
    // added, any data items that are older than the limit specified by maximumItemAge are automatically
    // discarded/*from ww w  .jav  a 2s.c o m*/
    // Maximum 2 hours.
    this.price.setMaximumItemAge(2 * 60 * 60);

    TimeSeriesCollection dataset = new TimeSeriesCollection();
    dataset.addSeries(this.price);

    JFreeChart freeChart = ChartFactory.createTimeSeriesChart(null, null, null, dataset, false, true, false);

    freeChart.setAntiAlias(true);
    while (freeChart.getSubtitleCount() > 0) {
        freeChart.removeSubtitle(freeChart.getSubtitle(0));
    }

    // Due to limited spacing, we remove all information regarding x and y axis
    // as well.
    XYPlot plot = freeChart.getXYPlot();
    plot.getRangeAxis().setVisible(false);
    plot.getDomainAxis().setVisible(false);

    XYItemRenderer renderer1 = plot.getRenderer();
    renderer1.setBaseToolTipGenerator(
            new StandardXYToolTipGenerator(StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT,
                    new SimpleDateFormat("h:mm:ss a"), new DecimalFormat("0.00#")));

    org.yccheok.jstock.charting.Utils.applyChartTheme(freeChart);

    // Disable zoom.
    chartPanel = new ChartPanel(freeChart, true, true, true, false, true);
    chartPanel.setMouseZoomable(false);
}

From source file:uk.co.petertribble.jkstat.demo.JLoadChart.java

/**
 * A standalone demo charting load averages.
 *//*from w  w w. j a v a 2 s . c o m*/
public JLoadChart() {
    super("JLoadChart");

    jkstat = new NativeJKstat();
    int maxage = 600000;

    String lavetext = KstatResources.getString("LOAD.AVERAGE.TEXT");
    ts1 = new TimeSeries("1min " + lavetext);
    ts1.setMaximumItemAge(maxage);
    ts5 = new TimeSeries("5min " + lavetext);
    ts5.setMaximumItemAge(maxage);
    ts15 = new TimeSeries("15min " + lavetext);
    ts15.setMaximumItemAge(maxage);

    updateAccessory();
    TimeSeriesCollection dataset = new TimeSeriesCollection();
    dataset.addSeries(ts1);
    dataset.addSeries(ts5);
    dataset.addSeries(ts15);

    JFreeChart chart = ChartFactory.createTimeSeriesChart(lavetext, KstatResources.getString("CHART.TIME"),
            KstatResources.getString("LOAD.LOAD.TEXT"), dataset, true, true, false);

    XYPlot xyplot = chart.getXYPlot();

    NumberAxis loadaxis = new NumberAxis(KstatResources.getString("LOAD.LOAD.TEXT"));
    loadaxis.setAutoRange(true);
    loadaxis.setAutoRangeIncludesZero(true);
    xyplot.setRangeAxis(loadaxis);

    DateAxis daxis = new DateAxis(KstatResources.getString("CHART.TIME"));
    daxis.setAutoRange(true);
    daxis.setFixedAutoRange(maxage);
    xyplot.setDomainAxis(daxis);

    addWindowListener(new winExit());
    setContentPane(new ChartPanel(chart));

    JMenuBar jm = new JMenuBar();
    JMenu jme = new JMenu(KstatResources.getString("FILE.TEXT"));
    jme.setMnemonic(KeyEvent.VK_F);
    exitItem = new JMenuItem(KstatResources.getString("FILE.EXIT.TEXT"), KeyEvent.VK_X);
    exitItem.addActionListener(this);
    jme.add(exitItem);
    jm.add(jme);

    setJMenuBar(jm);

    pack();
    setVisible(true);
    Timer timer = new Timer(5000, this);
    timer.start();
}