List of usage examples for org.jfree.chart ChartFactory createXYLineChart
public static JFreeChart createXYLineChart(String title, String xAxisLabel, String yAxisLabel, XYDataset dataset, PlotOrientation orientation, boolean legend, boolean tooltips, boolean urls)
From source file:fungus.UtilizationChartFrame.java
public UtilizationChartFrame(String prefix) { simulationCycles = Configuration.getDouble(PAR_SIMULATION_CYCLES); this.setTitle("MycoNet Statistics Chart"); graph = JungGraphObserver.getGraph(); //data.add(-1,0); XYSeriesCollection dataset = new XYSeriesCollection(); dataset.setAutoWidth(false);/*from ww w. ja va 2s .co m*/ dataset.setIntervalWidth(simulationCycles); averageUtilizationData = new XYSeries("Average Utilization"); dataset.addSeries(averageUtilizationData); averageStableUtilizationData = new XYSeries("Avg Stable Util"); dataset.addSeries(averageStableUtilizationData); hyphaRatioData = new XYSeries("Hypha Ratio"); dataset.addSeries(hyphaRatioData); stableHyphaRatioData = new XYSeries("Stable Hypha Ratio"); dataset.addSeries(stableHyphaRatioData); //XYSeriesCollection dataset; JFreeChart utilizationChart = ChartFactory.createXYLineChart("Utilization Metrics", "Cycle", "Average Utilization", dataset, PlotOrientation.VERTICAL, true, false, false); ChartPanel utilizationChartPanel = new ChartPanel(utilizationChart); //chart.setBackgroundPaint(Color.white); //XYPlot plot = chart.getXYPlot(); // BufferedImage chartImage = chart.createBufferedImage(500,300); // chartLabel = new JLabel(); //chartLabel.setIcon(new ImageIcon(chartImage)); Container contentPane = getContentPane(); contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.PAGE_AXIS)); JPanel labelPane = new JPanel(); labelPane.setLayout(new GridLayout(1, 1)); //chartPane.setPreferredSize(new java.awt.Dimension(500, 300)); JPanel buttonPane = new JPanel(); buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.LINE_AXIS)); ////contentPane.add(labelPane,BorderLayout.PAGE_START); //contentPane.add(Box.createRigidArea(new Dimension(0,5))); contentPane.add(utilizationChartPanel, BorderLayout.CENTER); //contentPane.add(Box.createRigidArea(new Dimension(0,5))); ////contentPane.add(buttonPane, BorderLayout.PAGE_END); //data = node.getHyphaData(); //link = node.getHyphaLink(); //mycocast = node.getMycoCast(); setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); //chartPanel.add(chartLabel); /*JButton updateButton = new JButton("Refresh"); ActionListener updater = new ActionListener() { public void actionPerformed(ActionEvent e) { refreshData(); } }; updateButton.addActionListener(updater); JButton closeButton = new JButton("Close"); ActionListener closer = new ActionListener() { public void actionPerformed(ActionEvent e) { closeFrame(); } }; closeButton.addActionListener(closer); buttonPane.add(Box.createHorizontalGlue()); buttonPane.add(updateButton); buttonPane.add(Box.createRigidArea(new Dimension(5,0))); buttonPane.add(closeButton); refreshData(); */ //JungGraphObserver.addChangeListener(this); this.pack(); this.setVisible(true); }
From source file:ca.nengo.plot.impl.DefaultPlotter.java
/** * @see ca.nengo.plot.Plotter#doPlot(ca.nengo.util.TimeSeries, java.lang.String) *///from w w w. j av a2 s . c o m public void doPlot(TimeSeries series, String title) { XYSeriesCollection dataset = getDataset(series); JFreeChart chart = ChartFactory.createXYLineChart(title, "Time (s)", "", dataset, PlotOrientation.VERTICAL, (series.getDimension() < 10), false, false); showChart(chart, "Time Series Plot"); }
From source file:graphique.GrapheCourse.java
/** * Genere un graphe pour une course// w ww . ja v a 2 s. c o m * @param nomC String */ public void genererGraphe(String nomC) { XYSeriesCollection dataset = new XYSeriesCollection(); for (int i = 0; i < lesVoitures.length; i++) { // Create a simple XY chart XYSeries series = new XYSeries("Voiture " + lesVoitures[i]); int[] temps = this.getTempsDeCourse(lesVoitures[i]); //1er tours series.add(1, temps[0]); for (int j = 1; j < nbTours; j++) { if (temps[j] != 0) { series.add(j + 1, (temps[j] - temps[j - 1])); } else { series.add(j + 1, 0); } } // Add the series to your data set dataset.addSeries(series); } // Generate the graph chart = ChartFactory.createXYLineChart("Rsultat de la course " + nomC, // Title "tours", // x-axis Label "temps ms", // y-axis Label dataset, // Dataset PlotOrientation.VERTICAL, // Plot Orientation true, // Show Legend true, // Use tooltips false // Configure chart to generate URLs? ); }
From source file:gui.grafica.estadisticas.GUIPanelGrafica.java
public BufferedImage creaImagen() { XYSeries series = new XYSeries("Evolucion"); for (int i = 0; i < listaEjeY.size(); i++) { Date date = listaEjeX.get(i); date.getTime();//from w ww. ja v a 2 s . com series.add(date.getTime(), listaEjeY.get(i)); } // series.add(4, 23); // series.add(2, 34); // series.add(3, 51); // series.add(4, 67); // series.add(5, 89); // series.add(6, 121); // series.add(7, 137); XYDataset juegoDatos = new XYSeriesCollection(series); log.info(listaEjeX.toString()); JFreeChart chart = ChartFactory.createXYLineChart(titulo, leyendaEjeX, leyendaEjeY, juegoDatos, PlotOrientation.VERTICAL, false, false, true // Show legend ); log.info("Valor de Width:" + getWidth()); log.info("Valor de Heigth:" + getHeight()); BufferedImage image = chart.createBufferedImage(getWidth(), getHeight()); return image; }
From source file:Main.Chart.java
/** * Creates a chart.// w w w . j a va2 s .co m * * @param dataset the data for the chart. * * @return a chart. */ private JFreeChart createChart(final XYDataset dataset) { // create the chart... final JFreeChart chart = ChartFactory.createXYLineChart("Weather Forecast", // chart title "Time", // x axis label "Temperature", // y axis label dataset, // data PlotOrientation.VERTICAL, true, // include legend true, // tooltips false // urls ); // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... chart.setBackgroundPaint(Color.white); // final StandardLegend legend = (StandardLegend) chart.getLegend(); // legend.setDisplaySeriesShapes(true); // get a reference to the plot for further customisation... final XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.lightGray); // plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0)); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setSeriesLinesVisible(0, false); renderer.setSeriesShapesVisible(1, false); plot.setRenderer(renderer); // change the auto tick unit selection to integer units only... final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); // OPTIONAL CUSTOMISATION COMPLETED. return chart; }
From source file:RLCcircuit.RLCcircuitJFrame.java
public JFreeChart getResultChart() { XYSeries series1 = new XYSeries("Resistor"); XYSeries series2 = new XYSeries("Inductor"); XYSeries series3 = new XYSeries("Capacitor"); for (double i = 0 + time; i < 100 + time; i++) { ValueCaculate(i / 1000.);//from w w w. j a v a2s .co m series1.add(i, Rvoltage); } for (double i = 0 + time; i < 100 + time; i++) { ValueCaculate(i / 1000.); series2.add(i, Lvoltage); } for (double i = 0 + time; i < 100 + time; i++) { ValueCaculate(-i / 1000.); series3.add(i, Cvoltage); } XYSeriesCollection data1 = new XYSeriesCollection(series1); XYSeriesCollection data2 = new XYSeriesCollection(series2); XYSeriesCollection data3 = new XYSeriesCollection(series3); final JFreeChart chart = ChartFactory.createXYLineChart("Time-Voltage Graph", "Time", "Voltage", data1, PlotOrientation.VERTICAL, true, false, false); chart.setBackgroundPaint(null); XYPlot plot = chart.getXYPlot(); plot.setDataset(1, data2); plot.setDataset(2, data3); XYLineAndShapeRenderer Renderer1 = new XYLineAndShapeRenderer(); XYLineAndShapeRenderer Renderer2 = new XYLineAndShapeRenderer(); XYLineAndShapeRenderer Renderer3 = new XYLineAndShapeRenderer(); plot.setRenderer(0, Renderer1); plot.setRenderer(1, Renderer2); plot.setRenderer(2, Renderer3); Renderer1.setSeriesShapesVisible(0, false); Renderer2.setSeriesShapesVisible(0, false); Renderer3.setSeriesShapesVisible(0, false); plot.setBackgroundPaint(Color.black); plot.getDomainAxis().setVisible(false); plot.getRangeAxis().setVisible(false); plot.getRangeAxis().setRange(-20, 20); //chart.plotChanged(new PlotChangeEvent(plot)); return chart; }
From source file:br.ufrgs.enq.jcosmo.test.VLEdiagrams.java
@SuppressWarnings("deprecation") public JPanel calcEthTol() throws Exception { super.setTitle("P vs x1"); double T = 60; setLayout(new BorderLayout()); COSMOSACDataBase db = COSMOSACDataBase.getInstance(); COSMOSACCompound comps[] = new COSMOSACCompound[2]; comps[0] = db.getComp("ethanol"); comps[1] = db.getComp("toluene"); COSMOSAC cosmosac = new COSMOSAC(); cosmosac.setComponents(comps);/*from w ww . j a v a2 s.c om*/ cosmosac.setTemperature(T + 273.15); double[] x1 = new double[n]; double[] x2 = new double[n]; double[] gamma1 = new double[n]; double[] gamma2 = new double[n]; double[] z = new double[2]; double[] lnGamma = new double[2]; z[0] = 0.00; int j = 0; while (z[0] < 1.0001) { z[1] = 1 - z[0]; x1[j] = z[0]; x2[j] = z[1]; cosmosac.setComposition(z); cosmosac.activityCoefficient(lnGamma); gamma1[j] = Math.exp(lnGamma[0]); gamma2[j] = Math.exp(lnGamma[1]); z[0] += 0.05; j++; } double[][] parAntoine = new double[3][3]; parAntoine[0][0] = 16.8958; parAntoine[0][1] = 3795.17; parAntoine[0][2] = 230.918; parAntoine[1][0] = 13.9320; parAntoine[1][1] = 3056.96; parAntoine[1][2] = 217.625; double[] Psat = pSat(parAntoine, T); double[] P = calcPx(x1, x2, gamma1, gamma2, Psat); double[] y1 = calcY(x1, gamma1, Psat, P); XYPlot plot1; XYSeriesCollection dataset = new XYSeriesCollection(); XYSeries liq = new XYSeries("liquid"); XYSeries vap = new XYSeries("vapor"); XYSeries raoult = new XYSeries("Raoult's Law"); for (int i = 0; i < n; i++) { liq.add(x1[i], P[i]); vap.add(y1[i], P[i]); } raoult.add(0, Psat[1]); raoult.add(1, Psat[0]); dataset.addSeries(liq); dataset.addSeries(vap); dataset.addSeries(raoult); JFreeChart chart = ChartFactory.createXYLineChart(null, "Mole Fraction: x1, y1", "P/KPa", null, PlotOrientation.VERTICAL, true, true, false); plot1 = (XYPlot) chart.getPlot(); plot1.getDomainAxis().setRange(new Range(0.0, 1.0)); plot1.getRangeAxis().setRange(new Range(15.0, 50.0)); plot1.setDataset(dataset); XYSplineRenderer r = new XYSplineRenderer(); BasicStroke stroke = new BasicStroke(2f); r.setStroke(stroke); plot1.setRenderer(r); r.setBaseShapesVisible(false); ChartPanel chartPanel = new ChartPanel(chart); JPanel jp = new JPanel(new BorderLayout()); jp.add(chartPanel); add(jp, BorderLayout.CENTER); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setSize(400, 500); return jp; }
From source file:adapters.HistogramChartAdapter.java
/** * Modified method (close legend: set it to false) * @param title/* w w w.j av a 2 s. c om*/ * @param XLabel * @param YLabel */ protected void init(String title, String XLabel, String YLabel) { // create the chart... chart = ChartFactory.createXYLineChart(title, // chart title XLabel, // x axis label YLabel, // y axis label dataset.getSeriesCollection(), // data PlotOrientation.VERTICAL, false, // include legend true, // tooltips false // urls ); ((XYPlot) chart.getPlot()).setRenderer(dataset.getRenderer()); //Initialize axis variables XAxis = new AxisAdapter((NumberAxis) ((XYPlot) chart.getPlot()).getDomainAxis(), Axis.ORIENTATION_HORIZONTAL); YAxis = new AxisAdapter((NumberAxis) ((XYPlot) chart.getPlot()).getRangeAxis(), Axis.ORIENTATION_VERTICAL); setAutoRange(false, true, true, true); }
From source file:wm.edu.cs420.Data.ChartBuilder.java
/** * Creates a chart.// ww w . j a v a 2 s.com * * @param dataset the data for the chart. * * @return a chart. */ private JFreeChart generateChart(final XYDataset dataset) { // create the chart... final JFreeChart chart = ChartFactory.createXYLineChart(null, // chart title null, // x axis label null, // y axis label dataset, // data PlotOrientation.VERTICAL, false, // include legend false, // tooltips false // urls ); // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... chart.setBackgroundPaint(Color.white); // final StandardLegend legend = (StandardLegend) chart.getLegend(); // legend.setDisplaySeriesShapes(true); // get a reference to the plot for further customisation... 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); Shape shape = new Ellipse2D.Double(0, 0, 3, 3); renderer.setSeriesShape(0, shape); plot.setRenderer(renderer); // change the auto tick unit selection to integer units only... final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); // OPTIONAL CUSTOMISATION COMPLETED. return chart; }
From source file:org.jfree.chart.demo.LineChartDemo3.java
/** * Creates a chart./*from ww w . j a v a 2 s. c o m*/ * * @param dataset a dataset. * * @return A chart based on the supplied dataset. */ private JFreeChart createChart(final XYDataset dataset) { final JFreeChart chart = ChartFactory.createXYLineChart("Line Chart Demo 3", // chart title "X", // x axis label "Y", // y axis label dataset, // data PlotOrientation.VERTICAL, true, // include legend true, // tooltips false // urls ); // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... // get a reference to the plot for further customisation... final XYPlot plot = chart.getXYPlot(); final StandardXYItemRenderer renderer = (StandardXYItemRenderer) plot.getRenderer(); renderer.setPlotShapes(true); // change the auto tick unit selection to integer units only... final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); return chart; }