Grafico em barras

3 respostas
A

OI GALERA;

TO PRECISANDO URGENTE DE ALGUM MODELO DE CODIGO PARA GRAFICOS JSP EM BARRAS (JFREE.CHAR).
ALGUÉM PODERIA ME ARRUMAR?
VALEEEU!!

3 Respostas

C

No site do JFreeChart nao tem um kra desses ai nao ?

M
package org.jfree.chart.demo;

import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.CategoryPlot;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.data.CategoryDataset;
import org.jfree.data.DefaultCategoryDataset;
import org.jfree.ui.ApplicationFrame;
import org.jfree.ui.RefineryUtilities;

/**
 * A simple demonstration application showing how to create a horizontal 3D bar chart using data
 * from a {@link CategoryDataset}.
 *
 * @author David Gilbert
 */
public class BarChart3DDemo2 extends ApplicationFrame {

    /**
     * Creates a new demo.
     *
     * @param title  the frame title.
     */
    public BarChart3DDemo2(String title) {

        super(title);
        // create the chart...
        DefaultCategoryDataset dataset = new DefaultCategoryDataset();
        dataset.addValue(23.0, "Series 1", "Group 1");
        dataset.addValue(14.0, "Series 1", "Group 2");
        dataset.addValue(13.0, "Series 2", "Group 1");
        dataset.addValue(19.0, "Series 2", "Group 2");
        dataset.addValue(7.0, "Series 3", "Group 1");
        dataset.addValue(9.0, "Series 3", "Group 2");
        
        JFreeChart chart = createChart(dataset);

        // add the chart to a panel...
        ChartPanel chartPanel = new ChartPanel(chart);
        chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
        setContentPane(chartPanel);

    }

    /**
     * Creates a chart.
     * 
     * @param dataset  the dataset.
     * 
     * @return The chart.
     */
    private JFreeChart createChart(CategoryDataset dataset) {
        JFreeChart chart = ChartFactory.createBarChart3D(
            "3D Bar Chart Demo 2",       // chart title
            "Category",                  // domain axis label
            "Value",                     // range axis label
            dataset,                     // data
            PlotOrientation.HORIZONTAL,  // orientation
            true,                        // include legend
            true,                        // tooltips
            false                        // urls
        );

        CategoryPlot plot = chart.getCategoryPlot();
        plot.setForegroundAlpha(1.0f);

        return chart;        
    }
        
}
A

Mas ainda estou com duvida. De que maneira insiro esse grafico dentro de uma aplicação web?
O HTML apenas? Como faço?

Obrigado pela força.

Criado 27 de maio de 2007
Ultima resposta 29 de mai. de 2007
Respostas 3
Participantes 3