List of usage examples for org.jfree.data.time TimeSeries TimeSeries
public TimeSeries(Comparable name)
From source file:y.graphs.ChartHelperELF.java
private static TimeSeriesCollection createDataset(ElfValue[][] dayvalues, int[] mediane, boolean[] medianevalide, int med_max, Config config, ArrayList<ConfigSerie> series) { final TimeSeries[] aserie = new TimeSeries[series.size()]; for (int i = 0; i < aserie.length; i++) aserie[i] = new TimeSeries(series.get(i).getName()); for (int d = 0; d < dayvalues.length; d++) { final ElfValue[] day = dayvalues[d]; for (int i = 0; i < day.length; i++) { final ElfValue value = day[i]; final DateTime time = value.getTime(); final RegularTimePeriod date = new Minute(time.toDate()); if (value.isValid()) for (int aix = 0; aix < aserie.length; aix++) series.get(aix).add(aserie[aix], date, value.getValue(), mediane[d], medianevalide[d], mediane[med_max]); }//from ww w . ja va 2 s. c o m } final TimeSeriesCollection dataset = new TimeSeriesCollection(); for (int aix = 0; aix < aserie.length; aix++) dataset.addSeries(aserie[aix]); return dataset; }
From source file:UserInterface.PatientRole.VitalSignsChartJPanel.java
private XYDataset createXYDataset() { TimeSeriesCollection data = new TimeSeriesCollection(); TimeSeries s1 = new TimeSeries("Respiratory Rate"); for (Record vitalSign : patient.getRecordHistory().getRecordList()) { s1.add(new Second(vitalSign.getDate()), vitalSign.getRespiratoryRate()); }//from w ww . j av a 2s . co m data.addSeries(s1); TimeSeries s2 = new TimeSeries("Heart Rate"); for (Record vitalSign : patient.getRecordHistory().getRecordList()) { s2.add(new Second(vitalSign.getDate()), vitalSign.getHeartRate()); } data.addSeries(s2); TimeSeries s3 = new TimeSeries("Blood Pressure"); for (Record vitalSign : patient.getRecordHistory().getRecordList()) { s3.add(new Second(vitalSign.getDate()), vitalSign.getSystolicBloodPressure()); } data.addSeries(s3); TimeSeries s4 = new TimeSeries("Weight"); for (Record vitalSign : patient.getRecordHistory().getRecordList()) { s4.add(new Second(vitalSign.getDate()), vitalSign.getWeightInPounds()); } data.addSeries(s4); return data; }
From source file:mediamatrix.gui.JVMMemoryProfilerPanel.java
public JVMMemoryProfilerPanel() { initComponents();// ww w . jav a2s.c o m profiler = new JVMMemoryProfiler(frequency); profiler.addListener(new JVMMemoryProfilerListener() { @Override public void addScore(long t, long f) { total.add(new Millisecond(), t); free.add(new Millisecond(), f); } }); total = new TimeSeries("Total Memory"); total.setMaximumItemCount(historyCount); free = new TimeSeries("Free Memory"); free.setMaximumItemCount(historyCount); final TimeSeriesCollection dataset = new TimeSeriesCollection(); dataset.addSeries(total); dataset.addSeries(free); final DateAxis domain = new DateAxis("Time"); final NumberAxis range = new NumberAxis("Memory"); domain.setTickLabelFont(new Font("SansSerif", Font.PLAIN, 12)); domain.setLabelFont(new Font("SansSerif", Font.PLAIN, 14)); range.setTickLabelFont(new Font("SansSerif", Font.PLAIN, 12)); range.setLabelFont(new Font("SansSerif", Font.PLAIN, 14)); range.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); final XYItemRenderer renderer = new DefaultXYItemRenderer(); renderer.setSeriesPaint(0, Color.red); renderer.setSeriesPaint(1, Color.green); renderer.setBaseStroke(new BasicStroke(3f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL)); final XYPlot plot = new XYPlot(dataset, domain, range, renderer); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); domain.setAutoRange(true); domain.setLowerMargin(0.0); domain.setUpperMargin(0.0); domain.setTickLabelsVisible(true); final JFreeChart chart = new JFreeChart("JVM Memory Usage", new Font("SansSerif", Font.BOLD, 24), plot, true); chart.setBackgroundPaint(Color.white); final ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4), BorderFactory.createLineBorder(Color.black))); chart.getLegend().setItemFont(new Font("SansSerif", Font.PLAIN, 12)); add(chartPanel, BorderLayout.CENTER); }
From source file:openqcm.ChartDynamicData.java
public ChartDynamicData() { // add primary axis frequency TimeSeries seriesFrequency = new TimeSeries("Frequency (Hz)"); datasetFrequency = new TimeSeriesCollection(seriesFrequency); rangeAxisF = new NumberAxis("Frequency (Hz)"); XYItemRenderer renderer = new StandardXYItemRenderer(); renderer.setSeriesPaint(0, new Color(0, 142, 192)); rangeAxisF.setAutoRangeIncludesZero(false); rangeAxisF.setAutoRange(true);//from w ww. j av a 2 s. co m rangeAxisF.setAutoRangeMinimumSize(50); plot.setDataset(0, datasetFrequency); plot.setRangeAxis(0, rangeAxisF); plot.setRangeAxisLocation(0, AxisLocation.BOTTOM_OR_LEFT); plot.setRenderer(0, renderer); plot.mapDatasetToRangeAxis(0, 0); // add secondary axis temperature TimeSeries seriesTemperature = new TimeSeries("Temperature (C)"); datasetTemperature = new TimeSeriesCollection(seriesTemperature); plot.setDataset(1, datasetTemperature); NumberAxis rangeAxisT = new NumberAxis("Temperature (C)"); rangeAxisT.setAutoRangeIncludesZero(false); rangeAxisT.setAutoRange(true); rangeAxisT.setAutoRangeMinimumSize(5); plot.setRangeAxis(1, rangeAxisT); plot.setRangeAxisLocation(1, AxisLocation.BOTTOM_OR_RIGHT); // custom renderer for dinamically changing temperaure rendererT.setSeriesPaint(0, new Color(255, 128, 0)); plot.setRenderer(1, rendererT); plot.mapDatasetToRangeAxis(1, 1); plotComb.add(plot); plotComb.setBackgroundPaint(Color.white); plotComb.setDomainGridlinePaint(Color.white); plotComb.setRangeGridlinePaint(Color.white); // enable panning for both axis plotComb.setRangePannable(true); plotComb.setDomainPannable(true); // set time axis properties // format time axis as hh:mm:ss SimpleDateFormat format = new SimpleDateFormat("HH:mm:ss"); DateAxis axis = (DateAxis) plotComb.getDomainAxis(); axis.setDateFormatOverride(format); // default auto range domainAxis.setAutoRange(true); // init the JFreeChart JFreeChart chart = new JFreeChart(plotComb); chart.setBorderPaint(Color.lightGray); chart.setBorderVisible(true); chart.setBackgroundPaint(Color.white); // set legend properties LegendTitle legend = chart.getLegend(); legend.setPosition(RectangleEdge.TOP); legend.setItemFont(new Font("Dialog", Font.PLAIN, 9)); // constructor for org.jfree.chart.ChartPanel // ChartPanel(JFreeChart chart, boolean properties, boolean save, boolean print, boolean zoom, boolean tooltips) ChartPanel chartPanel = new ChartPanel(chart, false, true, true, true, true); // enable mouse wheel support for the chart panel chartPanel.setMouseWheelEnabled(true); this.setLayout(new BorderLayout()); // add real time chart to the frame this.add(chartPanel); this.validate(); }
From source file:org.jfree.chart.demo.PriceVolumeDemo1.java
private static XYDataset createPriceDataset() { TimeSeries timeseries = new TimeSeries("Price"); timeseries.add(new Day(2, 1, 2002), 95.564999999999998D); timeseries.add(new Day(3, 1, 2002), 95.640000000000001D); timeseries.add(new Day(4, 1, 2002), 95.709999999999994D); timeseries.add(new Day(7, 1, 2002), 95.930000000000007D); timeseries.add(new Day(8, 1, 2002), 95.930000000000007D); timeseries.add(new Day(9, 1, 2002), 95.959999999999994D); timeseries.add(new Day(10, 1, 2002), 96.055000000000007D); timeseries.add(new Day(11, 1, 2002), 96.334999999999994D); timeseries.add(new Day(14, 1, 2002), 96.290000000000006D); timeseries.add(new Day(15, 1, 2002), 96.275000000000006D); timeseries.add(new Day(16, 1, 2002), 96.239999999999995D); timeseries.add(new Day(17, 1, 2002), 96.079999999999998D); timeseries.add(new Day(18, 1, 2002), 96.144999999999996D); timeseries.add(new Day(22, 1, 2002), 96.120000000000005D); timeseries.add(new Day(23, 1, 2002), 96.015000000000001D); timeseries.add(new Day(24, 1, 2002), 95.890000000000001D); timeseries.add(new Day(25, 1, 2002), 95.864999999999995D); timeseries.add(new Day(28, 1, 2002), 95.879999999999995D); timeseries.add(new Day(29, 1, 2002), 96.049999999999997D); timeseries.add(new Day(30, 1, 2002), 96.064999999999998D); timeseries.add(new Day(31, 1, 2002), 95.909999999999997D); timeseries.add(new Day(1, 2, 2002), 96.015000000000001D); timeseries.add(new Day(4, 2, 2002), 96.140000000000001D); timeseries.add(new Day(5, 2, 2002), 96.194999999999993D); timeseries.add(new Day(6, 2, 2002), 96.245000000000005D); timeseries.add(new Day(7, 2, 2002), 96.219999999999999D); timeseries.add(new Day(8, 2, 2002), 96.280000000000001D); timeseries.add(new Day(11, 2, 2002), 96.265000000000001D); timeseries.add(new Day(12, 2, 2002), 96.159999999999997D); timeseries.add(new Day(13, 2, 2002), 96.120000000000005D); timeseries.add(new Day(14, 2, 2002), 96.125D); timeseries.add(new Day(15, 2, 2002), 96.265000000000001D); timeseries.add(new Day(19, 2, 2002), 96.290000000000006D); timeseries.add(new Day(20, 2, 2002), 96.275000000000006D); timeseries.add(new Day(21, 2, 2002), 96.280000000000001D); timeseries.add(new Day(22, 2, 2002), 96.305000000000007D); timeseries.add(new Day(25, 2, 2002), 96.265000000000001D); timeseries.add(new Day(26, 2, 2002), 96.185000000000002D); timeseries.add(new Day(27, 2, 2002), 96.305000000000007D); timeseries.add(new Day(28, 2, 2002), 96.215000000000003D); timeseries.add(new Day(1, 3, 2002), 96.015000000000001D); timeseries.add(new Day(4, 3, 2002), 95.969999999999999D); timeseries.add(new Day(5, 3, 2002), 95.935000000000002D); timeseries.add(new Day(6, 3, 2002), 95.935000000000002D); timeseries.add(new Day(7, 3, 2002), 95.704999999999998D); timeseries.add(new Day(8, 3, 2002), 95.484999999999999D); timeseries.add(new Day(11, 3, 2002), 95.504999999999995D); timeseries.add(new Day(12, 3, 2002), 95.540000000000006D); timeseries.add(new Day(13, 3, 2002), 95.674999999999997D); timeseries.add(new Day(14, 3, 2002), 95.510000000000005D); timeseries.add(new Day(15, 3, 2002), 95.5D); timeseries.add(new Day(18, 3, 2002), 95.5D); timeseries.add(new Day(19, 3, 2002), 95.534999999999997D); timeseries.add(new Day(20, 3, 2002), 95.420000000000002D); timeseries.add(new Day(21, 3, 2002), 95.400000000000006D); timeseries.add(new Day(22, 3, 2002), 95.375D); timeseries.add(new Day(25, 3, 2002), 95.349999999999994D); timeseries.add(new Day(26, 3, 2002), 95.504999999999995D); timeseries.add(new Day(27, 3, 2002), 95.549999999999997D); timeseries.add(new Day(28, 3, 2002), 95.484999999999999D); timeseries.add(new Day(1, 4, 2002), 95.484999999999999D); timeseries.add(new Day(2, 4, 2002), 95.629999999999995D); timeseries.add(new Day(3, 4, 2002), 95.734999999999999D); timeseries.add(new Day(4, 4, 2002), 95.694999999999993D); timeseries.add(new Day(5, 4, 2002), 95.810000000000002D); timeseries.add(new Day(8, 4, 2002), 95.810000000000002D); timeseries.add(new Day(9, 4, 2002), 95.864999999999995D); timeseries.add(new Day(10, 4, 2002), 95.885000000000005D); timeseries.add(new Day(11, 4, 2002), 95.900000000000006D); timeseries.add(new Day(12, 4, 2002), 95.980000000000004D); timeseries.add(new Day(15, 4, 2002), 96.034999999999997D); timeseries.add(new Day(16, 4, 2002), 96D); timeseries.add(new Day(17, 4, 2002), 96.034999999999997D); timeseries.add(new Day(18, 4, 2002), 96.084999999999994D); timeseries.add(new Day(19, 4, 2002), 96.075000000000003D); timeseries.add(new Day(22, 4, 2002), 96.105000000000004D); timeseries.add(new Day(23, 4, 2002), 96.075000000000003D); timeseries.add(new Day(24, 4, 2002), 96.209999999999994D); timeseries.add(new Day(25, 4, 2002), 96.254999999999995D); timeseries.add(new Day(26, 4, 2002), 96.310000000000002D); timeseries.add(new Day(29, 4, 2002), 96.310000000000002D); timeseries.add(new Day(30, 4, 2002), 96.325000000000003D); timeseries.add(new Day(1, 5, 2002), 96.344999999999999D); timeseries.add(new Day(2, 5, 2002), 96.284999999999997D); timeseries.add(new Day(3, 5, 2002), 96.385000000000005D); timeseries.add(new Day(6, 5, 2002), 96.379999999999995D); timeseries.add(new Day(7, 5, 2002), 96.484999999999999D); timeseries.add(new Day(8, 5, 2002), 96.230000000000004D); timeseries.add(new Day(9, 5, 2002), 96.310000000000002D); timeseries.add(new Day(10, 5, 2002), 96.444999999999993D); timeseries.add(new Day(13, 5, 2002), 96.355000000000004D); timeseries.add(new Day(14, 5, 2002), 96.180000000000007D); timeseries.add(new Day(15, 5, 2002), 96.239999999999995D); timeseries.add(new Day(16, 5, 2002), 96.325000000000003D); timeseries.add(new Day(17, 5, 2002), 96.200000000000003D); timeseries.add(new Day(20, 5, 2002), 96.305000000000007D); timeseries.add(new Day(21, 5, 2002), 96.385000000000005D); timeseries.add(new Day(22, 5, 2002), 96.444999999999993D); timeseries.add(new Day(23, 5, 2002), 96.385000000000005D); timeseries.add(new Day(24, 5, 2002), 96.390000000000001D); timeseries.add(new Day(28, 5, 2002), 96.390000000000001D); timeseries.add(new Day(29, 5, 2002), 96.474999999999994D); timeseries.add(new Day(30, 5, 2002), 96.555000000000007D); timeseries.add(new Day(31, 5, 2002), 96.5D); timeseries.add(new Day(3, 6, 2002), 96.540000000000006D); timeseries.add(new Day(4, 6, 2002), 96.605000000000004D); timeseries.add(new Day(5, 6, 2002), 96.579999999999998D); timeseries.add(new Day(6, 6, 2002), 96.609999999999999D); timeseries.add(new Day(7, 6, 2002), 96.599999999999994D); timeseries.add(new Day(10, 6, 2002), 96.614999999999995D); timeseries.add(new Day(11, 6, 2002), 96.704999999999998D); timeseries.add(new Day(12, 6, 2002), 96.75D); timeseries.add(new Day(13, 6, 2002), 96.829999999999998D); timeseries.add(new Day(14, 6, 2002), 96.965000000000003D); timeseries.add(new Day(17, 6, 2002), 96.944999999999993D); timeseries.add(new Day(18, 6, 2002), 96.989999999999995D); timeseries.add(new Day(19, 6, 2002), 97.165000000000006D); timeseries.add(new Day(20, 6, 2002), 97.030000000000001D); timeseries.add(new Day(21, 6, 2002), 97.144999999999996D); timeseries.add(new Day(24, 6, 2002), 97.120000000000005D); timeseries.add(new Day(25, 6, 2002), 97.174999999999997D); timeseries.add(new Day(26, 6, 2002), 97.364999999999995D); timeseries.add(new Day(27, 6, 2002), 97.245000000000005D); timeseries.add(new Day(28, 6, 2002), 97.245000000000005D); timeseries.add(new Day(1, 7, 2002), 97.290000000000006D); timeseries.add(new Day(2, 7, 2002), 97.379999999999995D); timeseries.add(new Day(3, 7, 2002), 97.379999999999995D); timeseries.add(new Day(5, 7, 2002), 97.219999999999999D); timeseries.add(new Day(8, 7, 2002), 97.325000000000003D); timeseries.add(new Day(9, 7, 2002), 97.454999999999998D); timeseries.add(new Day(10, 7, 2002), 97.579999999999998D); timeseries.add(new Day(11, 7, 2002), 97.605000000000004D); timeseries.add(new Day(12, 7, 2002), 97.689999999999998D); timeseries.add(new Day(15, 7, 2002), 97.730000000000004D); timeseries.add(new Day(16, 7, 2002), 97.579999999999998D); timeseries.add(new Day(17, 7, 2002), 97.640000000000001D); timeseries.add(new Day(18, 7, 2002), 97.680000000000007D); timeseries.add(new Day(19, 7, 2002), 97.715000000000003D); timeseries.add(new Day(22, 7, 2002), 97.814999999999998D); timeseries.add(new Day(23, 7, 2002), 97.875D); timeseries.add(new Day(24, 7, 2002), 97.834999999999994D); timeseries.add(new Day(25, 7, 2002), 97.924999999999997D); timeseries.add(new Day(26, 7, 2002), 97.959999999999994D); timeseries.add(new Day(29, 7, 2002), 97.745000000000005D); timeseries.add(new Day(30, 7, 2002), 97.709999999999994D); timeseries.add(new Day(31, 7, 2002), 97.930000000000007D); timeseries.add(new Day(1, 8, 2002), 98D); timeseries.add(new Day(2, 8, 2002), 98.170000000000002D); timeseries.add(new Day(5, 8, 2002), 98.224999999999994D); timeseries.add(new Day(6, 8, 2002), 98.114999999999995D); timeseries.add(new Day(7, 8, 2002), 98.265000000000001D); timeseries.add(new Day(8, 8, 2002), 98.180000000000007D); timeseries.add(new Day(9, 8, 2002), 98.185000000000002D); timeseries.add(new Day(12, 8, 2002), 98.150000000000006D); timeseries.add(new Day(13, 8, 2002), 98.290000000000006D); timeseries.add(new Day(14, 8, 2002), 98.155000000000001D); timeseries.add(new Day(15, 8, 2002), 98.075000000000003D); timeseries.add(new Day(16, 8, 2002), 98D); timeseries.add(new Day(19, 8, 2002), 98.040000000000006D); timeseries.add(new Day(20, 8, 2002), 98.135000000000005D); timeseries.add(new Day(21, 8, 2002), 98.109999999999999D); timeseries.add(new Day(22, 8, 2002), 98.004999999999995D); timeseries.add(new Day(23, 8, 2002), 98.055000000000007D); timeseries.add(new Day(26, 8, 2002), 98.064999999999998D); timeseries.add(new Day(27, 8, 2002), 97.980000000000004D); timeseries.add(new Day(28, 8, 2002), 98.034999999999997D); timeseries.add(new Day(29, 8, 2002), 98.094999999999999D); timeseries.add(new Day(30, 8, 2002), 98.060000000000002D); timeseries.add(new Day(3, 9, 2002), 98.25D); timeseries.add(new Day(4, 9, 2002), 98.245000000000005D); timeseries.add(new Day(5, 9, 2002), 98.314999999999998D); timeseries.add(new Day(6, 9, 2002), 98.170000000000002D); timeseries.add(new Day(9, 9, 2002), 98.079999999999998D); timeseries.add(new Day(10, 9, 2002), 98.090000000000003D); timeseries.add(new Day(11, 9, 2002), 98.030000000000001D); timeseries.add(new Day(12, 9, 2002), 98.105000000000004D); timeseries.add(new Day(13, 9, 2002), 98.135000000000005D); timeseries.add(new Day(16, 9, 2002), 98.114999999999995D); timeseries.add(new Day(17, 9, 2002), 98.125D); timeseries.add(new Day(18, 9, 2002), 98.129999999999995D); timeseries.add(new Day(19, 9, 2002), 98.254999999999995D); timeseries.add(new Day(20, 9, 2002), 98.254999999999995D); timeseries.add(new Day(23, 9, 2002), 98.280000000000001D); timeseries.add(new Day(24, 9, 2002), 98.310000000000002D); timeseries.add(new Day(25, 9, 2002), 98.25D); timeseries.add(new Day(26, 9, 2002), 98.299999999999997D); timeseries.add(new Day(27, 9, 2002), 98.409999999999997D); timeseries.add(new Day(30, 9, 2002), 98.495000000000005D); timeseries.add(new Day(1, 10, 2002), 98.439999999999998D); timeseries.add(new Day(2, 10, 2002), 98.439999999999998D); timeseries.add(new Day(3, 10, 2002), 98.439999999999998D); timeseries.add(new Day(4, 10, 2002), 98.379999999999995D); timeseries.add(new Day(7, 10, 2002), 98.385000000000005D); timeseries.add(new Day(8, 10, 2002), 98.340000000000003D); timeseries.add(new Day(9, 10, 2002), 98.420000000000002D); timeseries.add(new Day(10, 10, 2002), 98.375D); timeseries.add(new Day(11, 10, 2002), 98.275000000000006D); timeseries.add(new Day(14, 10, 2002), 98.275000000000006D); timeseries.add(new Day(15, 10, 2002), 98.135000000000005D); timeseries.add(new Day(16, 10, 2002), 98.165000000000006D); timeseries.add(new Day(17, 10, 2002), 98.170000000000002D); timeseries.add(new Day(18, 10, 2002), 98.165000000000006D); timeseries.add(new Day(21, 10, 2002), 98.105000000000004D); timeseries.add(new Day(22, 10, 2002), 98.125D); timeseries.add(new Day(23, 10, 2002), 98.185000000000002D); timeseries.add(new Day(24, 10, 2002), 98.245000000000005D); timeseries.add(new Day(25, 10, 2002), 98.319999999999993D); timeseries.add(new Day(28, 10, 2002), 98.420000000000002D); timeseries.add(new Day(29, 10, 2002), 98.540000000000006D); timeseries.add(new Day(30, 10, 2002), 98.545000000000002D); timeseries.add(new Day(31, 10, 2002), 98.560000000000002D); return new TimeSeriesCollection(timeseries); }
From source file:org.jstockchart.time.SegmentedTimeSeries.java
/** * Creates a new <code>SegmentedTimeSeries</code> instance. * /*from w w w . ja v a 2 s . c o m*/ * @param name * the series name * @param timePeriodClass * the type of time period. * @param step * the time step. * @param timeline * the segmented timeline(<code>null</code> is permitted). */ public SegmentedTimeSeries(String name, int step, SegmentedTimeline timeline) { timeseries = new TimeSeries(name); this.step = step; this.timeline = timeline; }
From source file:org.jfree.chart.demo.MultipleAxisDemo4.java
private static XYDataset createDataset(String s, double d, RegularTimePeriod regulartimeperiod, int i) { TimeSeries timeseries = new TimeSeries(s); RegularTimePeriod regulartimeperiod1 = regulartimeperiod; double d1 = d; for (int j = 0; j < i; j++) { timeseries.add(regulartimeperiod1, d1); regulartimeperiod1 = regulartimeperiod1.next(); d1 *= 1.0D + (Math.random() - 0.495D) / 10D; }//from ww w . ja va 2 s. com TimeSeriesCollection timeseriescollection = new TimeSeriesCollection(); timeseriescollection.addSeries(timeseries); return timeseriescollection; }
From source file:msec.org.Tools.java
private static XYDataset createDaysDataset(ArrayList<OneDayValue> oneDayValues, GregorianCalendar startgc, OneAttrDaysChart chart) {// w w w . j av a 2s . c o m TimeSeriesCollection timeseriescollection = new TimeSeriesCollection(); TimeSeries timeseries = new TimeSeries( oneDayValues.get(0).getDate() + "-" + oneDayValues.get(oneDayValues.size() - 1).getDate()); int sum = 0; int max = 0; int min = 0; Minute current = new Minute(startgc.getTime()); for (int j = 0; j < oneDayValues.size(); j++) { int[] data = oneDayValues.get(j).getValues(); //check actual length for data int len = data.length - 1; if (j == oneDayValues.size() - 1) { //if last day is today... if (oneDayValues.get(j).getDate().equals(Tools.nowString("yyyyMMdd"))) { for (int i = len; i >= 0; i--) { if (data[i] != 0) { len = i; break; } } } } for (int i = 0; i < len; ++i) { timeseries.add(current, (double) (data[i])); sum += data[i]; max = Math.max(max, data[i]); if (min == 0) min = data[i]; else if (data[i] != 0) min = Math.min(min, data[i]); current = (Minute) current.next(); } } chart.setMax(max); chart.setMin(min); chart.setSum(sum); timeseriescollection.addSeries(timeseries); return timeseriescollection; }
From source file:net.footballpredictions.footballstats.swing.LeaguePositionGraph.java
/** * Plot league positions by date./*ww w . jav a 2 s .com*/ */ public void updateGraph(Object[] teams, LeagueSeason data) { assert teams.length > 0 : "Must be at least one team selected."; TimeSeriesCollection dataSet = new TimeSeriesCollection(); for (Object team : teams) { String teamName = (String) team; TimeSeries positionSeries = new TimeSeries(teamName); SortedMap<Date, Integer> positions = data.getTeam(teamName).getLeaguePositions(); for (Map.Entry<Date, Integer> entry : positions.entrySet()) { positionSeries.add(new Day(entry.getKey()), entry.getValue()); } dataSet.addSeries(positionSeries); } JFreeChart chart = ChartFactory.createTimeSeriesChart(null, // Title messageResources.getString("graphs.date"), messageResources.getString("combo.GraphType.LEAGUE_POSITION"), dataSet, true, // Legend. false, // Tooltips. false); // URLs. chart.getXYPlot().getRangeAxis().setInverted(true); chart.getXYPlot().getRangeAxis().setStandardTickUnits(NumberAxis.createIntegerTickUnits()); chart.getXYPlot().getRangeAxis().setRangeWithMargins(1, data.getTeamNames().size()); chart.getLegend().setPosition(legendPosition); setChart(chart); }
From source file:org.apache.phoenix.pherf.result.impl.ImageResultHandler.java
@Override public synchronized void write(Result result) throws Exception { TimeSeriesCollection timeSeriesCollection = new TimeSeriesCollection(); int rowCount = 0; int maxLegendCount = 20; int chartDimension = 1100; ResultValue<DataModelResult> resultValue = result.getResultValues().get(0); DataModelResult dataModelResult = resultValue.getResultValue(); for (ScenarioResult scenarioResult : dataModelResult.getScenarioResult()) { for (QuerySetResult querySetResult : scenarioResult.getQuerySetResult()) { for (QueryResult queryResult : querySetResult.getQueryResults()) { for (ThreadTime tt : queryResult.getThreadTimes()) { TimeSeries timeSeries = new TimeSeries( queryResult.getStatement() + " :: " + tt.getThreadName()); rowCount++;/*from w ww .j a va 2 s .c om*/ synchronized (tt.getRunTimesInMs()) { for (RunTime rt : tt.getRunTimesInMs()) { if (rt.getStartTime() != null) { timeSeries.add(new Millisecond(rt.getStartTime()), rt.getElapsedDurationInMs()); } } } timeSeriesCollection.addSeries(timeSeries); } } } } boolean legend = rowCount > maxLegendCount ? false : true; JFreeChart chart = ChartFactory.createTimeSeriesChart(dataModelResult.getName(), "Time", "Query Time (ms)", timeSeriesCollection, legend, true, false); StandardXYItemRenderer renderer = new StandardXYItemRenderer(StandardXYItemRenderer.SHAPES_AND_LINES); chart.getXYPlot().setRenderer(renderer); chart.getXYPlot().setBackgroundPaint(Color.WHITE); chart.getXYPlot().setRangeGridlinePaint(Color.BLACK); for (int i = 0; i < rowCount; i++) { chart.getXYPlot().getRenderer().setSeriesStroke(i, new BasicStroke(3f)); } try { ChartUtilities.saveChartAsJPEG(new File(resultFileName), chart, chartDimension, chartDimension); } catch (IOException e) { e.printStackTrace(); } }