List of usage examples for org.jfree.data.time TimeSeriesCollection TimeSeriesCollection
public TimeSeriesCollection()
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);/* w w w. ja v a 2 s.co 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:WeatherFrame.java
public WeatherFrame() { initComponents();/*from ww w . j a va 2 s . c o m*/ fc = new JFileChooser(); fc.setMultiSelectionEnabled(true); //only can select a single button a time ButtonGroup group = new ButtonGroup(); group.add(AllRadioButton); group.add(YearlyRadioButton); group.add(MonthlyRadioButton); group.add(WeeklyRadioButton); group.add(DailyRadioButton); jComboBox1.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Temperature", "Humidity", "Barometric Pressure", "Windspeed", "UVindex", "Raindfall" })); TempSet = new TimeSeriesCollection(); JFreeChart chart = ChartFactory.createXYLineChart("Temperature", "", "Degree Fahrenheit", TempSet, PlotOrientation.VERTICAL, true, true, false); chart.setBackgroundPaint(Color.white); ChartPanel.setLayout(new java.awt.BorderLayout()); ChartPanel CP = new ChartPanel(chart); CP.setPreferredSize(new Dimension(ChartPanel.getWidth(), ChartPanel.getHeight())); ChartPanel.add(CP, BorderLayout.CENTER); DefaultValueDataset dataset = new DefaultValueDataset(20f); ThermometerPlot thermometerplot = new ThermometerPlot(dataset); JFreeChart jfreechart = new JFreeChart("", JFreeChart.DEFAULT_TITLE_FONT, thermometerplot, true); jfreechart.setBackgroundPaint(new Color(240, 240, 240)); thermometerplot.setThermometerPaint(Color.lightGray); thermometerplot.setThermometerStroke(new BasicStroke(2.0F)); ChartPanel DP = new ChartPanel(jfreechart); DP.setPreferredSize(new Dimension(TempThermoPanel.getWidth(), TempThermoPanel.getHeight())); TempThermoPanel.setLayout(new java.awt.BorderLayout()); TempThermoPanel.add(DP); TempThermoPanel.validate(); }
From source file:grafix.graficos.comparativo.ConstrutorGraficoComparativos.java
private XYDataset criarDataset() { TimeSeriesCollection tc = new TimeSeriesCollection(); for (IndiceComparativo elem : indices) { TimeSeries tSerie = elem.getTimeSeries(); tc.addSeries(tSerie);/*from w w w. ja v a 2s. c om*/ } return tc; }
From source file:es.bsc.autonomic.powermodeller.graphics.TotalPowerAndPredictionDifference.java
private static XYDataset dataSetToJFreeChartXYDataSet(DataSet ds) { TimeSeries pactual = new TimeSeries(CoreConfiguration.PACTUAL_LABEL); TimeSeries ppredicted = new TimeSeries(CoreConfiguration.PPREDICTED_LABEL); double d = 0.0D; double d1 = 0.0D; Day day = new Day(); List<Double> pactualCol = ds.getCol(CoreConfiguration.PACTUAL_LABEL); List<Double> ppredictedCol = ds.getCol(CoreConfiguration.PPREDICTED_LABEL); for (int i = 0; i < ds.getSize(); i++) { pactual.add(day, pactualCol.get(i)); ppredicted.add(day, ppredictedCol.get(i)); day = (Day) day.next();/*from w w w .j a va2 s . c o m*/ } TimeSeriesCollection timeseriescollection = new TimeSeriesCollection(); timeseriescollection.addSeries(pactual); timeseriescollection.addSeries(ppredicted); return timeseriescollection; }
From source file:org.squale.squaleweb.util.graph.HistoMaker.java
/** * constructeur par dfaut */ public HistoMaker() { mDataSet = new TimeSeriesCollection(); }
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 ww w . j ava 2 s . com*/ 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: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:uk.co.petertribble.jkstat.demo.JLoadChart.java
/** * A standalone demo charting load averages. *//* www . j ava 2s .co 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(); }
From source file:com.charts.FiveDayChart.java
public FiveDayChart(YStockQuote currentStock) { TimeSeries series = new TimeSeries(currentStock.get_name()); ArrayList<String> fiveDayData = currentStock.get_five_day_data(); int length = fiveDayData.size(); for (int i = 22; i < length; i += 5) { String[] data = fiveDayData.get(i).split(","); Date time = new Date((long) Integer.parseInt(data[0]) * 1000); DateFormat df = new SimpleDateFormat("MM-dd-yyyy-h-m"); series.addOrUpdate(new Minute(time), Double.parseDouble(data[1])); }//from www.j a v a 2s. c om String[] data = fiveDayData.get(length - 1).split(","); Date time = new Date((long) Integer.parseInt(data[0]) * 1000); DateFormat df = new SimpleDateFormat("MM-dd-yyyy-h-m"); series.addOrUpdate(new Minute(time), Double.parseDouble(data[1])); TimeSeriesCollection dataset = new TimeSeriesCollection(); dataset.addSeries(series); JFreeChart chart = ChartFactory.createTimeSeriesChart( currentStock.get_name() + "(" + currentStock.get_symbol() + ")" + " Five Day", "Date", "Price", dataset, true, true, false); XYPlot plot = (XYPlot) chart.getPlot(); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); ValueAxis yAxis = (ValueAxis) plot.getRangeAxis(); DateAxis xAxis = (DateAxis) plot.getDomainAxis(); Date now = new Date(); SegmentedTimeline segmentedTimeline = SegmentedTimeline.newFifteenMinuteTimeline(); segmentedTimeline.addBaseTimelineExclusions(segmentedTimeline.getStartTime(), now.getTime()); Calendar[][] holidays = DayRange.getHolidayDates(); for (int i = 0; i < holidays[0].length; i++) { Calendar day = Calendar.getInstance(); day.set(Calendar.YEAR, holidays[0][i].get(Calendar.YEAR)); day.set(Calendar.MONTH, holidays[0][i].get(Calendar.MONTH)); day.set(Calendar.DAY_OF_MONTH, holidays[0][i].get(Calendar.DAY_OF_MONTH)); day.set(Calendar.HOUR_OF_DAY, 9); segmentedTimeline.addException(day.getTimeInMillis(), day.getTimeInMillis() + 21600000); } xAxis.setTimeline(segmentedTimeline); xAxis.setTickMarkPosition(DateTickMarkPosition.MIDDLE); //xAxis.setVerticalTickLabels(true); xAxis.setDateFormatOverride(new SimpleDateFormat("MM-dd")); xAxis.setAutoTickUnitSelection(false); xAxis.setAutoRange(false); StandardXYItemRenderer renderer1 = new StandardXYItemRenderer(); renderer1.setSeriesPaint(0, Color.BLUE); TimeSeries movingAverage5 = MovingAverage.createMovingAverage(series, "MA(5)", 30, 0); Double currMA5 = (Double) movingAverage5.getDataItem(movingAverage5.getItemCount() - 1).getValue(); currMA5 = Math.round(currMA5 * 100.0) / 100.0; movingAverage5.setKey("MA(5): " + currMA5); TimeSeriesCollection collection = new TimeSeriesCollection(); collection.addSeries(movingAverage5); plot.setDataset(1, collection); plot.setRenderer(1, renderer1); plot.setBackgroundPaint(Color.WHITE); chartPanel = new ChartPanel(chart); chart.setBackgroundPaint(chartPanel.getBackground()); plot.setDomainGridlinePaint(Color.lightGray); plot.setRangeGridlinePaint(Color.lightGray); chartPanel.setVisible(true); chartPanel.revalidate(); chartPanel.repaint(); }
From source file:net.footballpredictions.footballstats.swing.LeaguePositionGraph.java
/** * Plot league positions by date.// w w w. j a v a2 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); }