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:no.ntnu.mmfplanner.ui.graph.NpvChart.java
/** * Creates the main chart, but does not fill inn any data *///from w w w . ja va2s . c o m private void createChart() { JFreeChart chart = ChartFactory.createXYLineChart(null, // chart title "Period", // x axis label "Discounted Cash", // y axis label null, // data PlotOrientation.VERTICAL, true, // include legend true, // tooltips false // urls ); XYPlot plot = (XYPlot) chart.getPlot(); plot.getDomainAxis().setLowerMargin(0.0); plot.getDomainAxis().setUpperMargin(0.0); plot.setRangeAxisLocation(1, AxisLocation.BOTTOM_OR_LEFT); // change the auto tick unit selection to integer units only... NumberAxis rangeAxis = (NumberAxis) plot.getDomainAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); plot.getDomainAxis().setTickMarksVisible(false); setChart(chart); setMouseZoomable(false); }
From source file:br.com.ant.system.util.ChartUtil.java
public void createTempoTotalExecucao(Set<EstatisticaColetor> estatisticas) { // Create a simple XY chart XYSeries series = new XYSeries("Formiga"); JFrame frame = new JFrame(); for (EstatisticaColetor e : estatisticas) { series.add(e.getId(), e.getTempoExecucao()); }// w w w .j a v a 2 s . co m // Add the series to your data set XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(series); // Generate the graph JFreeChart chart = ChartFactory.createXYLineChart("Tempo total de Execuo", "Execuo", "Tempo (ms)", dataset, PlotOrientation.VERTICAL, true, true, false); frame.getContentPane().add(new ChartPanel(chart)); frame.setPreferredSize(new Dimension(600, 600)); frame.setMinimumSize(new Dimension(600, 600)); frame.setMaximumSize(new Dimension(600, 600)); frame.setVisible(true); try { ChartUtilities.saveChartAsJPEG(new File("chart.jpg"), chart, 500, 300); } catch (IOException e) { System.err.println("Problem occurred creating chart."); } }
From source file:phat.audio.listeners.XYRMSAudioChart.java
/** * Creates a new demo./*ww w . j a va 2 s. co m*/ * * @param title the frame title. */ public XYRMSAudioChart(final String title) { super(title); //Object[][][] data = new Object[3][50][2]; values = new XYSeries("data"); dataset = new XYSeriesCollection(); dataset.addSeries(values); chart = ChartFactory.createXYLineChart(title, // chart title "Time (m)", // domain axis label "RMS (dB)", // range axis label dataset, // data PlotOrientation.VERTICAL, true, // include legend true, false); plot = chart.getXYPlot(); /*final NumberAxis domainAxis = new NumberAxis("x"); final NumberAxis rangeAxis = new LogarithmicAxis("Log(y)"); plot.setDomainAxis(domainAxis); plot.setRangeAxis(rangeAxis);*/ chart.setBackgroundPaint(Color.white); plot.setOutlinePaint(Color.black); chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(500, 270)); setContentPane(chartPanel); }
From source file:endrov.typeTimeRemap.TimeRemapWindow.java
/** * Make a new window//w ww. ja va2 s . c om */ public TimeRemapWindow() { bAdd.addActionListener(this); bRefresh.addActionListener(this); objectCombo.addActionListener(this); XYDataset xyDataset = new XYSeriesCollection(frametimeSeries); JFreeChart chart = ChartFactory.createXYLineChart("", "New time", "Original time", xyDataset, PlotOrientation.HORIZONTAL, false/*legend*/, false/*tooltips*/, false/*urls*/); ChartPanel graphpanel = new ChartPanel(chart); //Put GUI together JPanel datapanel = new JPanel(new BorderLayout()); JPanel dataparto = new JPanel(new BorderLayout()); dataparto.add(datapart, BorderLayout.NORTH); JScrollPane datapartscroll = new JScrollPane(dataparto, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); JPanel buttonpanel = new JPanel(new GridLayout(1, 2)); buttonpanel.add(bAdd); buttonpanel.add(bRefresh); datapanel.add(buttonpanel, BorderLayout.SOUTH); datapanel.add(datapartscroll, BorderLayout.CENTER); setLayout(new BorderLayout()); add(datapanel, BorderLayout.EAST); JPanel leftPanel = new JPanel(new BorderLayout()); leftPanel.add(graphpanel, BorderLayout.CENTER); leftPanel.add(objectCombo, BorderLayout.SOUTH); add(leftPanel, BorderLayout.CENTER); loadData(); //Window overall things setTitleEvWindow("Time remapper"); packEvWindow(); setBoundsEvWindow(new Rectangle(100, 100, 1000, 600)); setVisibleEvWindow(true); }
From source file:org.marekasf.troughput.XYHistogramChart.java
public XYHistogramChart(final AdaptiveHistogram h, final String title) { super(title); final XYSeries series = new XYSeries(title); IntStream.rangeClosed(0, 100).forEach(i -> series.add(i, h.getValueForPercentile(i))); final XYSeriesCollection data = new XYSeriesCollection(series); final JFreeChart chart = ChartFactory.createXYLineChart("XY Histogram Chart " + title, "X", "Y", data, PlotOrientation.VERTICAL, true, true, false); final ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(500, 270)); setContentPane(chartPanel);/* w w w .j a va2s . c o m*/ }
From source file:org.portico.pgauge.gui.ThroughputChart.java
public ThroughputChart(ThroughputDataset rawdata, PGConfiguration configuration) { this.rawdata = rawdata; this.series = new XYSeries("Iterations"); this.dataset = new XYSeriesCollection(series); backfill();//from w ww . ja v a 2 s.c o m // create the chart String title = "Attribute Updates for " + configuration.getFederateName() + " (" + configuration.getPayloadSizeAsString() + " packets)"; this.chart = ChartFactory.createXYLineChart(title, "Iterations", "Time to Complete (ms)", dataset, PlotOrientation.VERTICAL, false, // legend true, // tooltips false); // urls this.panel = new ChartPanel(this.chart); getContentPane().add(this.panel); this.pack(); this.setVisible(true); }
From source file:edu.msu.cme.rdp.rarefaction.RarefactionPlotter.java
private static void plotToFile(List<RarefactionResult> resultsToPlot, int numSeqs, String title, File outputFile) throws IOException { XYSeriesCollection dataset = new XYSeriesCollection(); for (RarefactionResult result : resultsToPlot) { XYSeries series = new XYSeries(RarefactionWriter.dformat.format(result.distance) + " distance"); for (int plotIndex : RarefactionWriter.getIndiciesToPlot(numSeqs)) { series.add(result.geteArray()[plotIndex], plotIndex); }//w w w. j a v a2s . co m dataset.addSeries(series); } JFreeChart chart = ChartFactory.createXYLineChart(title, "", "", dataset, PlotOrientation.HORIZONTAL, true, false, false); ChartUtilities.saveChartAsPNG(outputFile, chart, 1280, 1024); }
From source file:umontreal.iro.lecuyer.charts.EmpiricalChart.java
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, true, // include legend true, // tool tips false // urls );// w ww . j av a 2 s . c om ((XYPlot) chart.getPlot()).setRenderer(dataset.getRenderer()); // Initialize axis variables XAxis = new Axis((NumberAxis) ((XYPlot) chart.getPlot()).getDomainAxis(), Axis.ORIENTATION_HORIZONTAL); YAxis = new Axis((NumberAxis) ((XYPlot) chart.getPlot()).getRangeAxis(), Axis.ORIENTATION_VERTICAL); fixZeroPoint(); }
From source file:br.usp.icmc.gazetteer.SemanticSearchTest.Grafico.java
public ChartPanel criaGrafico() { // create the chart... JFreeChart graf = ChartFactory.createXYLineChart("MAP ENTRE AS QUERYS", // chart title "QUERY", // x axis label "MAP", // y axis label createDataset1(), // data PlotOrientation.VERTICAL, true, // include legend true, // tooltips false // urls );/*from w ww.ja va2s .co m*/ // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... graf.setBackgroundPaint(Color.white); // get a reference to the plot for further customisation... XYPlot plot = (XYPlot) graf.getPlot(); plot.setDataset(1, createDataset2()); plot.setBackgroundPaint(Color.lightGray); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer(); renderer.setShapesVisible(false); XYLineAndShapeRenderer renderer2 = new XYLineAndShapeRenderer(true, false); plot.setRenderer(1, renderer2); // change the auto tick unit selection to integer units only... NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); // OPTIONAL CUSTOMISATION COMPLETED. ChartPanel myChartPanel = new ChartPanel(graf, true); return myChartPanel; }