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:overTrial.CreateGraphOverTrial.java

public CreateGraphOverTrial(String applicationTitle, String chartTitle, LinkedList<LinkedList<String>> pData,
        int sensorNum, String sessionNo) {
    super(applicationTitle);
    this.pressureData = pData;
    this.sensorNumber = sensorNum;
    JFreeChart lineChart = ChartFactory.createLineChart(chartTitle, sessionNo,
            "Average Pressure Value over the time(per trail)", createDataset(), PlotOrientation.VERTICAL, true,
            true, false);/*  www. ja  va  2s  . co m*/
    //lineChart.setBackgroundPaint(Color.red);
    ChartPanel chartPanel = new ChartPanel(lineChart);
    chartPanel.setPreferredSize(new java.awt.Dimension(1200, 500));
    setContentPane(chartPanel);

    File fileLineChart = new File(sessionNo + "_sensor" + this.sensorNumber + ".jpeg");
    try {
        ChartUtilities.saveChartAsJPEG(fileLineChart, lineChart, 1200, 500);
    } catch (IOException e) {
        e.printStackTrace();
    }

}

From source file:pdfboxtest.HistandVolChart.java

public File chart(String ticker, int numberOfYears) throws Exception {
    BufferedReader reader = null;
    String splitBy = ",";
    String line;/*ww  w .jav a2 s .c om*/
    double stockPrice;
    File file = new File(
            "C:\\Users\\Matthew\\Documents\\NetBeansProjects\\TradingData\\ticker\\" + ticker + ".data");
    reader = new BufferedReader(new FileReader(file));

    DefaultCategoryDataset stockDataSet = new DefaultCategoryDataset();
    while (reader.readLine() != null) {
        line = reader.readLine();
        String[] stockData = line.split(splitBy);
        stockPrice = Double.parseDouble(stockData[0]);
        stockDataSet.addValue(stockPrice, ticker, line);
    }

    JFreeChart chartObject = ChartFactory.createLineChart(null, null, null, stockDataSet,
            PlotOrientation.VERTICAL, false, false, false);
    int width = 300;
    int height = 200;
    File chart = new File("C:\\Users\\Matthew\\Documents\\NetBeansProjects\\PDFBoxTest\\" + ticker + ".jpg");
    ChartUtilities.saveChartAsJPEG(chart, chartObject, width, height);
    return chart;
}

From source file:overTrialSensorSubDivided.CreateGraphSubDivided.java

public CreateGraphSubDivided(String applicationTitle, String chartTitle, LinkedList<LinkedList<String>> pData,
        int sensorNum, String sessionNo) {
    super(applicationTitle);
    this.pressureData = pData;
    this.sensorNumber = sensorNum;
    JFreeChart lineChart = ChartFactory.createLineChart(chartTitle, sessionNo,
            "Average Pressure Value over the time(per trail)", createDataset(), PlotOrientation.VERTICAL, true,
            true, false);/*ww  w  . j  av a  2s  .c o  m*/
    //lineChart.setBackgroundPaint(Color.red);
    ChartPanel chartPanel = new ChartPanel(lineChart);
    chartPanel.setPreferredSize(new java.awt.Dimension(700, 500));
    setContentPane(chartPanel);

    File fileLineChart = new File(sessionNo + "_sensor" + this.sensorNumber + ".jpeg");
    try {
        ChartUtilities.saveChartAsJPEG(fileLineChart, lineChart, 1100, 500);
    } catch (IOException e) {
        e.printStackTrace();
    }

}

From source file:overTrialFluctuations.CreateGraphTrialFluctuations.java

public CreateGraphTrialFluctuations(String applicationTitle, String chartTitle,
        LinkedList<LinkedList<String>> pData, int sensorNum, String sessionNo) {
    super(applicationTitle);
    this.pressureData = pData;
    this.sensorNumber = sensorNum;
    JFreeChart lineChart = ChartFactory.createLineChart(chartTitle, sessionNo,
            "Average Pressure Value over the time(per trail)", createDataset(), PlotOrientation.VERTICAL, true,
            true, false);// w  ww .  j  a va  2s  .c om
    //lineChart.setBackgroundPaint(Color.red);
    ChartPanel chartPanel = new ChartPanel(lineChart);
    chartPanel.setPreferredSize(new java.awt.Dimension(700, 500));
    setContentPane(chartPanel);

    File fileLineChart = new File(sessionNo + "_sensor" + this.sensorNumber + ".jpeg");
    try {
        ChartUtilities.saveChartAsJPEG(fileLineChart, lineChart, 1100, 500);
    } catch (IOException e) {
        e.printStackTrace();
    }

}

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

private static JFreeChart createChart(CategoryDataset categorydataset) {
    JFreeChart jfreechart = ChartFactory.createLineChart("Line Chart Demo 8", "Category", "Count",
            categorydataset, PlotOrientation.VERTICAL, true, true, false);
    jfreechart.setBackgroundPaint(Color.white);
    CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot();
    categoryplot.setBackgroundPaint(Color.lightGray);
    categoryplot.setRangeGridlinePaint(Color.white);
    SymbolAxis symbolaxis = new SymbolAxis("Group", new String[] { "A", "B", "C", "D", "E", "F" });
    categoryplot.setRangeAxis(symbolaxis);
    LineAndShapeRenderer lineandshaperenderer = (LineAndShapeRenderer) categoryplot.getRenderer();
    lineandshaperenderer.setSeriesShapesVisible(0, true);
    lineandshaperenderer.setSeriesShapesVisible(1, false);
    lineandshaperenderer.setSeriesShapesVisible(2, true);
    lineandshaperenderer.setSeriesLinesVisible(2, false);
    lineandshaperenderer.setSeriesShape(2, ShapeUtilities.createDiamond(4F));
    lineandshaperenderer.setDrawOutlines(true);
    lineandshaperenderer.setUseFillPaint(true);
    lineandshaperenderer.setBaseFillPaint(Color.white);
    return jfreechart;
}

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

private static JFreeChart createChart(CategoryDataset categorydataset) {
    JFreeChart jfreechart = ChartFactory.createLineChart("Line Chart Demo 7", "Category", "Count",
            categorydataset, PlotOrientation.VERTICAL, true, true, false);
    jfreechart.setBackgroundPaint(Color.white);
    CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot();
    categoryplot.setBackgroundPaint(Color.lightGray);
    categoryplot.setRangeGridlinePaint(Color.white);
    NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis();
    numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    LineAndShapeRenderer lineandshaperenderer = (LineAndShapeRenderer) categoryplot.getRenderer();
    lineandshaperenderer.setSeriesShapesVisible(0, true);
    lineandshaperenderer.setSeriesShapesVisible(1, false);
    lineandshaperenderer.setSeriesShapesVisible(2, true);
    lineandshaperenderer.setSeriesLinesVisible(2, false);
    lineandshaperenderer.setSeriesShape(2, ShapeUtilities.createDiamond(4F));
    lineandshaperenderer.setDrawOutlines(true);
    lineandshaperenderer.setUseFillPaint(true);
    lineandshaperenderer.setBaseFillPaint(Color.white);
    return jfreechart;
}

From source file:net.sourceforge.processdash.ui.web.reports.LineChart.java

/** Create a  line chart. */
public JFreeChart createChart() {
    JFreeChart chart = ChartFactory.createLineChart(null, null, null, data.catDataSource(),
            PlotOrientation.VERTICAL, true, true, false);
    setupCategoryChart(chart);//  www  .ja va 2  s  . c o  m

    return chart;
}

From source file:Interface.Teste.java

public void criacao() {
    DefaultCategoryDataset ds = new DefaultCategoryDataset();
    ds.addValue(40.5, "maximo", "dia 1");
    ds.addValue(38.2, "maximo", "dia 2");
    ds.addValue(37.3, "maximo", "dia 3");
    ds.addValue(31.5, "maximo", "dia 4");
    ds.addValue(35.7, "maximo", "dia 5");
    ds.addValue(42.5, "maximo", "dia 6");

    // cria o grfico
    JFreeChart grafico = ChartFactory.createLineChart("Meu Grafico", "Dia", "Valor", ds,
            PlotOrientation.VERTICAL, true, true, false);
    try {/*  w  w w.java2  s. co  m*/
        OutputStream arquivo = new FileOutputStream("grafico.png");
        ChartUtilities.writeChartAsPNG(arquivo, grafico, 550, 400);
        arquivo.close();
    } catch (Exception e) {
        e.printStackTrace();
    }
    JPopupMenu pop = new JPopupMenu();
    pop.add(new JMenuItem("1"));
    pop.add(new JMenuItem("2"));
    pop.add(new JMenuItem("3"));
    pop.add(new JMenuItem("4"));
    JPanel painel = new JPanel();
    JButton botao = new JButton("teste");
    JCalendar cal = new JCalendar();
    botao.add(pop);
    painel.add(cal);
    painel.add(new ChartPanel(grafico));
    //Calendar c = cal.getDate();
    Date data = cal.getDate();
    int dia = data.getDay();
    System.out.println("" + dia);

    add(painel);
}

From source file:service.chart.FitnessChart.java

/**
 * Utworz wykres funkcji fitness dla najlepszego osobnika w danej iteracji algorytmu genetycznego 
 * na podstawie zestawu danych/*w  w  w .  j a  v  a  2s  .  c o m*/
 * 
 * @param categoryDataset Zestaw danych
 * @return Wykres funkcji fitness
 */
private static JFreeChart createChart(CategoryDataset categoryDataset) {

    JFreeChart chart = ChartFactory.createLineChart("Best fitness function value", // title
            "Iteration", // x-axis label
            "Fitness", // y-axis label
            categoryDataset, // data
            PlotOrientation.VERTICAL, true, // create legend?
            true, // generate tooltips?
            false // generate URLs?
    );

    chart.setBackgroundPaint(Color.white);

    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.white);
    plot.setDomainGridlinePaint(Color.lightGray);
    plot.setRangeGridlinePaint(Color.lightGray);
    plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    plot.setDomainCrosshairVisible(true);
    plot.setRangeCrosshairVisible(true);

    CategoryItemRenderer r = plot.getRenderer();
    if (r instanceof LineAndShapeRenderer) {
        LineAndShapeRenderer renderer = (LineAndShapeRenderer) r;
        renderer.setBaseShapesVisible(false);
        renderer.setBaseShapesFilled(true);
    }

    return chart;
}

From source file:net.neurowork.cenatic.centraldir.model.graphs.LinechartGraphCreator.java

@Override
public JFreeChart createGraphChart(String title, String yAxis, Dataset data) {
    PlotOrientation orientation = PlotOrientation.VERTICAL;
    boolean legend = true;
    boolean tooltips = true;
    boolean urls = false;

    return ChartFactory.createLineChart(title, "", yAxis, (CategoryDataset) data, orientation, legend, tooltips,
            urls);//  w w w .  j a  va2s . c o m
}