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) 

Source Link

Document

Creates a line chart with default settings.

Usage

From source file:model.finance_management.Profit_And_Loss_Comparison_Model.java

private JPanel createChartPanel() {

    String chartTitle = "Profit Loss Comparison";
    String categoryAxisLabel = "Day";
    String valueAxisLabel = "Amount";
    CategoryDataset dataset = createDataset();

    JFreeChart chart = ChartFactory.createLineChart(chartTitle, categoryAxisLabel, valueAxisLabel, dataset);
    return new ChartPanel(chart);
}

From source file:model.finance_management.Decision_Helper_Model.java

private JPanel createChartPanel() {

    String chartTitle = "Decision Helper";
    String categoryAxisLabel = "Day";
    String valueAxisLabel = "Profit";
    CategoryDataset dataset = createDataset();

    JFreeChart chart = ChartFactory.createLineChart(chartTitle, categoryAxisLabel, valueAxisLabel, dataset);
    return new ChartPanel(chart);
}

From source file:de.unihannover.se.processSimulation.interactive.ServerMain.java

private void handlePlotImage(HttpServletRequest request, HttpServletResponse response, int requestId,
        int runNbr, String plotName) throws IOException {

    try {/*from  w  w  w  .ja va  2  s . c  om*/
        final DefaultCategoryDataset dataset = this
                .loadDatasetFromCsv(new File(this.getRunDir(requestId, runNbr), plotName + ".csv"));
        response.setContentType("image/png");
        final JFreeChart chart = ChartFactory.createLineChart("", "time", "count", dataset);
        final BufferedImage image = chart.createBufferedImage(800, 500);
        ImageIO.write(image, "PNG", response.getOutputStream());
    } catch (final Exception e) {
        e.printStackTrace();
        throw e;
    }
}

From source file:aula1.Aula1.java

public static void geraGrafico(double[] x, double[] y) {
    DefaultCategoryDataset data;/*from w w w  . j  a va 2  s  . c  o  m*/
    data = new DefaultCategoryDataset();
    int i = 0;
    String s = "";

    for (double d : x) {
        s = String.valueOf(d);
        data.addValue(y[i], "f(x)", s);
        i++;
    }

    JFreeChart grafico = ChartFactory.createLineChart("Aula 3", "X", "Y", data);
    try {
        System.out.println("Gerando Grfico");
        OutputStream arq = new FileOutputStream("Grafico2.png");

        ChartUtilities.writeChartAsPNG(arq, grafico, 2000, 1500);
        arq.close();
        System.out.println("Feito!");
    } catch (IOException error) {
        System.out.println("Erro inesperado com arquivo: " + error.getMessage());
    }

}

From source file:UserInterface.CustomerRole.ViewProfileJPanel.java

private void purchasingBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_purchasingBtnActionPerformed
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    String series1 = "Purchases";

    for (Order o : network.getMasterOrderCatalog().getOrderCatalog()) {
        if (o.getBuyer().equals(account)) {
            for (OrderItem oi : o.getOrderItemList()) {
                dataset.addValue(oi.getQuantity(), series1, o.getDate());
            }/*from w  w w .j  a v a  2 s  . c  om*/
        }
    }
    String chartTitle = "Purchase History";
    String categoryAxisLabel = "TimeStamp";
    String valueAxisLabel = "Values";

    JFreeChart chart = ChartFactory.createLineChart(chartTitle, categoryAxisLabel, valueAxisLabel, dataset);
    chart.setBackgroundPaint(Color.white);
    chart.getTitle().setPaint(Color.BLACK);
    CategoryPlot p = chart.getCategoryPlot();
    p.setRangeGridlinePaint(Color.BLUE);
    ChartFrame frame = new ChartFrame("Graph of Purchase Habit", chart);
    frame.setVisible(true);
    frame.setSize(450, 350);
}

From source file:mainpackage.FrmXuatThongTin.java

private void cbbGraphSelectionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbbGraphSelectionActionPerformed

    pnDisplayGraph.removeAll();/*from  w  ww  . j a  v a 2  s. c  o m*/

    int nodeID = cbbGraphSelection.getSelectedIndex() - 1;

    if (nodeID < 0) {
        JOptionPane.showMessageDialog(rootPane, "Please select a node");
    } else {

        DefaultCategoryDataset humidityDataSet = masterNode.getModel().getListDataSetForGraph().get(nodeID)
                .getHumidityDataSet();
        JFreeChart humidityChart = ChartFactory.createLineChart("Humidity", "Time", "%", humidityDataSet);
        ChartPanel humidityPanel = new ChartPanel(humidityChart);
        humidityPanel.setPreferredSize(new Dimension(550, 500));

        DefaultCategoryDataset temperatureDataSet = masterNode.getModel().getListDataSetForGraph().get(nodeID)
                .getTemperatureDataSet();
        JFreeChart temperatureChart = ChartFactory.createLineChart("Temperature", "Time", "Degree",
                temperatureDataSet);
        ChartPanel temperaturePanel = new ChartPanel(temperatureChart);
        temperaturePanel.setPreferredSize(new Dimension(550, 500));

        pnDisplayGraph.add(humidityPanel);
        pnDisplayGraph.add(temperaturePanel);
        pnDisplayGraph.updateUI(); // Show the components immediately

        /* TEMPORARY DISCARD
         JPanel displayPanel = new JPanel();
         displayPanel.setSize(new Dimension(700, 900));
         displayPanel.add(humidityPanel);
         displayPanel.add(temperaturePanel);
                
         JFrame displayFrame = new JFrame("Node" + nodeID);
         displayFrame.setContentPane(displayPanel);
         displayFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
         displayFrame.pack();
         displayFrame.setVisible(true);
         */
    }
}

From source file:my.estadistico.Grafica.java

private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
    try {/*from   w  w w .  java2 s  . com*/
        this.datos();//Obtiene los datos
        JFreeChart chart = ChartFactory.createLineChart(null, null, null, dataset); //Grafico de linea
        CategoryPlot catPlot = chart.getCategoryPlot();
        catPlot.setRangeGridlinePaint(Color.BLACK);
        this.mostrar(chart);
    } catch (Exception e) {
        JOptionPane.showMessageDialog(rootPane, "FAVOR DE INGRESAR DATOS");
    }
    // TODO add your handling code here:
}