List of usage examples for org.jfree.data.time TimeSeriesCollection addSeries
public void addSeries(TimeSeries series)
From source file:org.jfree.chart.demo.TimeSeriesDemo6.java
/** * Creates a dataset, consisting of two series of monthly data. * * @return the dataset.//ww w .j a v a 2s . c o m */ public XYDataset createDataset() { final double value = 0.0; final TimeSeries s1 = new TimeSeries("Series 1", Month.class); s1.add(new Month(2, 2001), value); s1.add(new Month(3, 2001), value); s1.add(new Month(4, 2001), value); s1.add(new Month(5, 2001), value); s1.add(new Month(6, 2001), value); s1.add(new Month(7, 2001), value); s1.add(new Month(8, 2001), value); s1.add(new Month(9, 2001), value); s1.add(new Month(10, 2001), value); s1.add(new Month(11, 2001), value); s1.add(new Month(12, 2001), value); s1.add(new Month(1, 2002), value); s1.add(new Month(2, 2002), value); s1.add(new Month(3, 2002), value); s1.add(new Month(4, 2002), value); s1.add(new Month(5, 2002), value); s1.add(new Month(6, 2002), value); s1.add(new Month(7, 2002), value); final TimeSeriesCollection dataset = new TimeSeriesCollection(); dataset.addSeries(s1); return dataset; }
From source file:org.jfree.chart.demo.InternalFrameDemo.java
/** * Creates a sample dataset.//from w ww . j ava 2 s . c om * * @param name the dataset name. * @param base the starting value. * @param start the starting period. * @param count the number of values to generate. * * @return The dataset. */ private XYDataset createDataset(final String name, final double base, final RegularTimePeriod start, final int count) { final TimeSeries series = new TimeSeries(name, start.getClass()); RegularTimePeriod period = start; double value = base; for (int i = 0; i < count; i++) { series.add(period, value); period = period.next(); value = value * (1 + (Math.random() - 0.495) / 10.0); } final TimeSeriesCollection dataset = new TimeSeriesCollection(); dataset.addSeries(series); return dataset; }
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 a 2 s .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, 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:compecon.dashboard.panel.StatesPanel.java
protected ChartPanel createUtilityPanel(Currency currency) { TimeSeriesCollection timeSeriesCollection = new TimeSeriesCollection(); timeSeriesCollection.addSeries(ApplicationContext.getInstance().getModelRegistry() .getNationalEconomyModel(currency).stateModel.utilityModel.utilityOutputModel.getTimeSeries()); for (GoodType inputGoodType : ApplicationContext.getInstance().getModelRegistry() .getNationalEconomyModel(currency).stateModel.utilityModel.utilityInputModels.keySet()) { timeSeriesCollection.addSeries(ApplicationContext.getInstance().getModelRegistry() .getNationalEconomyModel(currency).stateModel.utilityModel.utilityInputModels.get(inputGoodType) .getTimeSeries()); }//from w ww .j av a 2 s .co m JFreeChart chart = ChartFactory.createTimeSeriesChart("State Utility", "Date", "Utility", (XYDataset) timeSeriesCollection, true, true, false); configureChart(chart); return new ChartPanel(chart); }
From source file:in.BBAT.presenter.DualAxisDemo2.java
/** * Creates a sample dataset./* ww w.j a va2 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:in.BBAT.presenter.DualAxisDemo2.java
/** * Creates a sample dataset./* w w w . ja v a 2 s. com*/ * * @return The dataset. */ private XYDataset createDataset1() { final TimeSeries s2 = new TimeSeries("Memory", Millisecond.class); for (MemoryEntity ent : ScreenShotView.testCase.getMemoryUsageValues()) { s2.addOrUpdate(new Millisecond(new Date(ent.getTime())), ent.getPercent()); } final TimeSeriesCollection dataset = new TimeSeriesCollection(); dataset.addSeries(s2); return dataset; }
From source file:net.sf.profiler4j.console.MemoryPlotPanel.java
public MemoryPlotPanel(int maxAge, String title) { super(new BorderLayout()); totalSeries = new TimeSeries("Committed Memory", Millisecond.class); totalSeries.setMaximumItemAge(maxAge); usedSeries = new TimeSeries("Used Memory", Millisecond.class); usedSeries.setMaximumItemAge(maxAge); TimeSeriesCollection seriesCollection = new TimeSeriesCollection(); seriesCollection.addSeries(totalSeries); seriesCollection.addSeries(usedSeries); NumberAxis numberAxis = new NumberAxis("Memory (KB)"); 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);// ww w . ja v a 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, 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(title, new Font("SansSerif", Font.PLAIN, 14), 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:sernet.gs.ui.rcp.main.bsi.views.chart.RealisierungLineChart.java
private Object createProgressDataset() throws CommandException { TimeSeries ts1 = new TimeSeries(Messages.RealisierungLineChart_7, Day.class); TimeSeries ts2 = new TimeSeries(Messages.RealisierungLineChart_8, Day.class); RealisierungSummary command = new RealisierungSummary(); command = ServiceFactory.lookupCommandService().executeCommand(command); DateValues dateTotal1 = command.getTotal1(); DateValues dateTotal2 = command.getTotal2(); Map<Day, Integer> totals1 = dateTotal1.getDateTotals(); Set<Entry<Day, Integer>> entrySet1 = totals1.entrySet(); for (Entry<Day, Integer> entry : entrySet1) { ts1.add(entry.getKey(), entry.getValue()); }//from ww w . j a v a2 s .co m Map<Day, Integer> totals2 = dateTotal2.getDateTotals(); Set<Entry<Day, Integer>> entrySet2 = totals2.entrySet(); for (Entry<Day, Integer> entry : entrySet2) { ts2.add(entry.getKey(), entry.getValue()); } TimeSeriesCollection tsc = new TimeSeriesCollection(); tsc.addSeries(ts2); tsc.addSeries(ts1); return tsc; }
From source file:org.jfree.chart.demo.MovingAverageDemo.java
/** * Creates a dataset, one series containing unit trust prices, the other a moving average. * * @return the dataset./*from w w w. j ava 2 s .c om*/ */ public XYDataset createDataset() { final TimeSeries s1 = new TimeSeries("L&G European Index Trust", Month.class); 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), 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); // **************************************************************************** // * JFREECHART DEVELOPER GUIDE * // * The JFreeChart Developer Guide, written by David Gilbert, is available * // * to purchase from Object Refinery Limited: * // * * // * http://www.object-refinery.com/jfreechart/guide.html * // * * // * Sales are used to provide funding for the JFreeChart project - please * // * support us so that we can continue developing free software. * // **************************************************************************** final TimeSeries s2 = MovingAverage.createMovingAverage(s1, "Six Month Moving Average", 6, 0); final TimeSeriesCollection dataset = new TimeSeriesCollection(); dataset.addSeries(s1); dataset.addSeries(s2); return dataset; }
From source file:org.uncommons.watchmaker.swing.evolutionmonitor.JVMView.java
private JFreeChart createHeapChart(double maxMemory) { TimeSeriesCollection dataSet = new TimeSeriesCollection(); dataSet.addSeries(memoryUsageSeries); dataSet.addSeries(heapSizeSeries);//from w w w.j a v a 2s .c o m JFreeChart chart = ChartFactory.createXYAreaChart("JVM Heap", "Time", "Megabytes", dataSet, PlotOrientation.VERTICAL, true, // Legend. false, // Tooltips. false); DateAxis timeAxis = new DateAxis("Time"); timeAxis.setLowerMargin(0); timeAxis.setUpperMargin(0); chart.getXYPlot().setDomainAxis(timeAxis); chart.getXYPlot().getRangeAxis().setLowerBound(0); chart.getXYPlot().getRangeAxis().setUpperBound(maxMemory * 1.1); // Add 10% to leave room for marker. // Add a horizontal marker to indicate the heap growth limit. ValueMarker marker = new ValueMarker(maxMemory, Color.BLACK, new BasicStroke(1)); marker.setLabel("Maximum Permitted Heap Size (adjust with -Xmx)"); marker.setLabelTextAnchor(TextAnchor.BOTTOM_RIGHT); marker.setLabelAnchor(RectangleAnchor.RIGHT); chart.getXYPlot().addRangeMarker(marker); chart.getXYPlot().getRenderer().setSeriesPaint(0, Color.RED); chart.getXYPlot().getRenderer().setSeriesPaint(1, new Color(0, 128, 0, 128)); return chart; }