List of usage examples for org.jfree.data.xy XYSeriesCollection addSeries
public void addSeries(XYSeries series)
From source file:logica.LGraficaAltura.java
public static void logicaBtnGraficar(JRadioButton jRLinea) { ChartPanel panel;/*from w ww . j a v a2 s . c o m*/ JFreeChart chart = null; if (jRLinea.isSelected()) { // ejecuto linea XYSplineRenderer graficoLinea = new XYSplineRenderer(); XYSeriesCollection dataset = new XYSeriesCollection(); ValueAxis x = new NumberAxis(); ValueAxis y = new NumberAxis(); XYSeries serie = new XYSeries("Datos"); XYPlot plot; graficoLinea.setSeriesPaint(0, Color.YELLOW); VGraficaAltura.getPanelLinea().removeAll(); for (int i = 0; i < VGraficaAltura.getjTable1().getRowCount(); i++) { float valor1 = Float.parseFloat(String.valueOf(VGraficaAltura.getjTable1().getValueAt(i, 0))); float valor2 = Float.parseFloat(String.valueOf(VGraficaAltura.getjTable1().getValueAt(i, 1))); System.out.println("valores " + valor1 + " " + valor2); serie.add(valor1, valor2); } dataset.addSeries(serie); x.setLabel("MES"); y.setLabel("ALTURA"); plot = new XYPlot(dataset, x, y, graficoLinea); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setRange(15, 30); chart = new JFreeChart(plot); chart.setTitle("grafico"); panel = new ChartPanel(chart); panel.setBounds(5, 10, 410, 350); VGraficaAltura.getPanelLinea().add(panel); VGraficaAltura.getPanelLinea().repaint(); } }
From source file:tools.descartes.bungee.chart.ChartGenerator.java
public static JFreeChart mappingChart(final IntensityDemandMapping mapping) { final XYSeriesCollection dataset = new XYSeriesCollection(); final XYSeries mappingSeries = new XYSeries("mapping function"); double lastIntentsity = 0; for (IntensityResourcePair pair : mapping.getMappingList()) { mappingSeries.add(lastIntentsity, pair.resourceAmount); mappingSeries.add(pair.maxIntensity, pair.resourceAmount); lastIntentsity = pair.maxIntensity; }//w w w. j av a 2 s . co m dataset.addSeries(mappingSeries); final JFreeChart chart = ChartFactory.createXYLineChart("", "Load Intensity", "Resource Amount", dataset); chartCustomization(chart); chart.getXYPlot().getRenderer().setSeriesPaint(0, Color.BLUE); chart.getXYPlot().getRenderer().setSeriesStroke(0, new BasicStroke(STROKE_WIDTH)); NumberAxis rangeAxis = (NumberAxis) chart.getXYPlot().getRangeAxis(); rangeAxis.setTickUnit(new NumberTickUnit(1)); return chart; }
From source file:com.jolbox.benchmark.BenchmarkLaunch.java
/** * @param results//from w ww .ja v a 2 s. c o m * @param delay * @param statementBenchmark * @param noC3P0 * @throws IOException */ private static void doPlotLineGraph(long[][] results, int delay, boolean statementBenchmark, boolean noC3P0) throws IOException { String title = "Multi-Thread test (" + delay + "ms delay)"; if (statementBenchmark) { title += "\n(with PreparedStatements tests)"; } String fname = System.getProperty("java.io.tmpdir") + File.separator + "bonecp-multithread-" + delay + "ms-delay"; if (statementBenchmark) { fname += "-with-preparedstatements"; } fname += "-poolsize-" + BenchmarkTests.pool_size + "-threads-" + BenchmarkTests.threads; if (noC3P0) { fname += "-noC3P0"; } PrintWriter out = new PrintWriter(new FileWriter(fname + ".txt")); fname += ".png"; XYSeriesCollection dataset = new XYSeriesCollection(); for (int i = 0; i < ConnectionPoolType.values().length; i++) { // if (!ConnectionPoolType.values()[i].isEnabled() || (noC3P0 && ConnectionPoolType.values()[i].equals(ConnectionPoolType.C3P0))) { continue; } XYSeries series = new XYSeries(ConnectionPoolType.values()[i].toString()); out.println(ConnectionPoolType.values()[i].toString()); for (int j = 1 + BenchmarkTests.stepping; j < results[i].length; j += BenchmarkTests.stepping) { series.add(j, results[i][j]); out.println(j + "," + results[i][j]); } dataset.addSeries(series); } out.close(); // Generate the graph JFreeChart chart = ChartFactory.createXYLineChart(title, // Title "threads", // x-axis Label "time (ns)", // y-axis Label dataset, // Dataset PlotOrientation.VERTICAL, // Plot Orientation true, // Show Legend true, // Use tooltips false // Configure chart to generate URLs? ); XYPlot plot = (XYPlot) chart.getPlot(); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(true, false); plot.setRenderer(renderer); renderer.setSeriesPaint(0, Color.BLUE); renderer.setSeriesPaint(1, Color.YELLOW); renderer.setSeriesPaint(2, Color.BLACK); renderer.setSeriesPaint(3, Color.DARK_GRAY); renderer.setSeriesPaint(4, Color.MAGENTA); renderer.setSeriesPaint(5, Color.RED); renderer.setSeriesPaint(6, Color.LIGHT_GRAY); // renderer.setSeriesShapesVisible(1, true); // renderer.setSeriesShapesVisible(2, true); try { ChartUtilities.saveChartAsPNG(new File(fname), chart, 1024, 768); System.out.println("******* Saved chart to: " + fname); } catch (IOException e) { System.err.println("Problem occurred creating chart."); } }
From source file:ca.nengo.plot.impl.DefaultPlotter.java
private static XYSeriesCollection getDataset(SpikePattern pattern) { XYSeriesCollection dataset = new XYSeriesCollection(); for (int i = 0; i < pattern.getNumNeurons(); i++) { XYSeries series = new XYSeries("Neuron " + i); float[] spikes = pattern.getSpikeTimes(i); for (int j = 0; j < spikes.length; j++) { series.add(spikes[j], i);// ww w.j av a2 s . c om } dataset.addSeries(series); } return dataset; }
From source file:de.hs.mannheim.modUro.controller.diagram.ModeltypeDiagramController.java
/** * Creates Dataset.//from ww w . j a v a2 s . c o m * * @return */ private static XYDataset createDataset(List<Simulation> simulationList, String selectedItem) { XYSeriesCollection dataset = new XYSeriesCollection(); for (Simulation simualtionItem : simulationList) { XYSeries xySerie = new XYSeries(simualtionItem.getSimulationName()); for (StatisticValues metricTypeItem : simualtionItem.getMetricTypes()) { if (metricTypeItem.getName().equals(selectedItem)) { double x; double y; double[][] fitnessArray = ((MetricType) metricTypeItem).getMetricData(); for (int i = 0; i < fitnessArray.length; i++) { x = fitnessArray[i][0]; y = fitnessArray[i][1]; xySerie.add(x, y); } } } dataset.addSeries(xySerie); } return dataset; }
From source file:org.matsim.contrib.parking.parkingchoice.lib.GeneralLib.java
public static void generateXYScatterPlot(String fileName, double[] x, double[] y, String title, String xLabel, String yLabel) {//from w w w.j a v a 2 s . co m if (x.length != y.length) { DebugLib.stopSystemAndReportInconsistency("dimensions of arrays do not match"); } final XYSeries series1 = new XYSeries(title); for (int i = 0; i < x.length; i++) { series1.add(x[i], y[i]); } final XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(series1); final JFreeChart chart = ChartFactory.createXYLineChart(title, xLabel, yLabel, dataset, PlotOrientation.VERTICAL, true, true, false); chart.setBackgroundPaint(Color.white); final XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setSeriesLinesVisible(0, false); renderer.setSeriesShapesVisible(1, false); plot.setRenderer(renderer); final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); int width = 500; int height = 300; try { ChartUtilities.saveChartAsPNG(new File(fileName), chart, width, height); } catch (IOException e) { } }
From source file:cn.InstFS.wkr.NetworkMining.UIs.TimeSeriesChart1.java
public static XYDataset createmodeDataset(DataItems normal, long offset1, String protocol2, long unit) { // ???//from ww w . j a va 2 s .c o m int length = normal.getLength(); int time[] = new int[length]; XYSeries xyseries = new XYSeries(protocol2); XYSeriesCollection xyseriescollection = new XYSeriesCollection(); // ?? long offset2 = normal.getElementAt(0).getTime().getTime(); int off = (int) ((offset2 - offset1) / unit); for (int i = 0; i < length; i++) { DataItem temp = new DataItem(); temp = normal.getElementAt(i); /* * if(i==0){ System.out.println("DataItem.time="+temp.getTime()); * } */ xyseries.add(i + off, Double.parseDouble(temp.getData())); // } xyseriescollection.addSeries(xyseries); return xyseriescollection; }
From source file:scatterplot1k.JFreeScatter2.java
private XYDataset createDataset() { XYSeriesCollection result = new XYSeriesCollection(); result.addSeries(populateData()); return result; }
From source file:org.jfree.chart.demo.MouseListenerDemo4.java
public XYDataset createDataset() { XYSeries xyseries = new XYSeries("Series 1"); xyseries.add(12.5D, 11D);/*from w ww.j av a 2 s.c om*/ xyseries.add(15D, 9.3000000000000007D); xyseries.add(20D, 21D); XYSeriesCollection xyseriescollection = new XYSeriesCollection(); xyseriescollection.addSeries(xyseries); return xyseriescollection; }
From source file:org.chocosolver.gui.panels.DepthPanel.java
public DepthPanel(GUI frame) { super(frame); depth = new XYSeries("Depth"); XYSeriesCollection scoll = new XYSeriesCollection(); scoll.addSeries(depth); JFreeChart chart = ChartFactory.createXYLineChart("Depth", "Nodes", "Depth", scoll); this.setChart(chart); solver.plugMonitor(this); }