List of usage examples for org.jfree.data.time TimeSeries TimeSeries
public TimeSeries(Comparable name)
From source file:graficoComparacion.graficaCompa.java
public void agregarGafica(String nombreDepor, String[] fecha1, double[] peso1) { pesos = new double[peso1.length]; fecha = new String[fecha1.length]; pesos = peso1;//w w w. ja v a 2 s .com fecha = fecha1; /////////////// Date fechaDate = null; int n = pesos.length; ///// TimeSeries miserie = new TimeSeries(nombreDepor); Calendar calendar = Calendar.getInstance(); for (int i = 0; i < n; i++) { // JOptionPane.showMessageDialog(null, "fecha tio:"+fecha[i]); try { //JOptionPane.showMessageDialog(null, "fecha tio:"+fecha[i]); fechaDate = formato.parse(fecha[i]); calendar.setTime(fechaDate); } catch (ParseException ex) { } // JOptionPane.showMessageDialog(null, calendar.get(Calendar.DAY_OF_MONTH)+" "+calendar.get(Calendar.MONTH)+1+" "+ calendar.get(Calendar.YEAR)); miserie.add(new Day(calendar.get(Calendar.DAY_OF_MONTH), calendar.get(Calendar.MONTH) + 1, calendar.get(Calendar.YEAR)), pesos[i]); } datos.addSeries(miserie); }
From source file:org.jfree.chart.demo.XYDrawableAnnotationDemo1.java
private static XYDataset createDataset() { TimeSeries timeseries = new TimeSeries("Division A"); timeseries.add(new Year(2005), 1520D); timeseries.add(new Year(2006), 1132D); timeseries.add(new Year(2007), 450D); timeseries.add(new Year(2008), 620D); TimeSeries timeseries1 = new TimeSeries("Division B"); timeseries1.add(new Year(2005), 1200D); timeseries1.add(new Year(2006), 1300D); timeseries1.add(new Year(2007), 640D); timeseries1.add(new Year(2008), 520D); TimeSeriesCollection timeseriescollection = new TimeSeriesCollection(); timeseriescollection.addSeries(timeseries); timeseriescollection.addSeries(timeseries1); return timeseriescollection; }
From source file:org.hxzon.demo.jfreechart.DatasetVisibleDemo2.java
private static XYDataset createDataset() { boolean notify = false; TimeSeries s1 = new TimeSeries(series1Name); s1.add(new Month(1, 2001), 181.8, notify); s1.add(new Month(2, 2001), 167.3, notify); s1.add(new Month(4, 2001), 153.8, notify); s1.add(new Month(5, 2001), 167.6, notify); s1.add(new Month(6, 2001), 158.8, notify); s1.add(new Month(9, 2001), 148.3, notify); s1.add(new Month(10, 2001), 153.9, notify); s1.add(new Month(11, 2001), 142.7, notify); s1.add(new Month(12, 2001), 123.2, notify); s1.add(new Month(1, 2002), 131.8, notify); s1.add(new Month(2, 2002), 139.6, notify); s1.add(new Month(3, 2002), 142.9, notify); s1.add(new Month(4, 2002), 138.7, notify); s1.add(new Month(6, 2002), 137.3, notify); s1.add(new Month(7, 2002), 143.9, notify); s1.add(new Month(8, 2002), 139.8, notify); s1.add(new Month(9, 2002), 137.0, notify); s1.add(new Month(10, 2002), 132.8, notify); TimeSeries s2 = new TimeSeries(series2Name); s2.add(new Month(2, 2001), 129.6, notify); s2.add(new Month(3, 2001), 123.2, notify); s2.add(new Month(4, 2001), 117.2, notify); s2.add(new Month(5, 2001), 124.1, notify); s2.add(new Month(6, 2001), 122.6, notify); s2.add(new Month(7, 2001), 119.2, notify); s2.add(new Month(8, 2001), 116.5, notify); s2.add(new Month(9, 2001), 112.7, notify); s2.add(new Month(10, 2001), 101.5, notify); s2.add(new Month(11, 2001), 106.1, notify); s2.add(new Month(12, 2001), 110.3, notify); s2.add(new Month(1, 2002), 111.7, notify); s2.add(new Month(2, 2002), 111.0, notify); s2.add(new Month(3, 2002), 109.6, notify); s2.add(new Month(4, 2002), 113.2, notify); s2.add(new Month(5, 2002), 111.6, notify); s2.add(new Month(6, 2002), 108.8, notify); s2.add(new Month(7, 2002), 101.6, notify); TimeSeries s3 = new TimeSeries(series3Name); s3.add(new Month(2, 2001), 1129.6, notify); s3.add(new Month(3, 2001), 1123.2, notify); s3.add(new Month(4, 2001), 1117.2, notify); s3.add(new Month(5, 2001), 1124.1, notify); s3.add(new Month(6, 2001), 1122.6, notify); s3.add(new Month(7, 2001), 1119.2, notify); s3.add(new Month(8, 2001), 1116.5, notify); s3.add(new Month(9, 2001), 1112.7, notify); s3.add(new Month(10, 2001), 1101.5, notify); s3.add(new Month(11, 2001), 1106.1, notify); s3.add(new Month(12, 2001), 1110.3, notify); s3.add(new Month(1, 2002), 1111.7, notify); s3.add(new Month(2, 2002), 1111.0, notify); s3.add(new Month(3, 2002), 1109.6, notify); s3.add(new Month(4, 2002), 1113.2, notify); s3.add(new Month(5, 2002), 1111.6, notify); s3.add(new Month(6, 2002), 1108.8, notify); s3.add(new Month(7, 2002), 1101.6, notify); TimeSeriesCollection dataset = new TimeSeriesCollection(); dataset.addSeries(s3);/*from www .ja va2 s . com*/ dataset.addSeries(s2); dataset.addSeries(s1); return dataset; }
From source file:com.sigueros.charts.LinearRegressionExample.java
/** * Creates a sample dataset for Linear data *//*from w w w. ja v a2s .c om*/ private TimeSeriesCollection createDatasetLinear() { final TimeSeries linearData = new TimeSeries("Linear"); //The Linear dataSet is the Linear Regression: double ad[] = Regression.getOLSRegression(getData()); for (int i = 0; i < getData().length; i++) { //The formula to calculate the value is a + b * x, where a = ad[0] and b = ad [1] linearData.add(new Year((int) getData()[i][0]), ad[0] + ad[1] * getData()[i][0]); } TimeSeriesCollection dataLinearCollection = new TimeSeriesCollection(); dataLinearCollection.addSeries(linearData); return dataLinearCollection; }
From source file:org.jfree.chart.demo.TimeSeriesDemo5.java
/** * Creates a sample dataset./*from ww w .ja v a 2 s .c o m*/ * * @return A sample dataset. */ private XYDataset createDataset() { final TimeSeries series = new TimeSeries("Random Data"); Day current = new Day(1, 1, 1990); double value = 100.0; for (int i = 0; i < 4000; i++) { try { value = value + Math.random() - 0.5; series.add(current, new Double(value)); current = (Day) current.next(); } catch (SeriesException e) { System.err.println("Error adding to series"); } } return new TimeSeriesCollection(series); }
From source file:org.jfree.data.time.TimeSeriesCollectionTest.java
/** * Some tests for the equals() method./* w ww. j av a 2s.c o m*/ */ @Test public void testEquals() { TimeSeriesCollection c1 = new TimeSeriesCollection(); TimeSeriesCollection c2 = new TimeSeriesCollection(); TimeSeries s1 = new TimeSeries("Series 1"); TimeSeries s2 = new TimeSeries("Series 2"); // newly created collections should be equal boolean b1 = c1.equals(c2); assertTrue("b1", b1); // add series to collection 1, should be not equal c1.addSeries(s1); c1.addSeries(s2); boolean b2 = c1.equals(c2); assertFalse("b2", b2); // now add the same series to collection 2 to make them equal again... c2.addSeries(s1); c2.addSeries(s2); boolean b3 = c1.equals(c2); assertTrue("b3", b3); // now remove series 2 from collection 2 c2.removeSeries(s2); boolean b4 = c1.equals(c2); assertFalse("b4", b4); // now remove series 2 from collection 1 to make them equal again c1.removeSeries(s2); boolean b5 = c1.equals(c2); assertTrue("b5", b5); }
From source file:net.pickapack.chart.LinePlotFrame.java
/** * Create a line plot frame./*from w w w.j a va2 s .co m*/ * * @param linePlot the line plot * @param width the width * @param height the height */ public LinePlotFrame(LinePlot linePlot, int width, int height) { super(linePlot.getTitle()); this.linePlot = linePlot; this.numSubPlots = linePlot.getSubLinePlots().size(); CombinedDomainXYPlot plot = new CombinedDomainXYPlot(new DateAxis("Time")); this.dataSets = new ArrayList<TimeSeriesCollection>(); this.dataSinks = new ArrayList<Map<SubLinePlotLine, Function<Double>>>(); for (SubLinePlot subLinePlot : linePlot.getSubLinePlots()) { TimeSeriesCollection dataSetsPerSubPlot = new TimeSeriesCollection(); this.dataSets.add(dataSetsPerSubPlot); HashMap<SubLinePlotLine, Function<Double>> dataSinksPerSubPlot = new HashMap<SubLinePlotLine, Function<Double>>(); this.dataSinks.add(dataSinksPerSubPlot); for (SubLinePlotLine subLinePlotLine : subLinePlot.getLines()) { TimeSeries timeSeries = new TimeSeries(subLinePlotLine.getTitle()); dataSetsPerSubPlot.addSeries(timeSeries); dataSinksPerSubPlot.put(subLinePlotLine, subLinePlotLine.getGetValueCallback()); } NumberAxis rangeAxis = new NumberAxis(subLinePlot.getTitleY()); rangeAxis.setAutoRangeIncludesZero(false); XYPlot subplot = new XYPlot(dataSetsPerSubPlot, null, rangeAxis, new StandardXYItemRenderer()); subplot.setBackgroundPaint(Color.lightGray); subplot.setDomainGridlinePaint(Color.white); subplot.setRangeGridlinePaint(Color.white); plot.add(subplot); } JFreeChart chart = new JFreeChart(linePlot.getTitle(), plot); chart.setBorderPaint(Color.black); chart.setBorderVisible(true); chart.setBackgroundPaint(Color.white); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); ValueAxis axis = plot.getDomainAxis(); axis.setAutoRange(true); axis.setFixedAutoRange(3600000.0); JPanel content = new JPanel(new BorderLayout()); ChartPanel chartPanel = new ChartPanel(chart); content.add(chartPanel); chartPanel.setPreferredSize(new java.awt.Dimension(width, height)); chartPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); setContentPane(content); DataSink dataSink = new DataSink(); new Thread(dataSink).start(); }
From source file:org.hxzon.demo.jfreechart.XYDatasetDemo.java
private static XYDataset createDataset() { TimeSeries s1 = new TimeSeries("L&G European Index Trust"); 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); TimeSeries s2 = new TimeSeries("L&G UK Index Trust"); s2.add(new Month(2, 2001), 129.6); s2.add(new Month(3, 2001), 123.2); s2.add(new Month(4, 2001), 117.2); s2.add(new Month(5, 2001), 124.1); s2.add(new Month(6, 2001), 122.6); s2.add(new Month(7, 2001), 119.2); s2.add(new Month(8, 2001), 116.5); s2.add(new Month(9, 2001), 112.7); s2.add(new Month(10, 2001), 101.5); s2.add(new Month(11, 2001), 106.1); s2.add(new Month(12, 2001), 110.3); s2.add(new Month(1, 2002), 111.7); s2.add(new Month(2, 2002), 111.0); s2.add(new Month(3, 2002), 109.6); s2.add(new Month(4, 2002), 113.2); s2.add(new Month(5, 2002), 111.6); s2.add(new Month(6, 2002), 108.8); s2.add(new Month(7, 2002), 101.6); TimeSeriesCollection dataset = new TimeSeriesCollection(); dataset.addSeries(s2);//from w w w. ja v a2 s.c o m dataset.addSeries(s1); return dataset; }
From source file:net.atomique.ksar.graph.Graph.java
private void create_DataStore() { // create timeseries for (int i = firstDataColumn; i < HeaderStr.length; i++) { Stats.add(new TimeSeries(HeaderStr[i])); }/*from w ww . ja va 2s . c o m*/ // create stack for (PlotStackConfig tmp : graphconfig.getStacklist().values()) { TimeTableXYDataset tmp2 = new TimeTableXYDataset(); String[] s = tmp.getHeaderStr().split("\\s+"); for (String value : s) { StackListbyCol.put(value, tmp2); } StackListbyName.put(tmp.getTitle(), tmp2); } }
From source file:uk.co.petertribble.jkstat.gui.KstatSetChart.java
private void init(List<String> statistics) { dataset = new TimeSeriesCollection(); tsmap = new HashMap<String, TimeSeries>(); kMap = new HashMap<Kstat, ChartableKstat>(); for (Kstat ks : kss.getKstats()) { kMap.put(ks, new ChartableKstat(jkstat, ks)); for (String statistic : KstatUtil.numericStatistics(jkstat, ks)) { String s = ks.getTriplet() + ":" + statistic; tsmap.put(s, new TimeSeries(s)); }//from w w w . ja v a2 s . co m for (String statistic : statistics) { dataset.addSeries(tsmap.get(ks.getTriplet() + ":" + statistic)); } } if (jkstat instanceof SequencedJKstat) { readAll(((SequencedJKstat) jkstat).newInstance()); } else { setMaxAge(maxage); updateAccessory(); } String ylabel = showdelta ? KstatResources.getString("CHART.RATE") : KstatResources.getString("CHART.VALUE"); chart = ChartFactory.createTimeSeriesChart(kss.toString() == null ? "statistic" : kss.toString(), KstatResources.getString("CHART.TIME"), ylabel, dataset, true, true, false); setAxes(); if (!(jkstat instanceof SequencedJKstat)) { startLoop(); } }