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:Modelos.Grafica.java

public JFreeChart crearGrafica(XYSeriesCollection dataset) {
    chart = ChartFactory.createXYLineChart("Sensores", "Tiempo", "Porcentaje", dataset,
            PlotOrientation.VERTICAL, true, // uso de leyenda
            false, // uso de tooltips  
            false // uso de urls
    );//from  www .j  av  a2  s . c o m
    // color de fondo de la grfica
    chart.setBackgroundPaint(COLOR_FONDO_GRAFICA);

    final XYPlot plot = (XYPlot) chart.getPlot();
    configurarPlot(plot);

    final NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis();
    configurarDomainAxis(domainAxis);

    final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    configurarRangeAxis(rangeAxis);

    final XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer();
    configurarRendered(renderer);

    return chart;
}

From source file:org.matsim.contrib.util.timeprofile.TimeProfileCharts.java

public static JFreeChart chartProfile(DefaultTableXYDataset dataset, ChartType type) {
    JFreeChart chart;//  w  w w  . j a v  a 2s. com
    switch (type) {
    case Line:
        chart = ChartFactory.createXYLineChart("TimeProfile", "Time [h]", "Values", dataset,
                PlotOrientation.VERTICAL, true, false, false);
        break;

    case StackedArea:
        chart = ChartFactory.createStackedXYAreaChart("TimeProfile", "Time [h]", "Values", dataset,
                PlotOrientation.VERTICAL, true, false, false);
        break;

    default:
        throw new IllegalArgumentException();
    }

    XYPlot plot = chart.getXYPlot();
    plot.setRangeGridlinesVisible(false);
    plot.setDomainGridlinesVisible(false);
    plot.setBackgroundPaint(Color.white);

    NumberAxis xAxis = (NumberAxis) plot.getDomainAxis();
    xAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    NumberAxis yAxis = (NumberAxis) plot.getRangeAxis();
    yAxis.setAutoRange(true);

    XYItemRenderer renderer = plot.getRenderer();
    for (int s = 0; s < dataset.getSeriesCount(); s++) {
        renderer.setSeriesStroke(s, new BasicStroke(2));
    }

    return chart;
}

From source file:com.thecoderscorner.groovychart.chart.XYLineChart.java

public JFreeChart createChart() {
    JFreeChart chart = ChartFactory.createXYLineChart(this.getTitle(), this.getXAxisLabel(),
            this.getYAxisLabel(), (XYDataset) this.getDataset(), this.getOrientation(), this.isLegend(),
            this.isTooltips(), this.isUrls());
    return setExtraProperties(chart);

}

From source file:statistic.graph.gui.Charts.java

public static JFreeChart createXYLineChart(DiagramData data, XYDataset dataset) {
    JFreeChart chart = ChartFactory.createXYLineChart(data.getTitle(), data.getXAxisLabel(),
            data.getYAxisLabel(), dataset, PlotOrientation.VERTICAL, true, true, false);
    initXAxis(chart.getXYPlot(), dataset);
    return chart;
}

From source file:br.unicamp.cst.behavior.bn.support.Grafico.java

public Grafico(String frametitle, String charttitle, String xlabel, String ylabel, XYSeriesCollection dataset) {
    JFreeChart chart = ChartFactory.createXYLineChart(charttitle, xlabel, ylabel, dataset,
            PlotOrientation.VERTICAL, true, true, false);

    XYPlot plot = (XYPlot) chart.getPlot();

    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(true);//w w w .  ja va2 s . c o m
    renderer.setShapesFilled(true);

    setXyplot(plot);
    setChart(chart);

    ChartFrame frame = new ChartFrame(frametitle, chart);

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

From source file:cpsControllers.LineChartController.java

/**
 * Method for create line chart./*ww  w  .  j a  v a2  s.co  m*/
 * 
 * @param t
 * @param values
 * @return 
 */
public JFreeChart printChart(ArrayList<Integer> t, ArrayList<Double> values) {

    // Prepare the data set
    XYSeries xySeries = new XYSeries("Number & Square Chart");

    double[] val = new double[values.size()];
    for (int i = 0; i < val.length; i++) {
        xySeries.add(i, values.get(i));
    }

    XYDataset xyDataset = new XYSeriesCollection(xySeries);

    //Create the chart
    JFreeChart chart = ChartFactory.createXYLineChart("Wykres liniowy", "Czas (t)", "Aplituda (A)", xyDataset,
            PlotOrientation.VERTICAL, false, true, false);

    //    //Render the frame
    //    ChartFrame chartFrame = new ChartFrame("Wykres sygnalu ", chart);
    //    chartFrame.setVisible(true);
    //    chartFrame.setSize(800, 600);

    return chart;
}

From source file:utils.Graficos_old.java

public static JFreeChart GraficoLinhas(List<CarCapContas> pagar, List<CarCapContas> receber, String titulo) {

    XYSeries series1 = new XYSeries("Pagar");

    //        CarCapContas contasPagar = new CarCapContas();
    for (CarCapContas contasPagar : pagar) {

        series1.add(contasPagar.getContaValorTotal(), contasPagar.getContaDataEmissao().getMonth());

    }//from  ww  w .  ja  v  a 2  s  .co  m

    XYSeries series2 = new XYSeries("Receber");

    for (CarCapContas contasReceber : receber) {

        series2.add(contasReceber.getContaValorTotal(), contasReceber.getContaDataEmissao().getMonth());

    }

    XYSeriesCollection dataset = new XYSeriesCollection();

    dataset.addSeries(series1);
    dataset.addSeries(series2);

    JFreeChart chart = ChartFactory.createXYLineChart(titulo, // 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...
    chart.setBackgroundPaint(Color.white);

    // 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:io.github.mzmine.util.jfreechart.ChartNodeJFreeChart.java

public ChartNodeJFreeChart() {

    super(ChartFactory.createXYLineChart("", // title
            "", // x-axis label
            "", // y-axis label
            null, // data set
            PlotOrientation.VERTICAL, // orientation
            true, // create legend?
            true, // generate tooltips?
            false // generate URLs?
    ), false);/*from  ww  w  .j  ava2  s.  c om*/

}

From source file:no.pritest.reporter.APFDGraph.java

private void makeGraph() {
    chart = ChartFactory.createXYLineChart("APFD", "Test suite fraction", "Precent Detected Faults", dataset,
            PlotOrientation.VERTICAL, true, true, false);

}

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

private static JFreeChart createChart(XYDataset xydataset) {
    JFreeChart jfreechart = ChartFactory.createXYLineChart("Crosshair Demo 4", "X", "Y", xydataset,
            PlotOrientation.VERTICAL, true, true, false);
    jfreechart.setBackgroundPaint(Color.white);
    XYPlot xyplot = (XYPlot) jfreechart.getPlot();
    xyplot.setBackgroundPaint(Color.lightGray);
    xyplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D));
    xyplot.setDomainGridlinePaint(Color.white);
    xyplot.setRangeGridlinePaint(Color.white);
    xyplot.setDomainCrosshairVisible(true);
    xyplot.setRangeCrosshairVisible(true);
    XYLineAndShapeRenderer xylineandshaperenderer = (XYLineAndShapeRenderer) xyplot.getRenderer();
    xylineandshaperenderer.setBaseShapesVisible(true);
    xylineandshaperenderer.setBaseShapesFilled(true);
    NumberAxis numberaxis = (NumberAxis) xyplot.getRangeAxis();
    numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    return jfreechart;
}