Example usage for org.jfree.chart ChartFactory createLineChart

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

Introduction

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

Prototype

public static JFreeChart createLineChart(String title, String categoryAxisLabel, String valueAxisLabel,
        CategoryDataset dataset, PlotOrientation orientation, boolean legend, boolean tooltips, boolean urls) 

Source Link

Document

Creates a line chart with default settings.

Usage

From source file:NovoClass.java

public static void main(String[] args) {
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();

    dataset.addValue(10.1, "Maximo", "Hora 1");
    dataset.addValue(20.1, "Maximo", "Hora 2");
    dataset.addValue(30.1, "Maximo", "Hora 3");
    dataset.addValue(40.1, "Maximo", "Hora 4");
    dataset.addValue(70.1, "Maximo", "Hora 5");

    JFreeChart chart = ChartFactory.createLineChart("Grafico Simpes", "Hora", "Valor", dataset,
            PlotOrientation.HORIZONTAL, true, true, false);

    try {/*w  w w.j a  va2s.co  m*/
        System.out.println("Criando...");
        OutputStream png = new FileOutputStream("GraficoSimples.png");
        ChartUtilities.writeChartAsPNG(png, chart, 500, 400);
        png.close();
    } catch (Exception e) {
    }
}

From source file:com.jaxzin.iraf.demo.CdfInv.java

public static void main(String[] args) {
    final JFreeChart chart = ChartFactory.createLineChart("Inverse CDF", "", "", createData(400),
            PlotOrientation.VERTICAL, true, true, true);

    // Customize the chart
    customizeChart(chart);/*  w  w  w .j av a  2 s  .c  o m*/

    final JPanel panel = new ChartPanel(chart, true);
    final JFrame frame = new JFrame("Demo");
    frame.getContentPane().add(panel);
    setupJFrame(frame);
}

From source file:com.etest.view.tq.charts.SubjectTestLineChart.java

public static JFreeChart discriminationIndex(int tqCoverageId) {
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();

    for (CellItem ci : CellItemDAO.getItemAnalysisResult(tqCoverageId)) {
        dataset.setValue((int) (ci.getDiscriminationIndex() * 100), "Discrimination Index",
                String.valueOf(ci.getItemNo()));
    }/* w  w  w. ja  va  2  s  .c om*/

    JFreeChart chart = ChartFactory.createLineChart("Item Analysis Report", "Item No.",
            "Discrimination Index (%)", dataset, PlotOrientation.VERTICAL, true, true, false);

    chart.setBackgroundPaint(Color.white);
    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setRangeGridlinePaint(Color.white);

    // customise the range axis...
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    // customise the renderer...
    LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer();
    renderer.setShapesVisible(true);
    renderer.setDrawOutlines(true);
    renderer.setUseFillPaint(true);
    renderer.setFillPaint(Color.white);

    return chart;
}

From source file:test.LineChart_AWT.java

public LineChart_AWT(String applicationTitle, String chartTitle) {
    super(applicationTitle);
    JFreeChart lineChart = ChartFactory.createLineChart(chartTitle, "Years", "Number of Schools",
            createDataset(), PlotOrientation.VERTICAL, true, true, false);

    ChartPanel chartPanel = new ChartPanel(lineChart);
    chartPanel.setPreferredSize(new java.awt.Dimension(560, 367));
    setContentPane(chartPanel);//from  w  w  w  .  j av  a2  s.  c  o  m
}

From source file:nodeconfig.SuspectLine.java

public SuspectLine(String applicationTitle, String chartTitle) {
    super(applicationTitle);
    JFreeChart lineChart = ChartFactory.createLineChart(chartTitle, "Nodes", "Degree Of Suspect",
            createDataset(), PlotOrientation.VERTICAL, true, true, false);

    ChartPanel chartPanel = new ChartPanel(lineChart);
    chartPanel.setPreferredSize(new java.awt.Dimension(560, 367));
    setContentPane(chartPanel);/*  ww w .  ja  va2 s  .c  o  m*/
}

From source file:TemHm.LineChart_AWT.java

public LineChart_AWT(String applicationTitle, String chartTitle) {
    super(applicationTitle);
    JFreeChart lineChart = ChartFactory.createLineChart(chartTitle, "Registo", "temperatura", createDataset(),
            PlotOrientation.VERTICAL, true, true, false);

    ChartPanel chartPanel = new ChartPanel(lineChart);
    chartPanel.setPreferredSize(new java.awt.Dimension(560, 367));
    setContentPane(chartPanel);//from   w w w  . j a  v a 2  s  .c o  m
}

From source file:adept.utilities.Grapher.java

/**
 * Make heap usage graph.//  w ww . j ava 2  s  . com
 *
 * @param values the values
 * @param filename the filename
 */
public static void makeHeapUsageGraph(ArrayList<Double> values, File filename) {
    try {
        DefaultCategoryDataset line_chart_dataset = new DefaultCategoryDataset();
        for (int i = 1; i <= values.size(); i++) {
            line_chart_dataset.addValue(values.get(i - 1), "MB", "" + i);
        }

        /* Step -2:Define the JFreeChart object to create line chart */
        JFreeChart lineChartObject = ChartFactory.createLineChart("Heap Memory Usage", "Run Number",
                "Heap Memory Used", line_chart_dataset, PlotOrientation.VERTICAL, true, true, false);

        /* Step -3 : Write line chart to a file */
        int width = 640; /* Width of the image */
        int height = 480; /* Height of the image */
        ChartUtilities.saveChartAsPNG(filename, lineChartObject, width, height);
    }

    catch (Exception e) {
        e.printStackTrace();
    }

}

From source file:geneticalgorithm2.LineChart_AWT.java

public LineChart_AWT(String applicationTitle, String chartTitle, ArrayList<Double> fitnessArrayList) {
    super(applicationTitle);
    JFreeChart lineChart = ChartFactory.createLineChart(chartTitle, "Number of Generations", "Minimum Value",
            createDataset(fitnessArrayList), PlotOrientation.VERTICAL, true, true, false);

    ChartPanel chartPanel = new ChartPanel(lineChart);
    chartPanel.setPreferredSize(new java.awt.Dimension(560, 367));
    setContentPane(chartPanel);/*from w w  w  .java  2s  .c  om*/
}

From source file:nodeconfig.FinalSuspectLine.java

public FinalSuspectLine(String applicationTitle, String chartTitle) {
    super(applicationTitle);
    JFreeChart lineChart = ChartFactory.createLineChart(chartTitle, "Nodes", "Degree Of Suspect",
            createDataset(), PlotOrientation.VERTICAL, true, true, false);

    ChartPanel chartPanel = new ChartPanel(lineChart);
    chartPanel.setPreferredSize(new java.awt.Dimension(560, 367));
    setContentPane(chartPanel);// ww w.  ja v  a  2  s . c o m
}

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

public LineChart(String applicationTitle, String chartTitle) {
    super(applicationTitle);
    setDefaultCloseOperation(ApplicationFrame.EXIT_ON_CLOSE);
    JFreeChart lineChart = ChartFactory.createLineChart(chartTitle, "Years", "Number of Schools",
            createDataset(), PlotOrientation.VERTICAL, true, true, false);

    ChartPanel chartPanel = new ChartPanel(lineChart);
    chartPanel.setPreferredSize(new java.awt.Dimension(560, 367));
    setContentPane(chartPanel);//from   w  ww .  jav a  2 s .  c  om
}