List of usage examples for org.jfree.data.xy XYSeriesCollection addSeries
public void addSeries(XYSeries series)
From source file:tp2.FCFS.java
@Override public void printGraph(String filename) { int i;/*from w w w . j a va 2s .c o m*/ int y_axis = requestString.length * 10; XYSeries series = new XYSeries("FCFS"); /* Adiciona o pontos XY do grfico de linhas. */ series.add(y_axis, initCilindro); for (i = 0; i < requestString.length; i++) { series.add(y_axis - ((i + 1) * 10), requestString[i]); } /* Adiciona a serie criada a um SeriesCollection. */ XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(series); /* Gera o grfico de linhas */ JFreeChart chart = ChartFactory.createXYLineChart( /* Title */ "FCFS Scheduler Algorithm", /* Title x*/ "", /* Title y */ "Cilindro", dataset, /* Plot Orientation */ PlotOrientation.HORIZONTAL, /* Show Legend */ false, /* Use tooltips */ false, /* Configure chart to generate URLs? */ false); /* Configura a espessura da linha do grfico */ XYPlot plot = chart.getXYPlot(); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setSeriesStroke(0, new BasicStroke(4.0f)); plot.setRenderer(renderer); /* Escreve o grfico para um arquivo indicado. */ try { ChartUtilities.saveChartAsJPEG(new File(filename), chart, 500, 300); } catch (IOException ex) { Logger.getLogger(FCFS.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:org.jfree.data.xy.IntervalXYDelegateTest.java
/** * Confirm that the equals method can distinguish all the required fields. *//*w w w .ja va 2 s . co m*/ @Test public void testEquals() { XYSeries s1 = new XYSeries("Series"); s1.add(1.2, 3.4); XYSeriesCollection c1 = new XYSeriesCollection(); c1.addSeries(s1); IntervalXYDelegate d1 = new IntervalXYDelegate(c1); XYSeries s2 = new XYSeries("Series"); XYSeriesCollection c2 = new XYSeriesCollection(); s2.add(1.2, 3.4); c2.addSeries(s2); IntervalXYDelegate d2 = new IntervalXYDelegate(c2); assertTrue(d1.equals(d2)); assertTrue(d2.equals(d1)); d1.setAutoWidth(false); assertFalse(d1.equals(d2)); d2.setAutoWidth(false); assertTrue(d1.equals(d2)); d1.setIntervalPositionFactor(0.123); assertFalse(d1.equals(d2)); d2.setIntervalPositionFactor(0.123); assertTrue(d1.equals(d2)); d1.setFixedIntervalWidth(1.23); assertFalse(d1.equals(d2)); d2.setFixedIntervalWidth(1.23); assertTrue(d1.equals(d2)); }
From source file:SystemAnomalies.bouncedLogInRate.java
public ChartPanel getChartPanel() { XYSeries series = new XYSeries("Annual Composite Production Vs Farmers Experience"); series.add(0, 0);/*from www .j a v a 2 s . c o m*/ series.add(1, 100); series.add(2, 100); series.add(3, 100); series.add(4, 120); series.add(5, 120); series.add(6, 1040); series.add(7, 1040); series.add(8, 1040); series.add(9, 2000); series.add(10, 2000); series.add(11, 100); series.add(12, 100); series.add(13, 100); series.add(14, 120); series.add(15, 120); series.add(16, 1040); series.add(17, 1040); series.add(18, 1040); series.add(19, 2000); series.add(20, 2000); series.add(21, 1845); series.add(22, 1040); series.add(23, 2000); // Add the series to your data set XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(series); // Generate the graph JFreeChart chart = ChartFactory.createXYLineChart("Sign-in Bounce off Rate", // Title "Time of Day", // x-axis Label "Number of Attempts", // y-axis Label dataset, // Dataset PlotOrientation.VERTICAL, // Plot Orientation true, // Show Legend true, // Use tooltips false // Configure chart to generate URLs? ); ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setBackground(Color.WHITE); chartPanel.setBounds(2, 5, 750, 500); chartPanel.setBorder(new LineBorder(Color.decode("#f5f5f5"), 2)); return chartPanel; }
From source file:IHM.NewClass.java
private XYDataset createDataset() { XYSeries s1 = new XYSeries("Temperature"); XYSeries s2 = new XYSeries("Humidit"); XYSeries s3 = new XYSeries("Nebulosit"); Controller c = new Controller(); // c.AfficherStationMoyenneTousLesJours(); for (ReleveMeteo i : c.getStationRecherchee()) { System.out.println(i.getTemperature()); if (i.getJour().getJour() == 0) { s1.add(Double.parseDouble("" + i.getMois().getMois()), Double.parseDouble(i.getTemperature())); s2.add(Double.parseDouble("" + i.getMois().getMois()), Double.parseDouble(i.getHumidite())); s3.add(Double.parseDouble("" + i.getMois().getMois()), Double.parseDouble(i.getNebulosite())); } else {/*ww w . j a v a 2s . c om*/ s1.add(Double.parseDouble("" + i.getJour().getJour()), Double.parseDouble(i.getTemperature())); s2.add(Double.parseDouble("" + i.getJour().getJour()), Double.parseDouble(i.getHumidite())); s3.add(Double.parseDouble("" + i.getJour().getJour()), Double.parseDouble(i.getNebulosite())); } } XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(s1); dataset.addSeries(s2); dataset.addSeries(s3); return dataset; }
From source file:cachedataanalysis.FlowCacheGroup.java
public XYSeries exportReportChart() throws IOException { ArrayList<XYSeries> series = new ArrayList<XYSeries>(); for (FlowCache cache : caches) { series.add(cache.exportReportChart()); }/* ww w . j a va 2 s . c o m*/ XYSeriesCollection data = new XYSeriesCollection(); for (XYSeries s : series) { data.addSeries(s); } JFreeChart chart = ChartFactory.createXYLineChart("Performance by Size", "Second", "Hit Rate", data); ChartUtilities.saveChartAsJPEG(new File("report/" + name + "_hitRateComp" + size + ".jpg"), chart, 1500, 900); return series.get(series.size() / 2 + 1); }
From source file:etssi.Graphique.java
/** * Creates a sample dataset.// w w w . ja va 2 s . com * * @return a sample dataset. */ private XYDataset createDataset(Dataset courbe1, Dataset courbe2, Dataset courbe3) { final XYSeries series1 = new XYSeries("JOB"); for (Data data : courbe1.getArray()) { series1.add(data.getTranche_horaire(), data.getMontant()); } final XYSeries series2 = new XYSeries("Samedi"); for (Data data : courbe2.getArray()) { series2.add(data.getTranche_horaire(), data.getMontant()); } final XYSeries series3 = new XYSeries("Dimanche"); for (Data data : courbe3.getArray()) { series3.add(data.getTranche_horaire(), data.getMontant()); } final XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(series1); dataset.addSeries(series2); dataset.addSeries(series3); return dataset; }
From source file:techtonic.PlotLogGraphListener.java
@Override public void actionPerformed(ActionEvent e) { List<WitsmlLogCurve> curves = log.getCurves(); Vector<String> curveDescription = new Vector<>(); for (WitsmlLogCurve c : curves) { // System.out.println(c.getDescription()); curveDescription.add(c.getDescription()); }// www . ja v a 2 s. co m Techtonic.setjcbX_Axis(curveDescription); Techtonic.setEnablejcbX_Axis(true); Techtonic.setEnablejcbY_Axis(false); Techtonic.setEnableRenderBtn(true); Techtonic.setPropertyBtn(true); //Techtonic.setjcbX_Axis(); Vector<String> v = new Vector<String>(Arrays.asList(new String[] { "Depth" })); Techtonic.setjcbY_Axis(v); //plot the graph using values of the second entry WitsmlLogCurve ydata = curves.get(0); WitsmlLogCurve xdata = curves.get(1); List<Object> yvalues = ydata.getValues(); List<Object> xvalues = xdata.getValues(); String title = "Depth against " + xdata.getDescription(); XYSeries series = new XYSeries(title); for (int i = 0; i < yvalues.size(); i++) { Object vx = xvalues.get(i); Object vy = yvalues.get(i); double dx = Double.parseDouble(vx.toString()); double dy = Double.parseDouble(vy.toString()); series.add(dx, dy); } XYSeriesCollection data = new XYSeriesCollection(); data.addSeries(series); // create a chart using the createYLineChart method... JFreeChart chart = ChartFactory.createXYLineChart(title, // chart title xdata.getDescription(), "Depth", // x and y axis labels data); // data ChartPanel cp = new ChartPanel(chart); // JFrame fr = new JFrame(); // fr.add(cp); // fr.pack(); // fr.setVisible(true); //cp.setMouseZoomable(true, true); Techtonic.setFreeChart(chart); Techtonic.setCurrentCurves(curves); Techtonic.setDisplayArea(cp); // chartPanel.setLayout(new java.awt.BorderLayout()); // chartPanel.add(cp,BorderLayout.CENTER); // chartPanel.validate(); // chartPanel.repaint(); }
From source file:aka.pirana.jdoc.JChart.java
private XYDataset SampleGenerator() { manager.getTransaction().begin();// w ww .j av a 2s .c o m CriteriaBuilder cb = manager.getCriteriaBuilder(); CriteriaQuery<Consultation> query = cb.createQuery(Consultation.class); Root<Consultation> sm = query.from(Consultation.class); query.where(cb.equal(sm.get("patient.id"), id.toString())); TypedQuery<Consultation> q = manager.createQuery(query); List<Consultation> results = q.getResultList(); XYSeries xyWeightSeries = new XYSeries("Weight"); XYSeries xyFatSeries = new XYSeries("Fat"); XYSeries xyMuscleSeries = new XYSeries("Muscle"); XYSeries xyWaterSeries = new XYSeries("Water"); int i = 2; results.stream().map((result) -> { xyWeightSeries.add(i, result.getC_weight()); return result; }).map((result) -> { xyFatSeries.add(i, result.getC_gm()); return result; }).map((result) -> { xyMuscleSeries.add(i, result.getC_mm()); return result; }).forEach((result) -> { xyWaterSeries.add(i, result.getC_hm()); }); XYSeriesCollection xyseriescollection = new XYSeriesCollection(xyWeightSeries); xyseriescollection.addSeries(xyFatSeries); xyseriescollection.addSeries(xyMuscleSeries); xyseriescollection.addSeries(xyWaterSeries); return xyseriescollection; }
From source file:com.cs572.assignments.Project2.view.LineChartPanel.java
private XYDataset createDataset(float actualOutput[], float expectedOutput[]) { XYSeries series1 = new XYSeries("Actual Output"); for (int x = 0; x < actualOutput.length; x++) { series1.add(x + 1, actualOutput[x]); }//w w w. j a v a 2 s . com XYSeries series2 = new XYSeries("Expected Output"); for (int x = 0; x < actualOutput.length; x++) { series2.add(x + 1, expectedOutput[x]); } final XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(series1); dataset.addSeries(series2); return dataset; }
From source file:physical_network.OscilloscopePanel.java
public OscilloscopePanel() { super("Oscilloscope"); // Set initial (time, voltage) datapoint of (0.0, 0.0). voltages.add(0.0, 0.0);//from w w w . j a va2 s .co m XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(voltages); JFreeChart chart = ChartFactory.createXYLineChart("Oscilloscope", "Time (seconds)", "Voltage", dataset, PlotOrientation.VERTICAL, true, false, false); XYPlot plot = (XYPlot) chart.getPlot(); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setSeriesLinesVisible(0, true); NumberAxis domain = (NumberAxis) plot.getDomainAxis(); domain.setRange(0.0, 10.0); domain.setTickUnit(new NumberTickUnit(1.0)); domain.setVerticalTickLabels(true); NumberAxis range = (NumberAxis) plot.getRangeAxis(); range.setRange(-5.0, 5.0); range.setTickUnit(new NumberTickUnit(1.0)); plot.setRenderer(renderer); ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(500, 300)); setContentPane(chartPanel); }