List of usage examples for org.jfree.data.xy XYSeriesCollection XYSeriesCollection
public XYSeriesCollection()
From source file:org.jfree.chart.demo.PolarChartDemo1.java
private static XYDataset createDataset() { XYSeriesCollection xyseriescollection = new XYSeriesCollection(); XYSeries xyseries = new XYSeries("Series 1"); xyseries.add(0.0D, 2D);//w ww. j a v a 2 s .c o m xyseries.add(90D, 13D); xyseries.add(180D, 9D); xyseries.add(270D, 8D); xyseriescollection.addSeries(xyseries); XYSeries xyseries1 = new XYSeries("Series 2"); xyseries1.add(90D, -11.199999999999999D); xyseries1.add(180D, 21.399999999999999D); xyseries1.add(250D, 17.300000000000001D); xyseries1.add(355D, 10.9D); xyseriescollection.addSeries(xyseries1); return xyseriescollection; }
From source file:it.unifi.rcl.chess.traceanalysis.gui.Plotter.java
public static JPanel assemblePlot(XYSeries series[]) { // Add the series to your data set XYSeriesCollection dataset = new XYSeriesCollection(); for (int i = 0; i < series.length; i++) { dataset.addSeries(series[i]);//from w ww . ja va 2s. co m } // Generate the graph JFreeChart chart = ChartFactory.createXYLineChart("XY Chart", // Title "x-axis", // x-axis Labels "y-axis", // y-axis Label dataset, // Dataset PlotOrientation.VERTICAL, // Plot Orientation false, // Show Legend true, // Use tooltips false // Configure chart to generate URLs? ); return new ChartPanel(chart); }
From source file:com.imaging100x.tracker.TrackerUtils.java
/** * Create a frame with a plot of the data given in XYSeries */// w w w . j a v a 2s.c o m public static void plotData(String title, final XYSeries data, String xTitle, String yTitle, int xLocation, int yLocation) { // JFreeChart code XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(data); JFreeChart chart = ChartFactory.createScatterPlot(title, // Title xTitle, // x-axis Label yTitle, // y-axis Label dataset, // Dataset PlotOrientation.VERTICAL, // Plot Orientation false, // Show Legend true, // Use tooltips false // Configure chart to generate URLs? ); final XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.white); plot.setRangeGridlinePaint(Color.lightGray); XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer(); renderer.setBaseShapesVisible(true); renderer.setSeriesPaint(0, Color.black); renderer.setSeriesFillPaint(0, Color.white); renderer.setSeriesLinesVisible(0, true); Shape circle = new Ellipse2D.Float(-2.0f, -2.0f, 4.0f, 4.0f); renderer.setSeriesShape(0, circle, false); renderer.setUseFillPaint(true); ChartFrame graphFrame = new ChartFrame(title, chart); graphFrame.getChartPanel().setMouseWheelEnabled(true); graphFrame.setPreferredSize(new Dimension(SIZE, SIZE)); graphFrame.setResizable(true); graphFrame.pack(); graphFrame.setLocation(xLocation, yLocation); graphFrame.setVisible(true); dataset.addChangeListener(new DatasetChangeListener() { public void datasetChanged(DatasetChangeEvent dce) { double xRange = data.getMaxX() - data.getMinX(); double yRange = data.getMaxY() - data.getMinY(); double xAvg = (data.getMaxX() + data.getMinX()) / 2; double yAvg = (data.getMaxY() + data.getMinY()) / 2; double range = xRange; if (yRange > range) { range = yRange; } double offset = 0.55 * range; plot.getDomainAxis().setRange(xAvg - offset, xAvg + offset); plot.getRangeAxis().setRange(yAvg - offset, yAvg + offset); } }); }
From source file:org.jfree.chart.demo.AnnotationDemo1.java
private static XYSeriesCollection createDataset() { XYSeriesCollection xyseriescollection = new XYSeriesCollection(); try {/*from w ww .j av a 2 s . com*/ BufferedReader bufferedreader = new BufferedReader( new InputStreamReader(AnnotationDemo1.class.getResourceAsStream("wtageinf.txt"))); bufferedreader.readLine(); bufferedreader.readLine(); bufferedreader.readLine(); bufferedreader.readLine(); XYSeries xyseries = new XYSeries("P3", true, false); XYSeries xyseries1 = new XYSeries("P5", true, false); XYSeries xyseries2 = new XYSeries("P10", true, false); XYSeries xyseries3 = new XYSeries("P25", true, false); XYSeries xyseries4 = new XYSeries("P50", true, false); XYSeries xyseries5 = new XYSeries("P75", true, false); XYSeries xyseries6 = new XYSeries("P90", true, false); XYSeries xyseries7 = new XYSeries("P95", true, false); XYSeries xyseries8 = new XYSeries("P97", true, false); for (String s1 = bufferedreader.readLine(); s1 != null; s1 = bufferedreader.readLine()) { int i = Integer.parseInt(s1.substring(1, 8).trim()); float f = Float.parseFloat(s1.substring(9, 17).trim()); float f1 = Float.parseFloat(s1.substring(69, 86).trim()); float f2 = Float.parseFloat(s1.substring(87, 103).trim()); float f3 = Float.parseFloat(s1.substring(104, 122).trim()); float f4 = Float.parseFloat(s1.substring(123, 140).trim()); float f5 = Float.parseFloat(s1.substring(141, 158).trim()); float f6 = Float.parseFloat(s1.substring(159, 176).trim()); float f7 = Float.parseFloat(s1.substring(177, 193).trim()); float f8 = Float.parseFloat(s1.substring(194, 212).trim()); float f9 = Float.parseFloat(s1.substring(212, s1.length()).trim()); if (i == 1) { xyseries.add(f, f1); xyseries1.add(f, f2); xyseries2.add(f, f3); xyseries3.add(f, f4); xyseries4.add(f, f5); xyseries5.add(f, f6); xyseries6.add(f, f7); xyseries7.add(f, f8); xyseries8.add(f, f9); } } xyseriescollection.addSeries(xyseries); xyseriescollection.addSeries(xyseries1); xyseriescollection.addSeries(xyseries2); xyseriescollection.addSeries(xyseries3); xyseriescollection.addSeries(xyseries4); xyseriescollection.addSeries(xyseries5); xyseriescollection.addSeries(xyseries6); xyseriescollection.addSeries(xyseries7); xyseriescollection.addSeries(xyseries8); } catch (FileNotFoundException filenotfoundexception) { System.err.println(filenotfoundexception); } catch (IOException ioexception) { System.err.println(ioexception); } return xyseriescollection; }
From source file:logica.LGraficapeso.java
public static void logicaBtnGraficar(JRadioButton jRLinea) { ChartPanel panel;//from www .j av a 2s. 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); VGraficaPeso.getPanelLinea().removeAll(); for (int i = 0; i < VGraficaPeso.getjTable1().getRowCount(); i++) { float valor1 = Float.parseFloat(String.valueOf(VGraficaPeso.getjTable1().getValueAt(i, 0))); float valor2 = Float.parseFloat(String.valueOf(VGraficaPeso.getjTable1().getValueAt(i, 1))); System.out.println("valores " + valor1 + " " + valor2); serie.add(valor1, valor2); } dataset.addSeries(serie); x.setLabel("MES"); y.setLabel("peso"); plot = new XYPlot(dataset, x, y, graficoLinea); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setRange(10, 15); chart = new JFreeChart(plot); chart.setTitle("grafico"); panel = new ChartPanel(chart); panel.setBounds(5, 10, 410, 350); VGraficaPeso.getPanelLinea().add(panel); VGraficaPeso.getPanelLinea().repaint(); } }
From source file:logica.LGraficaAltura.java
public static void logicaBtnGraficar(JRadioButton jRLinea) { ChartPanel panel;// w w w . j av a2 s . c om 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:eu.cassandra.csn.gui.Charts.java
/** * /*from ww w . ja va2 s. c om*/ * @param title * @param x * @param y * @param data * @return */ public static ChartPanel createGraph(String title, String x, String y, Double[] data) { XYSeries series1 = new XYSeries("First"); for (int i = 0; i < data.length; i++) { series1.add(i, data[i]); } final XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(series1); PlotOrientation orientation = PlotOrientation.VERTICAL; boolean show = false; boolean toolTips = false; boolean urls = false; JFreeChart chart = ChartFactory.createXYLineChart(title, x, y, dataset, orientation, show, toolTips, urls); //XYPlot plot = (XYPlot) chart.getPlot(); ChartPanel cp = new ChartPanel(chart); return cp; }
From source file:org.jfree.chart.demo.GridBandDemo1.java
public static JPanel createDemoPanel() { XYSeries xyseries = new XYSeries("Random Data"); for (int i = 0; i < 100; i++) xyseries.add(Math.random() + 1.0D, Math.random() + 1.0D); XYSeriesCollection xyseriescollection = new XYSeriesCollection(); xyseriescollection.addSeries(xyseries); JFreeChart jfreechart = createChart(xyseriescollection); ChartPanel chartpanel = new ChartPanel(jfreechart); return chartpanel; }
From source file:graficos.GraficoTeste.java
public GraficoTeste(String title, String labelX, String labelY) { datasets = new XYSeriesCollection(); grafico = ChartFactory.createXYLineChart(title, labelY, labelY, datasets); }
From source file:org.jfree.chart.demo.NormalDistributionDemo2.java
public static XYDataset createDataset() { XYSeriesCollection xyseriescollection = new XYSeriesCollection(); NormalDistributionFunction2D normaldistributionfunction2d = new NormalDistributionFunction2D(0.0D, 1.0D); org.jfree.data.xy.XYSeries xyseries = DatasetUtilities.sampleFunction2DToSeries( normaldistributionfunction2d, -5.0999999999999996D, 5.0999999999999996D, 121, "N1"); xyseriescollection.addSeries(xyseries); NormalDistributionFunction2D normaldistributionfunction2d1 = new NormalDistributionFunction2D(0.0D, Math.sqrt(0.20000000000000001D)); org.jfree.data.xy.XYSeries xyseries1 = DatasetUtilities.sampleFunction2DToSeries( normaldistributionfunction2d1, -5.0999999999999996D, 5.0999999999999996D, 121, "N2"); xyseriescollection.addSeries(xyseries1); NormalDistributionFunction2D normaldistributionfunction2d2 = new NormalDistributionFunction2D(0.0D, Math.sqrt(5D));/*from w w w . j a va 2 s . c o m*/ org.jfree.data.xy.XYSeries xyseries2 = DatasetUtilities.sampleFunction2DToSeries( normaldistributionfunction2d2, -5.0999999999999996D, 5.0999999999999996D, 121, "N3"); xyseriescollection.addSeries(xyseries2); NormalDistributionFunction2D normaldistributionfunction2d3 = new NormalDistributionFunction2D(-2D, Math.sqrt(0.5D)); org.jfree.data.xy.XYSeries xyseries3 = DatasetUtilities.sampleFunction2DToSeries( normaldistributionfunction2d3, -5.0999999999999996D, 5.0999999999999996D, 121, "N4"); xyseriescollection.addSeries(xyseries3); return xyseriescollection; }