List of usage examples for org.jfree.data.xy XYSeries XYSeries
public XYSeries(Comparable key)
From source file:org.uncommons.maths.demo.GraphPanel.java
public void generateGraph(String title, Map<Double, Double> observedValues, Map<Double, Double> expectedValues, double expectedMean, double expectedStandardDeviation, boolean discrete) { XYSeriesCollection dataSet = new XYSeriesCollection(); XYSeries observedSeries = new XYSeries("Observed"); dataSet.addSeries(observedSeries);/*www .j a v a 2 s. c o m*/ XYSeries expectedSeries = new XYSeries("Expected"); dataSet.addSeries(expectedSeries); for (Map.Entry<Double, Double> entry : observedValues.entrySet()) { observedSeries.add(entry.getKey(), entry.getValue()); } for (Map.Entry<Double, Double> entry : expectedValues.entrySet()) { expectedSeries.add(entry.getKey(), entry.getValue()); } JFreeChart chart = ChartFactory.createXYLineChart(title, "Value", "Probability", dataSet, PlotOrientation.VERTICAL, true, false, false); XYPlot plot = (XYPlot) chart.getPlot(); if (discrete) { // Render markers at each data point (these discrete points are the // distibution, not the lines between them). plot.setRenderer(new XYLineAndShapeRenderer()); } else { // Render smooth lines between points for a continuous distribution. XYSplineRenderer renderer = new XYSplineRenderer(); renderer.setBaseShapesVisible(false); plot.setRenderer(renderer); } chartPanel.setChart(chart); }
From source file:statistic.graph.JChartPanel.java
public void add(String key, double value) { XYSeries series = new XYSeries(key); stepDataset.addSeries(series);//from ww w .j a va2 s .c om series.add(Integer.MIN_VALUE, 0); series.add(0, value); series.add(Integer.MAX_VALUE, value); }
From source file:org.azrul.langmera.LineChart.java
/** * Creates a sample dataset./*from w ww. j a v a 2 s . c om*/ * * @return a sample dataset. */ public XYDataset createDataset(Map<String, List<Double>> dataList) { final XYSeriesCollection dataset = new XYSeriesCollection(); for (String key : dataList.keySet()) { final XYSeries series = new XYSeries(key); int maxT = dataList.get(key).size(); for (int j = 0; j < (maxT - 1); j++) { Double v = dataList.get(key).get(j) * 100.0; series.add((double) j, (double) (v)); } dataset.addSeries(series); } return dataset; }
From source file:net.relet.freimap.NodeInfo.java
public void setLinkCountProfile(LinkedList<LinkCount> lcp) { if (lcp.size() == 0) { minLinks = 0;// w w w.jav a2 s .c o m maxLinks = 0; return; } XYSeries data = new XYSeries("links"); XYSeries avail = new XYSeries("avail"); XYSeriesCollection datac = new XYSeriesCollection(data); datac.addSeries(avail); linkCountChart = ChartFactory.createXYLineChart("average incoming link count\r\nincoming link availability", "time", "count", datac, PlotOrientation.VERTICAL, false, false, false); sexupLayout(linkCountChart); long first = lcp.getFirst().time, last = lcp.getLast().time, lastClock = first, count = 0, maxCount = 0; long aggregate = (last - first) / CHART_WIDTH; double sum = 0; /* ok, this ain't effective, we do it just to pre-calculate maxCount */ ListIterator<LinkCount> li = lcp.listIterator(); while (li.hasNext()) { LinkCount lc = li.next(); count++; if (lc.time - lastClock > aggregate) { if (maxCount < count) maxCount = count; lastClock = lc.time; count = 0; } } //reset for second iteration count = 0; lastClock = first; //iterate again li = lcp.listIterator(); while (li.hasNext()) { LinkCount lc = li.next(); if (minLinks > lc.count) minLinks = lc.count; if (maxLinks < lc.count) maxLinks = lc.count; sum += lc.count; count++; if (aggregate == 0) aggregate = 1000;//dirty hack if (lc.time - lastClock > aggregate) { for (long i = lastClock; i < lc.time - aggregate; i += aggregate) { data.add(i * 1000, (i == lastClock) ? sum / count : Double.NaN); avail.add(i * 1000, (i == lastClock) ? ((double) count / maxCount) : 0); } count = 0; sum = 0; lastClock = lc.time; } } status = STATUS_AVAILABLE; }
From source file:org.portico.pgauge.gui.LatencyChart.java
public LatencyChart(LatencyDataset rawdata, PGConfiguration configuration) { this.rawdata = rawdata; this.series = new XYSeries("Iterations"); this.dataset = new XYSeriesCollection(series); backfill(); // will initialize dataset // create the chart String title = "Round-Trip Latency (" + configuration.getPayloadSizeAsString() + " packets)"; this.chart = ChartFactory.createXYLineChart(title, "Iterations", "Latency (microseconds)", dataset, PlotOrientation.VERTICAL, false, // legend true, // tooltips false); // urls // set max at 3 standard deviations from mean long max = rawdata.getAverage() + (long) (3 * rawdata.getStandardDeviation()); chart.getXYPlot().getRangeAxis().setRange(0, max); this.panel = new ChartPanel(this.chart); getContentPane().add(this.panel); this.pack();/*from w w w .j av a 2 s. c o m*/ this.setVisible(true); }
From source file:it.unifi.rcl.chess.traceanalysis.gui.Plotter.java
public static XYSeries traceToSeries(Trace t) { XYSeries s = new XYSeries(t.getName()); for (int i = 0; i < t.getSampleSize(); i++) { s.add(i + 1, t.getValueAt(i));//w w w . java 2 s. c o m } return s; }
From source file:de.hs.mannheim.modUro.reader.JCellCountDiagram.java
private XYDataset createDataset(List<String> cellTypes, List<CellCountEntry> cellcountList) { XYSeriesCollection dataset = new XYSeriesCollection(); XYSeries xySerieSum = new XYSeries("total"); for (String cellType : cellTypes) { XYSeries xySerie = new XYSeries(cellType); for (CellCountEntry e : cellcountList) { double x = e.time; double y = 0; if (e.count.containsKey(cellType)) { y = (double) e.count.get(cellType); }/*from w ww . jav a 2 s . c o m*/ xySerie.add(x, y); } dataset.addSeries(xySerie); } for (CellCountEntry e : cellcountList) { double x = e.time; double y = e.count.values().stream().mapToDouble(i -> i.intValue()).sum(); if (y != Double.NaN) { xySerieSum.add(x, y); } } dataset.addSeries(xySerieSum); return dataset; }
From source file:cv.mikusher.freechart.XYLineChart.java
private XYDataset createDataset() { final XYSeries firefox = new XYSeries("Firefox"); firefox.add(1.0, 1.0);// ww w . j a va 2s . co m firefox.add(2.0, 4.0); firefox.add(3.0, 3.0); final XYSeries chrome = new XYSeries("Chrome"); chrome.add(1.0, 4.0); chrome.add(2.0, 5.0); chrome.add(3.0, 6.0); final XYSeries iexplorer = new XYSeries("InternetExplorer"); iexplorer.add(3.0, 4.0); iexplorer.add(4.0, 5.0); iexplorer.add(5.0, 4.0); final XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(firefox); dataset.addSeries(chrome); dataset.addSeries(iexplorer); return dataset; }
From source file:org.portico.pgauge.gui.ThroughputChart.java
public ThroughputChart(ThroughputDataset rawdata, PGConfiguration configuration) { this.rawdata = rawdata; this.series = new XYSeries("Iterations"); this.dataset = new XYSeriesCollection(series); backfill();//from w w w.ja v a 2s .c o m // create the chart String title = "Attribute Updates for " + configuration.getFederateName() + " (" + configuration.getPayloadSizeAsString() + " packets)"; this.chart = ChartFactory.createXYLineChart(title, "Iterations", "Time to Complete (ms)", dataset, PlotOrientation.VERTICAL, false, // legend true, // tooltips false); // urls this.panel = new ChartPanel(this.chart); getContentPane().add(this.panel); this.pack(); this.setVisible(true); }
From source file:udpserver.UDPui.java
/** * Creates new form UDPui//from www . j av a 2 s . c o m */ public UDPui() { // <editor-fold defaultstate="collapsed" desc="Graph"> series = new XYSeries("ECG Reading"); series.setMaximumItemCount(50); XYSeriesCollection dataset = new XYSeriesCollection(series); JFreeChart chart = ChartFactory.createXYLineChart("ECG Reading", "Time (seconds)", "Voltage (volt)", dataset); final XYPlot plot = chart.getXYPlot(); NumberAxis domain = (NumberAxis) plot.getDomainAxis(); JPanel jPanel1 = new JPanel(); jPanel1.setLayout(new java.awt.BorderLayout()); jPanel1.setVisible(true); jPanel1.setSize(600, 500); jPanel1.add(new ChartPanel(chart), BorderLayout.CENTER); jPanel1.validate(); add(jPanel1); // </editor-fold> initComponents(); receiveUDP(); // tempReceiveUDP(); // new UDPServer(valuePane); }