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:statistics.distribution.ExponentialDistribution.java
@Override public JFreeChart getChart() { JFreeChart chart = ChartFactory.createXYLineChart("Exponential Cumulative Distribution", "", "", getDataset(), PlotOrientation.VERTICAL, true, true, false); return chart; }
From source file:org.dkpro.lab.reporting.ChartUtilTest.java
@Test public void testSvg() throws Exception { double[][] data = new double[2][10]; for (int n = 1; n < 10; n++) { data[0][n] = 1.0 / n;//from ww w. ja va 2 s . co m data[1][n] = 1.0 - (1.0 / n); } DefaultXYDataset dataset = new DefaultXYDataset(); dataset.addSeries("data", data); JFreeChart chart = ChartFactory.createXYLineChart(null, "Recall", "Precision", dataset, PlotOrientation.VERTICAL, false, false, false); chart.getXYPlot().setRenderer(new XYSplineRenderer()); chart.getXYPlot().getRangeAxis().setRange(0.0, 1.0); chart.getXYPlot().getDomainAxis().setRange(0.0, 1.0); File tmp = File.createTempFile("testfile", ".svg"); try (OutputStream os = new FileOutputStream(tmp)) { ChartUtil.writeChartAsSVG(os, chart, 400, 400); } // String ref = FileUtils.readFileToString(new File("src/test/resources/chart/test.svg"), // "UTF-8"); // String actual = FileUtils.readFileToString(tmp, "UTF-8"); // assertEquals(ref, actual); }
From source file:de.fub.maps.gpx.analysis.ui.charts.LineChart.java
/** * Creates new form LineChart/*from ww w .j av a2 s . co m*/ */ public LineChart() { initComponents(); chart = ChartFactory.createXYLineChart(null, NbBundle.getMessage(LineChart.class, "LineChart.Domain.Name"), NbBundle.getMessage(LineChart.class, "LineCHart.Value.Name"), dataset, PlotOrientation.VERTICAL, false, true, true); plot = chart.getXYPlot(); plot.setRangeAxisLocation(0, AxisLocation.BOTTOM_OR_LEFT); plot.setBackgroundPaint(Color.white); plot.getRenderer(0).setSeriesPaint(0, Color.BLUE); plot.getRenderer(0).setSeriesShape(0, new Ellipse2D.Double(0, 0, 2, 2)); plot.getRenderer(0).setBaseShape(new Ellipse2D.Double(0, 0, 2, 2)); chartPanel = new ChartPanel(chart, false); add(chartPanel, BorderLayout.CENTER); }
From source file:simphy.XYChart.java
public XYChart(Pendulum p) { this.p = p;//from w ww . j a v a2 s . c o m type = "pendulum"; // Create a simple XY chart series = new XYSeries("Omega-Time Plot"); series1 = new XYSeries("Theta-Time Plot"); dataset = new XYSeriesCollection(); dataset.addSeries(series); dataset.addSeries(series1); // Generate the graph chart = ChartFactory.createXYLineChart("Velocity/Angle Graph", // Title "time", // x-axis Label "Angular Velocity(rad/s)/Angle(rad)", // y-axis Label dataset, // Dataset PlotOrientation.VERTICAL, // Plot Orientation true, // Show Legend true, // Use tooltips false // Configure chart to generate URLs? ); this.setTitle(p.toString()); this.setBounds(950, 0, 400, 700); panel = new ChartPanel(chart, false); this.add(panel, BorderLayout.CENTER); this.setAlwaysOnTop(true); this.addWindowListener(this); this.pack(); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { XYChart.this.setVisible(true); } }); }
From source file:com.hello2morrow.sonargraph.jenkinsplugin.model.XYLineAndShapePlot.java
@Override protected JFreeChart createChartInternal(String chartTitle, String categoryName, String yAxisName, XYDataset dataset) {// w w w. j av a 2 s. c o m return ChartFactory.createXYLineChart(chartTitle, categoryName, yAxisName, dataset, PlotOrientation.VERTICAL, false, true, false); }
From source file:netplot.XYPlotPanel.java
private JFreeChart createChart(XYDataset dataset) { JFreeChart chart = ChartFactory.createXYLineChart(plotTitle, xAxisName, yAxisName, dataset, PlotOrientation.VERTICAL, enableLegend, true, true); XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.WHITE); plot.setDomainGridlinePaint(Color.DARK_GRAY); plot.setRangeGridlinePaint(Color.DARK_GRAY); return chart; }
From source file:statistics.distribution.UniformDistribution.java
@Override public JFreeChart getChart() { JFreeChart chart = ChartFactory.createXYLineChart("Uniform Cumulative Distribution", "", "", getDataset(), PlotOrientation.VERTICAL, true, true, false); return chart; }
From source file:com.kurvlrgui.gui.ChartPanel.java
/** * Creates new form ChartPanel//from w w w . j a v a2 s .c o m */ public ChartPanel(String title, NumericData s1, NumericData s2) { initComponents(); calculated = new XYSeries("Calculated"); for (NumericPair np : s1.values) { calculated.add(np.x, np.y); } observed = null; if (s2 != null) { observed = new XYSeries("Observed"); for (NumericPair np : s2.values) { observed.add(np.x, np.y); } } XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(calculated); if (s2 != null) dataset.addSeries(observed); JFreeChart chart = ChartFactory.createXYLineChart(title, "X", "Y", dataset, PlotOrientation.VERTICAL, true, true, false); chart.setBackgroundPaint(Color.white); XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setSeriesLinesVisible(0, false); renderer.setSeriesLinesVisible(1, false); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); panel = new org.jfree.chart.ChartPanel(chart); panel.setHorizontalAxisTrace(true); panel.setVerticalAxisTrace(true); this.add(panel); }
From source file:graph_line.java
public void showGraph() { dataset = new XYSeriesCollection(); dataset.addSeries(fftseries);//ww w. j a v a 2s . co m // dataset.addSeries(series1); //dataset.addSeries(series2); chart = ChartFactory.createXYLineChart("XY Chart", // Title "x-axis", // x-axis Label "y-axis", // y-axis Label dataset, // Dataset PlotOrientation.VERTICAL, // Plot Orientation true, // Show Legend true, // Use tooltips false); chartPanel = new ChartPanel(chart); // default size chartPanel.setPreferredSize(new java.awt.Dimension(500, 270)); // add it to our application setContentPane(chartPanel); plot = chart.getXYPlot(); this.pack(); this.setVisible(true); _active = 1; }
From source file:statistic.graph.JChartPanel.java
protected static JFreeChart createChart() { stepDataset = new XYSeriesCollection(); linearDataset = new XYSeriesCollection(); chart = ChartFactory.createXYLineChart("Fluss", "Zeiteinheiten", "Flusseinheiten", stepDataset, PlotOrientation.VERTICAL, true, true, false); chart.setBackgroundPaint(Color.WHITE); plot = (XYPlot) chart.getPlot();//from w ww . j a v a2 s . c o m plot.setBackgroundPaint(Color.LIGHT_GRAY); plot.setDomainGridlinePaint(Color.WHITE); plot.setRangeGridlinePaint(Color.WHITE); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); plot.setDataset(0, stepDataset); plot.setDataset(1, linearDataset); XYItemRenderer r = plot.getRenderer(); //r.setBaseOutlinePaint(Color.BLACK); //r.setBasePaint(); //r.setItemLabelPaint(); //r.setOutlinePaint(Color.BLACK); //r.setSeriesItemLabelPaint(); //r.setSeriesOutlinePaint(); r.setSeriesPaint(0, Color.GREEN.darker()); r.setSeriesPaint(1, Color.MAGENTA.darker()); if (r instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r; renderer.setBaseShapesVisible(true); renderer.setBaseShapesFilled(true); } //XYStepRenderer r3 = new XYStepRenderer(); //r.setBaseOutlinePaint(Color.BLACK); //r.setBasePaint(); //r.setItemLabelPaint(); //r.setOutlinePaint(Color.BLACK); //r.setSeriesItemLabelPaint(); //r.setSeriesOutlinePaint(); //r3.setSeriesPaint(0, Color.BLACK); //r3.setShapesVisible(true); //r3.setShapesFilled(true); //r3.setSeriesShapesFilled(0,true); //r3.set //r3.setSeriesStroke(0, new BasicStroke(2.0f)); XYItemRenderer r2 = new XYStepRenderer(); r2.setSeriesPaint(2, Color.BLACK); plot.setRenderer(r2); plot.setRenderer(1, r); //plot.setRenderer(2, r3); plot.getDomainAxis().setStandardTickUnits(NumberAxis.createIntegerTickUnits()); plot.getDomainAxis().setRange(-0.5, 10); plot.getRangeAxis().setStandardTickUnits(NumberAxis.createIntegerTickUnits()); plot.getRangeAxis().setRange(-0.5, 8.5); return chart; }