Example usage for org.jfree.chart ChartFactory createPieChart3D

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

Introduction

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

Prototype

public static JFreeChart createPieChart3D(String title, PieDataset dataset, boolean legend, boolean tooltips,
        boolean urls) 

Source Link

Document

Creates a 3D pie chart using the specified dataset.

Usage

From source file:cz.zcu.kiv.eegdatabase.logic.controller.history.GraphController.java

protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response)
        throws Exception {
    log.debug("Processing creating pie graph");
    String graphType = "";

    List<DownloadStatistic> topDownloadedFilesList = null;
    boolean isGroupAdmin;
    long countFile = 0;

    graphType = request.getParameter("graphType");
    int groupId = Integer.parseInt(request.getParameter("groupId"));
    isGroupAdmin = auth.userIsGroupAdmin();
    response.setContentType("image/png");

    topDownloadedFilesList = historyDao.getTopDownloadHistory(ChoiceHistory.valueOf(graphType), isGroupAdmin,
            groupId);/*  w  ww. j  a v a2s . co m*/

    DefaultPieDataset dataset = new DefaultPieDataset();
    if (groupId != -1) {
        for (int i = 0; i < topDownloadedFilesList.size(); i++) {
            dataset.setValue(topDownloadedFilesList.get(i).getFileName(),
                    new Long(topDownloadedFilesList.get(i).getCount()));
            countFile = countFile + topDownloadedFilesList.get(i).getCount();
        }

        if (historyDao.getCountOfFilesHistory(ChoiceHistory.valueOf(graphType), isGroupAdmin,
                groupId) > countFile) {
            dataset.setValue("Other",
                    historyDao.getCountOfFilesHistory(ChoiceHistory.valueOf(graphType), isGroupAdmin, groupId)
                            - countFile);
        }
    }
    JFreeChart chart = ChartFactory.createPieChart3D("Daily downloads", // chart title
            dataset, // data
            true, // include legend
            true, false);

    PiePlot3D plot = (PiePlot3D) chart.getPlot();
    plot.setStartAngle(290);
    plot.setDirection(Rotation.CLOCKWISE);
    plot.setForegroundAlpha(0.5f);
    plot.setNoDataMessage("No data to display");

    ChartUtilities.writeChartAsPNG(response.getOutputStream(), chart, 600, 400);
    response.getOutputStream().close();
    return null;
}

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

/**
 * Creates a sample chart.//w  w w.  jav a 2 s  .com
 * 
 * @param dataset  the dataset.
 * 
 * @return A chart.
 */
private JFreeChart createChart(final PieDataset dataset) {

    final JFreeChart chart = ChartFactory.createPieChart3D("Pie Chart 3D Demo 4", // chart title
            dataset, // data
            true, // include legend
            true, false);

    final PiePlot3D plot = (PiePlot3D) chart.getPlot();
    plot.setStartAngle(290);
    plot.setDirection(Rotation.CLOCKWISE);
    plot.setForegroundAlpha(0.5f);
    plot.setNoDataMessage("No data to display");
    plot.setLabelGenerator(new CustomLabelGenerator());
    return chart;

}

From source file:id.aas.apps.mvc.view.chartFrame.java

void pie() {
    try {//from www .j  ava 2s .  co  m
        int nilaiKiloan = 0;
        int nilaiSatuan = 0;
        //create pie chart
        String queryKiloan = "SELECT COUNT(*) FROM laundry WHERE jenis_layanan='Laundry Kiloan'";
        String querySatuan = "SELECT COUNT(*) FROM laundry WHERE jenis_layanan='Laundry Satuan'";
        ConnectionDB.InstanceDB.openConnection();
        ResultSet rs = ConnectionDB.InstanceDB.RunSelectQuery(queryKiloan);
        while (rs.next()) {
            nilaiKiloan = rs.getInt(1);
        }
        System.out.println(nilaiKiloan);

        ResultSet rs1 = ConnectionDB.InstanceDB.RunSelectQuery(querySatuan);
        while (rs1.next()) {
            nilaiSatuan = rs1.getInt(1);
        }
        System.out.println(nilaiSatuan);
        DefaultPieDataset pieDataset = new DefaultPieDataset();
        pieDataset.setValue("Laundry Kiloan", nilaiKiloan);
        pieDataset.setValue("Laundry Satuan", nilaiSatuan);

        JFreeChart chart = ChartFactory.createPieChart3D("Perbandingan Pengguna Layanan Laundry", pieDataset,
                true, true, false);

        chart.setBorderVisible(false);
        chart.setBackgroundPaint(null);

        ChartPanel cPanel = new ChartPanel(chart);
        setBounds(100, 100, 685, 429);
        jPanel1 = new JPanel();
        jPanel1.setBorder(new EmptyBorder(5, 5, 5, 5));
        setContentPane(jPanel1);
        jPanel1.setLayout(null);
        jPanel1.add(cPanel);
        jTabbedPane1.add(jPanel1);
        setVisible(true);

        //            BufferedImage image3 = chart.createBufferedImage(500, 300);
        //            jLabel2.setIcon(new ImageIcon(image3));
        //            jLabel2.setLocation(20, 20);
    } catch (Exception e) {
        System.out.println(e.getMessage());
    }

}

From source file:org.getobjects.samples.HelloChart.Main.java

/**
 * This defines the direct action which can be invoked using:<pre>
 *   /HelloThumbnail/wa/Main/chart?chs=128x128&chartType=p3</pre>
 * //from ww w  .j ava 2  s  . c om
 * <p>
 * Note that the method returns a java.awt.BufferedImage. This will get
 * rendered to a GIF image by the GoDefaultRenderer.
 * (this method does not return a WOResponse, but it lets the Go machinery
 * deal with the image result object). 
 * 
 * @return a BufferedImage containing the scaled image
 */
public Object chartAction() {
    Dimension size = UGoogleChart.getDimensions(F("chs", "128x128"), null);
    String chartType = (String) F("cht", "p");

    JFreeChart chart = null;
    if (chartType.equals("p")) {
        chart = ChartFactory.createPieChart((String) F("title", "Revenue Chart" /* default title */),
                this.getPieDataset(), UObject.boolValue(F("legend", true)) /* show legend */,
                UObject.boolValue(F("tooltips", true)) /* show tooltips */, false /* no URLs */);
    } else if (chartType.equals("p3")) {
        chart = ChartFactory.createPieChart3D((String) F("title", "Revenue Chart" /* default title */),
                this.getPieDataset(), UObject.boolValue(F("legend", true)) /* show legend */,
                UObject.boolValue(F("tooltips", true)) /* show tooltips */, false /* no URLs */);
    } else if (chartType.startsWith("b")) {
        // bhs, bvs (one bar with multiple values)
        // bhg, bvg (one bar for each row)

        PlotOrientation orientation = PlotOrientation.VERTICAL;
        if (chartType.startsWith("bh"))
            orientation = PlotOrientation.HORIZONTAL;

        if (chartType.endsWith("3")) {
            chart = ChartFactory.createBarChart3D((String) F("title", "Revenue Chart" /* default title */),
                    (String) F("xlabel", "X-Axis"), (String) F("ylabel", "Y-Axis"), getCatDataSet(),
                    orientation, UObject.boolValue(F("legend", true)) /* show legend */,
                    UObject.boolValue(F("tooltips", true)) /* show tooltips */, false /* no URLs */);
        } else {
            chart = ChartFactory.createBarChart((String) F("title", "Revenue Chart" /* default title */),
                    (String) F("xlabel", "X-Axis"), (String) F("ylabel", "Y-Axis"), getRevCatDataSet(),
                    orientation, UObject.boolValue(F("legend", true)) /* show legend */,
                    UObject.boolValue(F("tooltips", true)) /* show tooltips */, false /* no URLs */);
        }
    }

    /* style the chart */

    chart.setBorderVisible(true);
    //chart.setBorderPaint(new Paint(Color.blue));

    Paint p = new GradientPaint(0, 0, Color.white, 1000, 0, Color.blue);
    chart.setBackgroundPaint(p);

    /* style the plot */

    Plot plot = chart.getPlot();
    plot.setBackgroundPaint(new Color(240, 240, 250));

    /* add explosion for Pies */

    if (plot instanceof PiePlot) {
        PiePlot pplot = (PiePlot) chart.getPlot();
        pplot.setExplodePercent("Products", 0.30); // can be multiple explodes
    }

    /* create the image for HTTP delivery */

    return chart.createBufferedImage(size.width, size.height);
}

From source file:WeeklyReport.Sections.Commodities.java

private JFreeChart commodityChart() {
    DefaultPieDataset dataset = new DefaultPieDataset();
    Map<Double, String> mp = new CargoTypeData().quotesByCommodityCBM();
    mp.entrySet().stream().forEach((mapEntry) -> {
        dataset.setValue(mapEntry.getValue(), mapEntry.getKey());
    });/*from  w ww  .  j  a v a 2  s.  c  o m*/
    JFreeChart pieChart = ChartFactory.createPieChart3D("Commodities Quoted by Cubic Meter", dataset, true,
            true, false);

    PiePlot plot = (PiePlot) pieChart.getPlot();
    plot.setBackgroundPaint(Color.WHITE);

    PieSectionLabelGenerator gen = new StandardPieSectionLabelGenerator("{0}: {1} cbm ({2})",
            new DecimalFormat("0.000"), new DecimalFormat("0%"));
    plot.setLabelGenerator(gen);

    return pieChart;
}

From source file:it.eng.spagobi.engines.chart.bo.charttypes.piecharts.SimplePie.java

public JFreeChart createChart(DatasetMap datasets) {

    Dataset dataset = (Dataset) datasets.getDatasets().get("1");

    JFreeChart chart = null;//from w w  w .  ja va 2 s. c o m

    if (!threeD) {
        chart = ChartFactory.createPieChart(name, (PieDataset) dataset, // data
                legend, // include legend
                true, false);

        chart.setBackgroundPaint(color);

        TextTitle title = chart.getTitle();
        title.setToolTipText("A title tooltip!");

        PiePlot plot = (PiePlot) chart.getPlot();
        plot.setLabelFont(new Font(defaultLabelsStyle.getFontName(), Font.PLAIN, defaultLabelsStyle.getSize()));
        plot.setCircular(false);
        plot.setLabelGap(0.02);
        plot.setNoDataMessage("No data available");

        if (percentage == false) {
            plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0} ({1})"));
        } else {
            plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0} ({2})"));
        }

    } else {
        chart = ChartFactory.createPieChart3D(name, (PieDataset) dataset, // data
                true, // include legend
                true, false);

        chart.setBackgroundPaint(color);

        TextTitle title = chart.getTitle();
        title.setToolTipText("A title tooltip!");

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

        plot.setDarkerSides(true);
        plot.setStartAngle(290);
        plot.setDirection(Rotation.CLOCKWISE);
        plot.setForegroundAlpha(1.0f);
        plot.setDepthFactor(0.2);

        plot.setLabelFont(new Font(defaultLabelsStyle.getFontName(), Font.PLAIN, defaultLabelsStyle.getSize()));
        // plot.setNoDataMessages("No data available");
        plot.setCircular(false);
        plot.setLabelGap(0.02);
        plot.setNoDataMessage("No data available");

        if (percentage == false) {
            plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0} ({1})"));
        } else {
            plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0} ({2})"));
        }
    }

    TextTitle title = setStyleTitle(name, styleTitle);
    chart.setTitle(title);
    if (subName != null && !subName.equals("")) {
        TextTitle subTitle = setStyleTitle(subName, styleSubTitle);
        chart.addSubtitle(subTitle);
    }

    return chart;

}

From source file:GUILayer.CustomerStatsByGroup.java

private JFreeChart createChart(PieDataset dataset, String title) {
    JFreeChart chart = ChartFactory.createPieChart3D(title, dataset, true, true, true);
    PiePlot3D plot = (PiePlot3D) chart.getPlot();
    plot.setForegroundAlpha(0.5f);//from w ww. ja v  a 2s  .com
    return chart;
}

From source file:aplicacion.gestion.tablero.logic.PieChart3DDemo1.java

/**
 * Creates a sample chart.// w ww.  j a  v a  2  s . c o  m
 * 
 * @param dataset  the dataset.
 * 
 * @return A chart.
 */
private JFreeChart createChart(final PieDataset dataset) {

    final JFreeChart chart = ChartFactory.createPieChart3D("Pie Chart 3D Demo 1", // chart title
            dataset, // data
            true, // include legend
            true, false);

    final PiePlot3D plot = (PiePlot3D) chart.getPlot();
    plot.setStartAngle(290);
    plot.setDirection(Rotation.CLOCKWISE);
    plot.setForegroundAlpha(0.5f);
    plot.setNoDataMessage("No data to display");
    return chart;

}

From source file:Connexion.ChartDocteur.java

public ChartDocteur() {

    try {/*from w ww. j  av  a  2s.c om*/
        Class.forName("com.mysql.jdbc.Driver");
    } catch (ClassNotFoundException e) {
        /* Grer les ventuelles erreurs ici. */
    }
    int a = 0;
    int b = 0;
    int c = 0;
    int d = 0;
    int f = 0;
    int g = 0;
    try {
        ResultSet resultat1 = this.connect
                .createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE)
                .executeQuery("SELECT specialite FROM docteur WHERE specialite =  'Cardiologue'");
        // on rcupre le nombre de lignes de la requte
        if (resultat1.last()) {
            a = resultat1.getRow();
        }
        System.out.println(a);

    } catch (SQLException e) {
        e.printStackTrace();
    }
    try {
        ResultSet resultat2 = this.connect
                .createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE)
                .executeQuery("SELECT specialite FROM docteur WHERE specialite =  'Traumatologue'");
        // on rcupre le nombre de lignes de la requte
        if (resultat2.last()) {
            b = resultat2.getRow();
        }
        System.out.println(b);

    } catch (SQLException e) {
        e.printStackTrace();
    }
    try {

        ResultSet resultat3 = this.connect
                .createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE)
                .executeQuery("SELECT specialite FROM docteur WHERE specialite =  'Pneumologue'");
        // on rcupre le nombre de lignes de la requte
        if (resultat3.last()) {
            c = resultat3.getRow();
        }
        System.out.println(c);

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

    try {

        ResultSet resultat4 = this.connect
                .createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE)
                .executeQuery("SELECT specialite FROM docteur WHERE specialite =  'Orthopediste'");
        // on rcupre le nombre de lignes de la requte
        if (resultat4.last()) {
            d = resultat4.getRow();
        }
        System.out.println(d);

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

    try {

        ResultSet resultat5 = this.connect
                .createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE)
                .executeQuery("SELECT specialite FROM docteur WHERE specialite =  'Radiologue'");
        // on rcupre le nombre de lignes de la requte
        if (resultat5.last()) {
            f = resultat5.getRow();
        }
        System.out.println(f);

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

    try {

        ResultSet resultat6 = this.connect
                .createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE)
                .executeQuery("SELECT specialite FROM docteur WHERE specialite =  'Anesthesiste'");
        // on rcupre le nombre de lignes de la requte
        if (resultat6.last()) {
            g = resultat6.getRow();
        }
        System.out.println(g);

    } catch (SQLException e) {
        e.printStackTrace();
    }
    DefaultPieDataset union = new DefaultPieDataset();

    //remplir l'ensemble

    union.setValue("Cardiologue", a);
    union.setValue("Traumatologue", b);
    union.setValue("Pneumologue", c);
    union.setValue("Orthopediste", d);
    union.setValue("Radiologue", f);
    union.setValue("Anesthesiste", g);

    JFreeChart repart = ChartFactory.createPieChart3D("Nombre de mdecin par spcialit", union, true, true,
            false);
    ChartPanel crepart = new ChartPanel(repart);
    this.add(crepart);
    this.pack();
    this.setVisible(true);
}

From source file:org.adempiere.apps.graph.GraphBuilder.java

private JFreeChart createPieChart() {
    final JFreeChart chart = ChartFactory.createPieChart3D(m_goal.getMeasure().getName(), pieDataset, false,
            true, true);/*from www.  j  a  v  a2 s.  c o m*/

    return chart;
}