Example usage for org.jfree.chart ChartFactory createXYLineChart

List of usage examples for org.jfree.chart ChartFactory createXYLineChart

Introduction

In this page you can find the example usage for org.jfree.chart ChartFactory createXYLineChart.

Prototype

public static JFreeChart createXYLineChart(String title, String xAxisLabel, String yAxisLabel,
        XYDataset dataset, PlotOrientation orientation, boolean legend, boolean tooltips, boolean urls) 

Source Link

Document

Creates a line chart (based on an XYDataset ) with default settings.

Usage

From source file:GUI.Data.java

/**
 * Creates new form Data//from  w ww.  ja  va2  s. co m
 */
public Data() {

    XYSeries Goals = new XYSeries("Goals Scored");
    Goals.add(1, 1.0);
    Goals.add(2, 3.0);
    Goals.add(3, 2.0);
    Goals.add(4, 0.0);
    Goals.add(5, 3.0);
    XYDataset xyDataset = new XYSeriesCollection(Goals);
    JFreeChart chart = ChartFactory.createXYLineChart("Goals Scored Over Time", "Fixture Number", "Goals",
            xyDataset, PlotOrientation.VERTICAL, true, true, false);
    ChartPanel cp = new ChartPanel(chart) {

        @Override
        public Dimension getPreferredSize() {
            return new Dimension(320, 240);
        }
    };
    cp.setMouseWheelEnabled(true);
    add(cp);
    setDefaultCloseOperation(EXIT_ON_CLOSE);
    pack();
    initComponents();
}

From source file:Graphic.Poids.java

public Poids(List<Float> valeurs, List<String> date) {
    dataset = new XYSeriesCollection();
    XYSeries serie = new XYSeries("Courbe");
    for (int i = 0; i < valeurs.size(); i++) {
        serie.add(i, valeurs.get(i));/*w  w  w.ja  va  2 s.c  o  m*/
    }
    dataset.addSeries(serie);
    diagramme = ChartFactory.createXYLineChart("Graphe de Poids", "Date", "Poids", dataset,
            PlotOrientation.VERTICAL, true, true, false);

    ChartPanel chartPanel = new ChartPanel(diagramme);
    chartPanel.setFillZoomRectangle(true);
    chartPanel.setMouseWheelEnabled(true);
    chartPanel.setPreferredSize(new Dimension(1200, 600));
    add(chartPanel);
}

From source file:cv.mikusher.freechart.XYLineChart.java

public XYLineChart(String applicationTitle, String chartTitle) {
    super(applicationTitle);
    setDefaultCloseOperation(ApplicationFrame.EXIT_ON_CLOSE);
    JFreeChart xylineChart = ChartFactory.createXYLineChart(chartTitle, "Category", "Score", createDataset(),
            PlotOrientation.VERTICAL, true, true, false);

    ChartPanel chartPanel = new ChartPanel(xylineChart);
    chartPanel.setPreferredSize(new java.awt.Dimension(560, 367));
    final XYPlot plot = xylineChart.getXYPlot();
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer.setSeriesPaint(0, Color.RED);
    renderer.setSeriesPaint(1, Color.GREEN);
    renderer.setSeriesPaint(2, Color.YELLOW);
    renderer.setSeriesStroke(0, new BasicStroke(4.0f));
    renderer.setSeriesStroke(1, new BasicStroke(3.0f));
    renderer.setSeriesStroke(2, new BasicStroke(2.0f));
    plot.setRenderer(renderer);/*  w  ww.  ja v a 2  s  . c om*/
    setContentPane(chartPanel);
}

From source file:cs.register.geraGrafico.java

public geraGrafico(String title, int type, List<partida> L) {
    super(title);
    JFreeChart chart = null;/*  w w w. j  av  a  2  s  . c  o m*/
    switch (type) {
    case 0:
        chart = ChartFactory.createXYLineChart(title, "X", "y", datakill(L), PlotOrientation.VERTICAL, true,
                true, false);
    case 1:
        chart = ChartFactory.createXYLineChart(title, "X", "y", datakda(L), PlotOrientation.VERTICAL, true,
                true, false);
    case 2:
        chart = ChartFactory.createXYLineChart(title, "X", "y", datawld(L), PlotOrientation.VERTICAL, true,
                true, false);
    case 3:
        chart = ChartFactory.createXYLineChart(title, "X", "y", datasocore(L), PlotOrientation.VERTICAL, true,
                true, false);
    case 4:
        chart = ChartFactory.createXYLineChart(title, "X", "y", datarank(L), PlotOrientation.VERTICAL, true,
                true, false);

    }
    graf = new ChartPanel(chart);
    graf.setPreferredSize(new java.awt.Dimension(560, 367));
    XYPlot plot = chart.getXYPlot();
    XYLineAndShapeRenderer rendrer = new XYLineAndShapeRenderer();
    rendrer.setSeriesPaint(0, Color.GREEN);
    rendrer.setSeriesStroke(0, new BasicStroke(4.0f));
    plot.setRenderer(rendrer);
    setContentPane(graf);

}

From source file:com.oracle.cch.swingtest.ChartJFrame.java

/**
 * Creates new form ChartJFrame/*  ww w.ja  v a 2  s .c  o  m*/
 */
public ChartJFrame() {
    initComponents();
    XYSeries Goals = new XYSeries("Goals Scored");
    Goals.add(1, 1.0);
    Goals.add(2, 3.0);
    Goals.add(3, 2.0);
    Goals.add(4, 0.0);
    Goals.add(5, 3.0);
    XYDataset xyDataset = new XYSeriesCollection(Goals);
    chart = ChartFactory.createXYLineChart("Goals Scored Over Time", "Fixture Number", "Goals", xyDataset,
            PlotOrientation.VERTICAL, true, true, false);
    ChartPanel cp = new ChartPanel(chart) {

        @Override
        public Dimension getPreferredSize() {
            return new Dimension(320, 240);
        }
    };
    FlowLayout fl = new FlowLayout();
    this.setLayout(fl);
    this.add(cp);

    setDefaultCloseOperation(EXIT_ON_CLOSE);
    pack();
}

From source file:Logica.Graficas.java

public void tipoGrafica(int tipo) {
    switch (tipo) {
    case LINEAL://from   w  ww  . jav a  2 s  .c om
        grafica = ChartFactory.createXYLineChart(null, tx, ty, datos, PlotOrientation.VERTICAL, true, true,
                true);
        break;
    case AREA:
        grafica = ChartFactory.createXYAreaChart(null, tx, ty, datos, PlotOrientation.VERTICAL, true, true,
                true);
        break;
    }
}

From source file:evaluation.simulator.gui.results.LineJFreeChartCreator.java

/**
 * Creates a chart./*from  w  ww  .  j a  va2s .  c  om*/
 * 
 * @param dataset
 *            the data for the chart.
 * 
 * @return a chart.
 */
private static JFreeChart createChart(final XYDataset dataset) {

    final JFreeChart chart = ChartFactory.createXYLineChart("Latency Mix Message", // chart title
            "BATCH_SIZE", // x axis label
            "ms", // y axis label
            dataset, // data
            PlotOrientation.VERTICAL, true, // include legend
            true, // tooltips
            false // urls
    );

    chart.setBackgroundPaint(Color.white);

    // Spezial berschreiben des Aussehen der Striche im Graphen
    final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer() {
        private static final long serialVersionUID = 1L;
        Stroke soild = new BasicStroke(2.0f);

        @Override
        public Stroke getItemStroke(int row, int column) {
            return this.soild;
        }
    };

    final XYPlot plot = chart.getXYPlot();
    plot.setRenderer(renderer);

    return chart;

}

From source file:SyntheticData.XYLineChart.java

public XYLineChart(String applicationTitle, String chartTitle, String xaxislabel, String yaxislabel,
        XYSeriesCollection dataset) throws IOException {

    super(applicationTitle);
    JFreeChart xylinechart = ChartFactory.createXYLineChart(chartTitle, xaxislabel, yaxislabel, dataset,
            PlotOrientation.VERTICAL, true, true, false);

    ChartPanel cpanel = new ChartPanel(xylinechart);
    cpanel.setPreferredSize(new java.awt.Dimension(500, 500));
    final XYPlot xyplot = xylinechart.getXYPlot();
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer.setSeriesPaint(0, Color.blue);
    renderer.setSeriesStroke(0, new BasicStroke(2.0f));
    xyplot.setRenderer(renderer);/*from  w  ww  .  jav a  2  s.c  o m*/
    setContentPane(cpanel);
    File saveImageFile = new File("" + applicationTitle + ".jpg");
    ChartUtilities.saveChartAsJPEG(saveImageFile, xylinechart, 1920, 1080);
}

From source file:com.marmoush.jann.chart.LineImg.java

@Override
public void createJPEG() {
    JFreeChart chart = ChartFactory.createXYLineChart(getTitle(), getxAxisTitle(), getyAxisTitle(),
            getXySeriesCollec(), getOrientation(), isLegend(), isTooltips(), isUrls());
    setChart(chart);/*from www.  j  a va 2s. c o  m*/
    super.createJPEG();
}

From source file:GUI.PlotHere.java

/**
 * Creates new form PlotHere/*from w  ww  . ja  v a2  s . co  m*/
 */
public PlotHere(String Title) {
    initComponents();
    XYSeries Input00 = new XYSeries("Input 00");
    XYSeries Input01 = new XYSeries("Input 01");
    XYSeries Input02 = new XYSeries("Input 02");
    XYSeriesCollection data = new XYSeriesCollection(Input00);
    data.addSeries(Input01);
    data.addSeries(Input02);
    JFreeChart chart = ChartFactory.createXYLineChart(Title, "Angle", "Voltage", data, PlotOrientation.VERTICAL,
            true, true, false);
    ChartPanel chartpanel = new ChartPanel(chart);
    //chartpanel.setDomainZoomable(true);
    chartpanel.setPreferredSize(new java.awt.Dimension(200, 200));

    //JPanel jPanel4 = new JPanel();

    Component[] a = GraphHerePanel.getComponents();
    if (a.length == 0) {
        GraphHerePanel.setLayout(new BorderLayout());
        GraphHerePanel.add(chartpanel);
    }
    this.revalidate();
    this.repaint();

}