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:ec.display.chart.XYSeriesChartStatistics.java

public JFreeChart makeChart() {
    JFreeChart chart = ChartFactory.createXYLineChart(this.title, this.xlabel, this.ylabel,
            this.seriesCollection, PlotOrientation.VERTICAL, true, false, false);

    return chart;
}

From source file:democsv.XYLineChart_AWT.java

public XYLineChart_AWT(String applicationTitle, String chartTitle) {
    super(applicationTitle);
    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 .j av  a 2 s .co m*/
    setContentPane(chartPanel);
}

From source file:org.jfree.chart.demo.DeviationRendererDemo1.java

private static JFreeChart createChart(XYDataset xydataset) {
    JFreeChart chart = ChartFactory.createXYLineChart("DeviationRenderer - Demo 1", "X", "Y", xydataset,
            PlotOrientation.VERTICAL, true, true, false);
    chart.setBackgroundPaint(Color.white);
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D));
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);
    //A specialised subclass of the {@link XYLineAndShapeRenderer} that requires
    // an {@link IntervalXYDataset} and represents the y-interval by shading an
    // area behind the y-values on the chart.
    DeviationRenderer renderer = new DeviationRenderer(true, false);
    renderer.setSeriesStroke(0, new BasicStroke(3F, 1, 1));
    renderer.setSeriesStroke(0, new BasicStroke(3F, 1, 1));
    renderer.setSeriesStroke(1, new BasicStroke(3F, 1, 1));
    renderer.setSeriesFillPaint(0, new Color(255, 200, 200));
    renderer.setSeriesFillPaint(1, new Color(200, 200, 255));
    plot.setRenderer(renderer);//from   w  w w.  j  a  v  a 2s .  c o  m
    //
    NumberAxis valueAxis = (NumberAxis) plot.getRangeAxis();
    valueAxis.setAutoRangeIncludesZero(false);
    valueAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    return chart;
}

From source file:iad_2_gg.gui.ChartDialog.java

public ChartDialog(java.awt.Frame parent, boolean modal, String chartTitle, String xLabel, String yLabel,
        List<Double> values, String name, int interval) {
    super(parent, modal);

    JFreeChart lineChart = ChartFactory.createXYLineChart(chartTitle, xLabel, yLabel,
            createDataset(values, name, interval), PlotOrientation.VERTICAL, true, true, false);

    ChartPanel chartPanel = new ChartPanel(lineChart);
    chartPanel.setPreferredSize(new Dimension(1200, 600));
    setContentPane(chartPanel);/* w w w . ja va  2s.co  m*/
    initComponents();
}

From source file:simcommunity.XYChart.java

public XYChart(String applicationTitle, String chartTitle, ArrayList<Float> dSet) {
    super(applicationTitle);

    // based on the dataset we create the chart
    JFreeChart pieChart = ChartFactory.createXYLineChart(chartTitle, "ERA", "OMOGENEITA'", createDataset(dSet),
            PlotOrientation.VERTICAL, true, true, false);

    // Adding chart into a chart panel
    ChartPanel chartPanel = new ChartPanel(pieChart);

    // settind default size
    chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));

    // add to contentPane
    setContentPane(chartPanel);//from ww w. ja v  a 2 s  .com

    this.pack();
    this.setVisible(true);
}

From source file:org.jfree.chart.demo.MouseListenerDemo4.java

public MouseListenerDemo4(String s) {
    super(s);/*from  www.  ja  va 2  s.c o  m*/
    String s1 = "Mouse Listener Demo 4";
    XYDataset xydataset = createDataset();
    chart = ChartFactory.createXYLineChart(s1, "X", "Y", xydataset, PlotOrientation.VERTICAL, true, true,
            false);
    chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new Dimension(500, 270));
    chartPanel.setMouseZoomable(true, false);
    chartPanel.addChartMouseListener(this);
    setContentPane(chartPanel);
}

From source file:graficarfreechart.GraficarFreeChart.java

public GraficarFreeChart(String applicationTitle, String chartTitle) {
    super(applicationTitle);

    JFreeChart xylineChart = ChartFactory.createXYLineChart(chartTitle, "Category", "Score", dataset,
            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);/*from  www  . j a va  2 s.c  om*/
    setContentPane(chartPanel);
}

From source file:signalanalysis.Graphs.java

public Graphs(final String title, ArrayList<Float> lags, String x, String y, String name) {

    super(title);
    final XYSeries series = new XYSeries(name);
    for (int i = 0; i < lags.size(); i++) {
        series.add(i, lags.get(i));//from w w  w  . ja v a 2s  . c o m
    }

    final XYSeriesCollection data = new XYSeriesCollection(series);
    final JFreeChart chart = ChartFactory.createXYLineChart(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);
}

From source file:simulation.Graf.java

public Graf(String applicationTitle, String chartTitle, String chart, String chart2) {
    super(applicationTitle);
    JFreeChart lineChart = ChartFactory.createXYLineChart(chartTitle, chart, chart2, mnozina,
            PlotOrientation.VERTICAL, true, true, false);
    plot = (XYPlot) lineChart.getPlot();
    axis = (NumberAxis) plot.getRangeAxis();
    lineChart.getLegend().setVisible(false);
    lineChart.getLegend().setPosition(RectangleEdge.RIGHT);
    ChartPanel chartPanel = new ChartPanel(lineChart);
    chartPanel.setPreferredSize(new java.awt.Dimension(560, 367));
    p = chartPanel;//from  ww w. j a va2s  .  c  o  m
    setContentPane(chartPanel);
}

From source file:logica_controladores.controlador_estadistica.java

public static void grafica_orden(JPanel panel_grafica_orden, Inventario inventario, JLabel lbLinea) {
    XYSeries serie = null;//  w w w  .  j  av  a2  s  . co m
    XYSeries serie_2 = null;

    JFreeChart linea;

    serie = new XYSeries("graficas relacion gastos-orden");
    Gasto gasto_minimo = valor_minimo(inventario);
    Gasto gasto_max = valor_maximo(inventario);
    for (int i = 0; i < inventario.getGastos().size(); i = i + inventario.getReorden_max()) {
        serie.add(inventario.getGastos().get(i).getOrden_inicial(), inventario.getGastos().get(i).getGastos());
    }
    serie_2 = new XYSeries("graficas relacion gastos-reorden");

    for (int i = 0; i < inventario.getGastos().size(); i = i + inventario.getOrden_max()) {
        serie_2.add(inventario.getGastos().get(i).getReorden(), inventario.getGastos().get(i).getGastos());
    }
    final XYSeriesCollection datos = new XYSeriesCollection();
    datos.addSeries(serie);
    datos.addSeries(serie_2);

    linea = ChartFactory.createXYLineChart(
            "grafica representativa de ordenes por corrida, gasto_minimo(orden: "
                    + gasto_minimo.getOrden_inicial() + "reorden: " + gasto_minimo.getReorden() + ")= "
                    + gasto_minimo.getGastos(),
            "rango", "gastos", datos, PlotOrientation.VERTICAL, true, true, true);
    final XYPlot plot = (XYPlot) linea.getPlot();
    final NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis();
    final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    configurarDomainAxis(domainAxis, inventario);
    configurarRangeAxis(rangeAxis, gasto_minimo.getGastos(), gasto_max.getGastos());
    BufferedImage graficoLinea = linea.createBufferedImage(600, 280);
    lbLinea.setSize(panel_grafica_orden.getSize());
    lbLinea.setIcon(new ImageIcon(graficoLinea));
    panel_grafica_orden.updateUI();
}