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:graph.plotter.LineGraph.java

/**
 * This is the main working button for this class... It creates Line Graph analyZing whole data set
 * /*from  w  ww.  j  ava  2 s .  c  o m*/
 * @param evt 
 */
private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
    // TODO add your handling code here:
    try {
        DefaultCategoryDataset dataset = new DefaultCategoryDataset();
        int i;
        i = 0;
        String genre = " ";
        if (button1 == 2) {
            if (button2 == 1)
                while (i < cnt) {
                    double aa = Double.parseDouble(Table.getModel().getValueAt(i, 1).toString());
                    String str = Table.getModel().getValueAt(i, 0).toString();
                    dataset.setValue(new Double(aa), genre, str);
                    i++;
                    //genre+=" ";

                }
            else {
                try {
                    BufferedReader br = new BufferedReader(new FileReader(jTextField4.getText()));
                    String Line;
                    while ((Line = br.readLine()) != null) {
                        String[] value = Line.split(",");
                        double val = Double.parseDouble(value[1]);

                        dataset.setValue(new Double(val), genre, value[0]);
                        //   genre+=" ";
                        ////System.out.println(value[0]);
                    }
                } catch (FileNotFoundException ex) {
                    Logger.getLogger(LineGraph.class.getName()).log(Level.SEVERE, null, ex);
                } catch (IOException ex) {
                    Logger.getLogger(LineGraph.class.getName()).log(Level.SEVERE, null, ex);
                }

            }
        } else if (button1 == 1) {

            String input = jTextField1.getText();
            input = input.replaceAll("sin", "@");
            input = input.replaceAll("cos", "#");
            input = input.replaceAll("tan", "Q");
            input = input.replaceAll("log", "~");
            input = input.replaceAll("e", "&");
            input = input.replaceAll("cosec", "r");
            input = input.replaceAll("cot", "w");
            input = input.replaceAll("sec", "y");

            //System.out.println(input);
            int len;
            len = input.length();
            String so = ".";

            for (ind = 0; ind < 360; ind++) {
                String gini = input;

                String sa = Integer.toString(ind);
                gini = gini.replaceAll("X", sa);

                Polish polish = new Polish(gini);
                double Calculate = Polish.Calculate();
                dataset.setValue(new Double(Calculate), ".", sa);
                so += ".";
            }

        }

        JFreeChart chart = ChartFactory.createLineChart("Line Graph", "X - Axis", "Y - Axis", dataset,
                PlotOrientation.VERTICAL, false, true, false);
        CategoryPlot p = chart.getCategoryPlot();
        p.setRangeGridlinePaint(Color.YELLOW);
        p.setBackgroundPaint(Color.BLACK);
        ChartFrame frame = new ChartFrame("Line Chart", chart);
        jButto1 = new JButton("Save");

        frame.setLayout(new BorderLayout());

        JPanel panel = new JPanel();
        panel.setLayout(new GridBagLayout());

        GridBagConstraints gc = new GridBagConstraints();
        gc.gridx = 1;
        gc.gridy = 0;

        panel.add(jButto1, gc);

        frame.add(panel, BorderLayout.SOUTH);

        jButto1.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {

                try {
                    final ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection());
                    final File file1 = new File("Line_Chart.png");
                    ChartUtilities.saveChartAsPNG(file1, chart, 600, 400, info);
                } catch (Exception ex) {

                }

            }
        });
        frame.setVisible(true);

        frame.setSize(858, 513);
    } catch (Exception e) {

    }
}

From source file:hudson.plugins.plot.PlotData.java

/**
 * Creates a Chart of the style indicated by getEffStyle() using the given dataset.
 * Defaults to using createLineChart./* w  w w .  j  a  va2 s  .  c  o m*/
 */
private JFreeChart createChart(PlotCategoryDataset dataset) {
    String s = getUrlStyle();
    if (s.equalsIgnoreCase("area")) {
        return ChartFactory.createAreaChart(getURLTitle(), /*categoryAxisLabel=*/null, getYaxis(), dataset,
                PlotOrientation.VERTICAL, hasLegend(), /*tooltips=*/true, /*url=*/false);
    }
    if (s.equalsIgnoreCase("bar")) {
        return ChartFactory.createBarChart(getURLTitle(), /*categoryAxisLabel=*/null, getYaxis(), dataset,
                PlotOrientation.VERTICAL, hasLegend(), /*tooltips=*/true, /*url=*/false);
    }
    if (s.equalsIgnoreCase("bar3d")) {
        return ChartFactory.createBarChart3D(getURLTitle(), /*categoryAxisLabel=*/null, getYaxis(), dataset,
                PlotOrientation.VERTICAL, hasLegend(), /*tooltips=*/true, /*url=*/false);
    }
    if (s.equalsIgnoreCase("line3d")) {
        return ChartFactory.createLineChart3D(getURLTitle(), /*categoryAxisLabel=*/null, getYaxis(), dataset,
                PlotOrientation.VERTICAL, hasLegend(), /*tooltips=*/true, /*url=*/false);
    }
    if (s.equalsIgnoreCase("stackedarea")) {
        return ChartFactory.createStackedAreaChart(getURLTitle(), /*categoryAxisLabel=*/null, getYaxis(),
                dataset, PlotOrientation.VERTICAL, hasLegend(), /*tooltips=*/true, /*url=*/false);
    }
    if (s.equalsIgnoreCase("stackedbar")) {
        return ChartFactory.createStackedBarChart(getURLTitle(), /*categoryAxisLabel=*/null, getYaxis(),
                dataset, PlotOrientation.VERTICAL, hasLegend(), /*tooltips=*/true, /*url=*/false);
    }
    if (s.equalsIgnoreCase("stackedbar3d")) {
        return ChartFactory.createStackedBarChart3D(getURLTitle(), /*categoryAxisLabel=*/null, getYaxis(),
                dataset, PlotOrientation.VERTICAL, hasLegend(), /*tooltips=*/true, /*url=*/false);
    }
    if (s.equalsIgnoreCase("waterfall")) {
        return ChartFactory.createWaterfallChart(getURLTitle(), /*categoryAxisLabel=*/null, getYaxis(), dataset,
                PlotOrientation.VERTICAL, hasLegend(), /*tooltips=*/true, /*url=*/false);
    }
    return ChartFactory.createLineChart(getURLTitle(), /*categoryAxisLabel=*/null, getYaxis(), dataset,
            PlotOrientation.VERTICAL, hasLegend(), /*tooltips=*/true, /*url=*/false);
}

From source file:de.forsthaus.webui.customer.CustomerChartCtrl.java

/**
 * onClick button Line Bar Chart. <br>
 * // www .ja va 2  s. c om
 * @param event
 * @throws IOException
 */
public void onClick$button_CustomerChart_LineBar(Event event) throws InterruptedException, IOException {
    // logger.debug(event.toString());

    div_chartArea.getChildren().clear();

    // get the customer ID for which we want show a chart
    long kunId = getCustomer().getId();

    // get a list of data
    List<ChartData> kunAmountList = getChartService().getChartDataForCustomer(kunId);

    if (kunAmountList.size() > 0) {

        DefaultCategoryDataset dataset = new DefaultCategoryDataset();

        for (ChartData chartData : kunAmountList) {

            Calendar calendar = new GregorianCalendar();
            calendar.setTime(chartData.getChartKunInvoiceDate());

            int month = calendar.get(Calendar.MONTH) + 1;
            int year = calendar.get(Calendar.YEAR);
            String key = String.valueOf(month) + "/" + String.valueOf(year);

            BigDecimal bd = chartData.getChartKunInvoiceAmount().setScale(15, 3);
            String amount = String.valueOf(bd.doubleValue());

            // fill the data
            dataset.setValue(new Double(chartData.getChartKunInvoiceAmount().doubleValue()), "2009",
                    key + " " + amount);
        }

        String title = "Monthly amount for year 2009";
        PlotOrientation po = PlotOrientation.VERTICAL;
        JFreeChart chart = ChartFactory.createLineChart(title, "Month", "Amount", dataset, po, true, true,
                true);

        CategoryPlot plot = (CategoryPlot) chart.getPlot();
        plot.setForegroundAlpha(0.5f);
        BufferedImage bi = chart.createBufferedImage(chartWidth, chartHeight, BufferedImage.TRANSLUCENT, null);
        byte[] bytes = EncoderUtil.encode(bi, ImageFormat.PNG, true);

        AImage chartImage = new AImage("Line Bar Chart", bytes);

        Image img = new Image();
        img.setContent(chartImage);
        img.setParent(div_chartArea);

    } else {

        div_chartArea.getChildren().clear();

        Label label = new Label();
        label.setValue("This customer have no data for showing in a chart!");

        label.setParent(div_chartArea);

    }
}

From source file:org.pentaho.chart.plugin.jfreechart.JFreeChartFactoryEngine.java

public JFreeChart makeLineChart(ChartModel chartModel, MultiSeriesDataModel dataModel,
        IChartLinkGenerator linkGenerator) {
    DefaultCategoryDataset categoryDataset = createCategoryDataset(dataModel);
    org.pentaho.chart.model.TwoAxisPlot twoAxisPlot = (org.pentaho.chart.model.TwoAxisPlot) chartModel
            .getPlot();//from   w ww  .  j av  a2 s. c om

    String title = "";
    if ((chartModel.getTitle() != null) && (chartModel.getTitle().getText() != null)
            && (chartModel.getTitle().getText().trim().length() > 0)) {
        title = chartModel.getTitle().getText();
    }
    AxesLabels axesLabels = getAxesLabels(chartModel);
    PlotOrientation plotOrientation = (twoAxisPlot.getOrientation() == Orientation.HORIZONTAL)
            ? PlotOrientation.HORIZONTAL
            : PlotOrientation.VERTICAL;
    boolean showLegend = (chartModel.getLegend() != null) && (chartModel.getLegend().getVisible());
    JFreeChart chart = null;

    LinePlot linePlot = (LinePlot) twoAxisPlot;
    if (linePlot.getFlavor() == LinePlotFlavor.THREED) {
        chart = ChartFactory.createLineChart3D(title, axesLabels.domainAxisLabel, axesLabels.rangeAxisLabel,
                categoryDataset, plotOrientation, showLegend, true, false);
    } else {
        chart = ChartFactory.createLineChart(title, axesLabels.domainAxisLabel, axesLabels.rangeAxisLabel,
                categoryDataset, plotOrientation, showLegend, true, false);
        Stroke stroke = getLineStyleStroke(linePlot.getFlavor(), linePlot.getLineWidth());
        ((CategoryPlot) chart.getPlot()).getRenderer().setStroke(stroke);
    }

    initCategoryPlot(chart, chartModel, linkGenerator);
    initChart(chart, chartModel);

    return chart;
}

From source file:com.sun.japex.ChartGenerator.java

private int generateTestCaseLineCharts(String baseName, String extension) {
    int nOfFiles = 0;
    List<DriverImpl> driverInfoList = _testSuite.getDriverInfoList();

    // Get number of tests from first driver
    final int nOfTests = driverInfoList.get(0).getAggregateTestCases().size();

    int groupSizesIndex = 0;
    int[] groupSizes = calculateGroupSizes(nOfTests, _plotGroupSize);

    try {//from w  ww  .  j a v a2s.  c o m
        String resultUnit = _testSuite.getParam(Constants.RESULT_UNIT);

        // Generate charts 
        DefaultCategoryDataset dataset = new DefaultCategoryDataset();

        int i = 0, thisGroupSize = 0;
        for (; i < nOfTests; i++) {

            for (DriverImpl di : driverInfoList) {
                TestCaseImpl tc = (TestCaseImpl) di.getAggregateTestCases().get(i);

                dataset.addValue(tc.getDoubleParamNoNaN(Constants.RESULT_VALUE),
                        _plotDrivers ? di.getName() : tc.getName(), _plotDrivers ? tc.getName() : di.getName());
            }

            thisGroupSize++;

            // Generate chart for this group if complete
            if (thisGroupSize == groupSizes[groupSizesIndex]) {
                JFreeChart chart = ChartFactory.createLineChart(
                        (_plotDrivers ? "Results per Driver (" : "Results per Test (") + resultUnit + ")", "",
                        resultUnit, dataset, PlotOrientation.VERTICAL, true, true, false);

                configureLineChart(chart);

                chart.setAntiAlias(true);
                ChartUtilities.saveChartAsJPEG(new File(baseName + Integer.toString(nOfFiles) + extension),
                        chart, _chartWidth, _chartHeight);

                nOfFiles++;
                groupSizesIndex++;
                thisGroupSize = 0;
                dataset = new DefaultCategoryDataset();
            }
        }
    } catch (RuntimeException e) {
        throw e;
    } catch (Exception e) {
        e.printStackTrace();
    }

    return nOfFiles;
}

From source file:Balo.MainFram.java

private void Button_ResultActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Button_ResultActionPerformed
    // TODO add your handling code here:
    //==========================================================
    if (RadioLine.isSelected()) {
        long timeG = 0;
        long timeD = 0;
        String csv = "D:\\ResultGTNC.csv";
        CSVWriter writer = null;/*from  w  w  w .j av a  2  s .  c om*/
        try {
            writer = new CSVWriter(new FileWriter(csv));
        } catch (IOException ex) {
            Logger.getLogger(MainFram.class.getName()).log(Level.SEVERE, null, ex);
        }
        List<String[]> data = new ArrayList<String[]>();
        data.add(new String[] { "Weight", "Greedy", "Dynamic" });
        weightBag = Integer.parseInt(TextW.getText());
        DefaultCategoryDataset barChart = new DefaultCategoryDataset();
        //Get all data
        for (int i = 10; i <= 700; i = i + 40) {
            InitData();
            timeG = balo.timeToRunGreedy(dvGreedy, numOfItem, i);
            timeD = balo.timeToRunDynamic(dvDynamic, numOfItem, i);
            barChart.setValue(timeG, "Tham n          ", String.valueOf(i));
            barChart.setValue(timeD, "Quy hoch ng   ", String.valueOf(i));
            data.add(new String[] { String.valueOf(i), String.valueOf(timeG), String.valueOf(timeD) });
        }

        writer.writeAll(data);
        try {
            writer.close();
        } catch (IOException ex) {
            Logger.getLogger(MainFram.class.getName()).log(Level.SEVERE, null, ex);
        }
        //==========================================================
        JFreeChart jbarChart = ChartFactory.createLineChart("Biu  th?i gian thc hin",
                "Tr?ng lng ca ba l", "micro giy", barChart, PlotOrientation.VERTICAL, true, true,
                true);
        CategoryPlot barchrt = (CategoryPlot) jbarChart.getPlot();
        ChartPanel barPanel = new ChartPanel(jbarChart);
        Panel_Chart.removeAll();
        Panel_Chart.setLayout(new BorderLayout());
        Panel_Chart.add(barPanel, BorderLayout.CENTER);
        Panel_Chart.validate();
    } else if (RadioColumn.isSelected()) {
        String csv = "D:\\ResultColumn.csv";
        CSVWriter writer = null;
        try {
            writer = new CSVWriter(new FileWriter(csv));
        } catch (IOException ex) {
            Logger.getLogger(MainFram.class.getName()).log(Level.SEVERE, null, ex);
        }
        List<String[]> data = new ArrayList<String[]>();
        data.add(new String[] { "Result", "Greedy", "Dynamic" });
        InitData();
        weightBag = Integer.parseInt(TextW.getText());
        long timeG = balo.timeToRunGreedy(dvGreedy, numOfItem, weightBag);
        String resultGreedy = balo.resultGreedy(dvGreedy, numOfItem);
        TextAreaGreedy.setText(resultGreedy);
        long timeD = balo.timeToRunDynamic(dvDynamic, numOfItem, weightBag);
        String resultDynamic = balo.resultDynamic(dvDynamic, numOfItem, weightBag);
        TextAreaDynamic.setText(resultDynamic);

        //Random data
        long timeG2 = balo.timeToRunGreedy(dvGreedy2, numOfItem2, weightBag);
        long timeD2 = balo.timeToRunDynamic(dvDynamic2, numOfItem2, weightBag);

        data.add(new String[] { "File", String.valueOf(timeG), String.valueOf(timeD) });
        data.add(new String[] { "Random", String.valueOf(timeG2), String.valueOf(timeD2) });
        writer.writeAll(data);
        try {
            writer.close();
        } catch (IOException ex) {
            Logger.getLogger(MainFram.class.getName()).log(Level.SEVERE, null, ex);
        }

        //==========================================================
        DefaultCategoryDataset barChart = new DefaultCategoryDataset();
        barChart.setValue(timeG, "Tham n          ", "D liu thc nghim");
        barChart.setValue(timeD, "Quy hoch ng   ", "D liu thc nghim");

        barChart.setValue(timeG2, "Tham n          ", "D liu ngu nhin");
        barChart.setValue(timeD2, "Quy hoch ng   ", "D liu ngu nhin");

        JFreeChart jbarChart = ChartFactory.createBarChart("Biu  th?i gian thc hin",
                "Tr?ng lng ti a ca ba l", "micro giy", barChart, PlotOrientation.VERTICAL,
                true, true, true);
        CategoryPlot barchrt = (CategoryPlot) jbarChart.getPlot();

        ChartPanel barPanel = new ChartPanel(jbarChart);
        Panel_Chart.removeAll();
        Panel_Chart.setLayout(new BorderLayout());
        Panel_Chart.add(barPanel, BorderLayout.CENTER);
        Panel_Chart.validate();
    } else { // Tr?ng lng khng i, s lng  vt thay i.
        long timeG = 0;
        long timeD = 0;
        String csv = "D:\\ResultItemChage.csv";
        CSVWriter writer = null;
        try {
            writer = new CSVWriter(new FileWriter(csv));
        } catch (IOException ex) {
            Logger.getLogger(MainFram.class.getName()).log(Level.SEVERE, null, ex);
        }
        List<String[]> data = new ArrayList<String[]>();
        data.add(new String[] { "Num of Item", "Greedy", "Dynamic" });
        weightBag = Integer.parseInt(TextW.getText());
        DefaultCategoryDataset barChart = new DefaultCategoryDataset();
        //Get all data
        for (int i = 1; i <= 77; i = i + 4) {
            RandomData(i);
            timeG = balo.timeToRunGreedy(dvGreedy2, i, weightBag);
            timeD = balo.timeToRunDynamic(dvDynamic2, i, weightBag);
            barChart.setValue(timeG, "Tham n          ", String.valueOf(i));
            barChart.setValue(timeD, "Quy hoch ng   ", String.valueOf(i));
            data.add(new String[] { String.valueOf(i), String.valueOf(timeG), String.valueOf(timeD) });
        }

        writer.writeAll(data);
        try {
            writer.close();
        } catch (IOException ex) {
            Logger.getLogger(MainFram.class.getName()).log(Level.SEVERE, null, ex);
        }
        //==========================================================
        JFreeChart jbarChart = ChartFactory.createLineChart(
                "Biu  th?i gian thc hin khi s lng  vt thay i",
                "S lng  vt", "micro giy", barChart, PlotOrientation.VERTICAL, true, true,
                true);
        CategoryPlot barchrt = (CategoryPlot) jbarChart.getPlot();
        ChartPanel barPanel = new ChartPanel(jbarChart);
        Panel_Chart.removeAll();
        Panel_Chart.setLayout(new BorderLayout());
        Panel_Chart.add(barPanel, BorderLayout.CENTER);
        Panel_Chart.validate();
    }
}

From source file:ds.monte.carlo.Application.java

private void createGrowthGraph(double[] growthMap) {
    DefaultCategoryDataset growthDataset = new DefaultCategoryDataset();
    double min = 1000000;
    double max = 0;
    int l_100 = growthMap.length;
    int l_40 = (int) Math.round(l_100 * 0.4);
    System.out.print(growthMap.length);
    for (int i = l_40; i < growthMap.length; i++) {
        growthDataset.setValue(growthMap[i], "", "" + i);
        if (growthMap[i] < min) {
            min = growthMap[i];//from  w w  w .ja v  a 2 s .  c om
        }
        if (growthMap[i] > max) {
            max = growthMap[i];
        }
    }

    JFreeChart growChart = ChartFactory.createLineChart("Simulated annealing", "", "", growthDataset,
            PlotOrientation.VERTICAL, false, false, false);
    growChart.setBackgroundPaint(Color.WHITE);

    CategoryPlot catPlot = growChart.getCategoryPlot();
    catPlot.setRangeGridlinePaint(new Color(92, 184, 92));

    ValueAxis vAxis = catPlot.getRangeAxis();
    CategoryAxis cAxis = catPlot.getDomainAxis();

    cAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90);
    vAxis.setRange(min, max);

    cAxis.setTickLabelsVisible(false);

    Font font = new Font("SansSerif", Font.PLAIN, 12);
    Font fontTitle = new Font("SansSerif", Font.PLAIN, 14);
    vAxis.setTickLabelFont(font);
    growChart.getTitle().setFont(fontTitle);

    LineAndShapeRenderer renderer = (LineAndShapeRenderer) catPlot.getRenderer();
    Color bootstrapGreen = new Color(92, 184, 92);
    renderer.setSeriesPaint(0, bootstrapGreen);

    ChartPanel chartPanel = new ChartPanel(growChart);
    jPanel6.removeAll();
    jPanel6.add(chartPanel, BorderLayout.CENTER);
    jPanel6.validate();
    //jPanel5.setVisible(true);
}

From source file:hudson.plugins.plot.Plot.java

/**
 * Creates a Chart of the style indicated by getEffStyle() using the given
 * dataset. Defaults to using createLineChart.
 */// ww w  .  j  a v  a  2 s  . co  m
private JFreeChart createChart(PlotCategoryDataset dataset) {
    String s = getUrlStyle();
    if ("area".equalsIgnoreCase(s)) {
        return ChartFactory.createAreaChart(getURLTitle(), /*
                                                            * categoryAxisLabel=
                                                            */null, getYaxis(), dataset,
                PlotOrientation.VERTICAL, hasLegend(), /*
                                                        * tooltips
                                                        * =
                                                        */
                true, /* url= */false);
    }
    if ("bar".equalsIgnoreCase(s)) {
        return ChartFactory.createBarChart(getURLTitle(), /*
                                                           * categoryAxisLabel=
                                                           */null, getYaxis(), dataset,
                PlotOrientation.VERTICAL, hasLegend(), /*
                                                        * tooltips
                                                        * =
                                                        */
                true, /* url= */false);
    }
    if ("bar3d".equalsIgnoreCase(s)) {
        return ChartFactory.createBarChart3D(getURLTitle(), /*
                                                             * categoryAxisLabel
                                                             * =
                                                             */null, getYaxis(), dataset,
                PlotOrientation.VERTICAL, hasLegend(), /*
                                                        * tooltips
                                                        * =
                                                        */
                true, /* url= */false);
    }
    if ("line3d".equalsIgnoreCase(s)) {
        return ChartFactory.createLineChart3D(getURLTitle(), /*
                                                              * categoryAxisLabel
                                                              * =
                                                              */null, getYaxis(), dataset,
                PlotOrientation.VERTICAL, hasLegend(), /*
                                                        * tooltips
                                                        * =
                                                        */
                true, /* url= */false);
    }
    if ("lineSimple".equalsIgnoreCase(s)) {
        return ChartFactory.createLineChart(getURLTitle(), /*categoryAxisLabel=*/null, getYaxis(), dataset,
                PlotOrientation.VERTICAL, hasLegend(), /*tooltips=*/true, /*url=*/false);
    }

    if ("stackedarea".equalsIgnoreCase(s)) {
        return ChartFactory.createStackedAreaChart(getURLTitle(), /*
                                                                   * categoryAxisLabel
                                                                   * =
                                                                   */null, getYaxis(), dataset,
                PlotOrientation.VERTICAL, hasLegend(), /*
                                                        * tooltips
                                                        * =
                                                        */
                true, /* url= */false);
    }
    if ("stackedbar".equalsIgnoreCase(s)) {
        return ChartFactory.createStackedBarChart(getURLTitle(), /*
                                                                  * categoryAxisLabel
                                                                  * =
                                                                  */null, getYaxis(), dataset,
                PlotOrientation.VERTICAL, hasLegend(), /*
                                                        * tooltips
                                                        * =
                                                        */
                true, /* url= */false);
    }
    if ("stackedbar3d".equalsIgnoreCase(s)) {
        return ChartFactory.createStackedBarChart3D(getURLTitle(), /*
                                                                    * categoryAxisLabel
                                                                    * =
                                                                    */null, getYaxis(), dataset,
                PlotOrientation.VERTICAL, hasLegend(), /*
                                                        * tooltips
                                                        * =
                                                        */
                true, /* url= */false);
    }
    if ("waterfall".equalsIgnoreCase(s)) {
        return ChartFactory.createWaterfallChart(getURLTitle(), /*
                                                                 * categoryAxisLabel
                                                                 * =
                                                                 */null, getYaxis(), dataset,
                PlotOrientation.VERTICAL, hasLegend(), /*
                                                        * tooltips
                                                        * =
                                                        */
                true, /* url= */false);
    }
    return ChartFactory.createLineChart(getURLTitle(), /* categoryAxisLabel= */
            null, getYaxis(), dataset, PlotOrientation.VERTICAL, hasLegend(), /* tooltips= */true,
            /* url= */false);
}

From source file:com.softidea.www.private_access.adminstrator.admin_index.java

private void loadChart() {
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    JFreeChart chart = ChartFactory.createLineChart("Income ,Cost ,Profit & Returns", "Details", "Values",
            createDataset(), PlotOrientation.VERTICAL, false, true, false);
    chart.setBackgroundPaint(Color.WHITE);
    CategoryPlot p = chart.getCategoryPlot();
    p.setRangeGridlinePaint(Color.BLUE);
    // ChartFrame frame = new ChartFrame("Full Report", chart);
    ChartPanel panel = new ChartPanel(chart);
    // panel.setSize(jp_loadChart.getWidth(), jp_loadChart.getHeight());
    panel.setPreferredSize(new Dimension(658, 384));
    jp_loadChart.removeAll();//from   w  ww . j a  v  a2 s  . c o  m
    jp_loadChart.setLayout(new FlowLayout());
    jp_loadChart.add(panel);

    panel.setVisible(true);
    jp_loadChart.updateUI();

}

From source file:ds.monte.carlo.Application.java

private void createLengthGraph(HashMap<Integer, Integer> probability) {
    DefaultCategoryDataset pDataset = new DefaultCategoryDataset();

    for (Integer key : probability.keySet()) {
        pDataset.setValue(probability.get(key), "", "" + key);
    }//from w  w  w  .j  a v  a  2  s  . co  m

    JFreeChart growChart = ChartFactory.createLineChart("Simulated annealing", "", "", pDataset,
            PlotOrientation.VERTICAL, false, false, false);
    growChart.setBackgroundPaint(Color.WHITE);

    CategoryPlot catPlot = growChart.getCategoryPlot();
    catPlot.setRangeGridlinePaint(new Color(92, 184, 92));

    ValueAxis vAxis = catPlot.getRangeAxis();
    CategoryAxis cAxis = catPlot.getDomainAxis();

    cAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90);
    cAxis.setTickLabelsVisible(false);

    Font font = new Font("SansSerif", Font.PLAIN, 12);
    Font fontTitle = new Font("SansSerif", Font.PLAIN, 14);
    vAxis.setTickLabelFont(font);
    growChart.getTitle().setFont(fontTitle);

    LineAndShapeRenderer renderer = (LineAndShapeRenderer) catPlot.getRenderer();
    Color bootstrapGreen = new Color(92, 184, 92);
    renderer.setSeriesPaint(0, bootstrapGreen);

    ChartPanel chartPanel = new ChartPanel(growChart);
    jPanel9.removeAll();
    jPanel9.add(chartPanel, BorderLayout.CENTER);
    jPanel9.validate();
}