Example usage for org.jfree.chart ChartPanel setBounds

List of usage examples for org.jfree.chart ChartPanel setBounds

Introduction

In this page you can find the example usage for org.jfree.chart ChartPanel setBounds.

Prototype

public void setBounds(int x, int y, int width, int height) 

Source Link

Document

Moves and resizes this component.

Usage

From source file:simuladorruleta.Principal.java

private void graficar() {
    ChartPanel panel;
    JFreeChart chart = null;/*from   w  ww .  j a  v a 2s  .c  o  m*/

    /* data.addValue(10, "numeros",""+0);
     data.addValue(30, "numeros",""+1);
     data.addValue(23, "numeros",""+2);*/

    chart = ChartFactory.createBarChart("Repeticiones de los numeros", "Cantidad", "Numero", data);
    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    plot.setDomainGridlinesVisible(true);

    panel = new ChartPanel(chart);
    panel.setBounds(5, 5, 800, 600);

    grafRepe.removeAll();
    grafRepe.add(panel);
    grafRepe.repaint();
    grafRepe.setVisible(true);

}

From source file:Interfaz.VnServidorReportes.java

/**
     * Creates new form VnServidorReportes
     *//* w ww  .  j  a v  a2 s . c  om*/
    public VnServidorReportes(ServidorVentana ventanaPadre) {
        initComponents();
        setLocationRelativeTo(null);
        //cargaListaActividadReciente();
        this.ventanaPadre = ventanaPadre;

        dataset.setValue(9, "Atendidos", "Reporte de Tickets");
        dataset.setValue(10, "Aun EN Atencion", "Reporte de Tickets");
        dataset.setValue(70, "Pendientes", "Reporte de Tickets");
        dataset.setValue(25, "Sin Categorizar", "Reporte de Tickets");

        JFreeChart chart = ChartFactory.createBarChart("", "", "Cantidad", dataset, PlotOrientation.VERTICAL,
                rootPaneCheckingEnabled, rootPaneCheckingEnabled, rootPaneCheckingEnabled);

        ChartPanel chartPanel = new ChartPanel(chart);
        chartPanel.setBounds(0, 0, 250, 170);
        this.pnGraficoNumTikets.add(chartPanel);

    }

From source file:com.ec.vistas.Dashboard.java

/**
 * Creates new form Dashboard/*from   www .  j  a v  a  2 s  .  com*/
 */
public Dashboard() {
    initComponents();
    this.Vivienda.setVisible(false);
    ChartPanel panel;
    JFreeChart chart;
    DefaultPieDataset data = new DefaultPieDataset();
    data.setValue("Categra 1", 43.2);
    data.setValue("Categra 2", 27.9);
    data.setValue("Categra 3", 79.5);
    /*chart=ChartFactory.createPieChart("Grafico1", data, true, true, true);
    panel = new ChartPanel(chart);
    panel.setBounds(5,10,50,60);
    pastel.add(panel);
    pastel.repaint();*/
    chart = ChartFactory.createPieChart("Ejemplo de JFreeChart", //Ttrulo del grfico
            data, true, //Leyenda
            true, //ToolTips
            true);
    panel = new ChartPanel(chart);
    panel.setBounds(5, 10, 50, 60);
    Alimento.add(panel);
    Alimento.repaint();
    //Creamos una especie de frame y mostramos el JFreeChart en l
    //Este constructor nos pide el ttulo del Chart y el chart creado
    //ChartFrame frame=new ChartFrame("Primer Chart para javax0711",chart);
    //frame.pack();
    //frame.setVisible(true);
}

From source file:com.polivoto.vistas.Charts.java

private JPanel hacerPiePanel(Pregunta pregunta, List<Opcion> opciones) {
    JPanel panel = new JPanel(new BorderLayout());
    panel.setBackground(Color.white);
    DefaultPieDataset data = new DefaultPieDataset();
    // Fuente de Datos
    for (Opcion opc : opciones) {
        data.setValue(opc.getNombre(), opc.getCantidad());
    }/*from ww w .  j  a  va  2s .co m*/

    // Creando el Grafico
    JFreeChart chart = ChartFactory.createPieChart("\n" + pregunta.getTitulo(), data, true, false, //TOOLTIPS
            false);
    chart.setBackgroundPaint(Color.white);
    chart.getTitle().setFont(new Font("Roboto", 0, 28));

    // Crear el Panel del Grafico con ChartPanel
    ChartPanel chartPanel = new ChartPanel(chart);
    PiePlot plot = (PiePlot) chart.getPlot();

    Rectangle bounds = panel.getBounds();
    chartPanel.setBounds(bounds.x, bounds.y, bounds.height, bounds.height);

    panel.add(chartPanel);

    plot.setLabelGenerator(null);
    plot.setBackgroundPaint(Color.white);
    plot.setOutlineVisible(false);
    //StandardPieSectionLabelGenerator labels = new StandardPieSectionLabelGenerator("{0} = {1}");
    //plot.setLabelGenerator(labels);

    plot.setBaseSectionOutlinePaint(Color.white);
    plot.setShadowXOffset(0);
    plot.setShadowYOffset(0);

    //#7cb5ec,#f45b5b,#90ed7d,#434348,
    //#f7a35c,#8085e9,#f15c80,#e4d354,
    //#2b908f,#91e8e1
    Color[] colors = { new Color(124, 181, 236), new Color(244, 91, 91), new Color(144, 237, 125),
            new Color(67, 67, 72), new Color(247, 163, 92), new Color(128, 133, 233), new Color(241, 92, 128),
            new Color(228, 211, 84), new Color(43, 144, 143), new Color(145, 232, 225) };
    PieRenderer renderer = new PieRenderer(colors);
    renderer.setColor(plot, data);

    LegendTitle legend = chart.getLegend();
    legend.setPosition(RectangleEdge.RIGHT);
    Font nwfont = new Font("Roboto", 0, 18);
    legend.setItemFont(nwfont);
    legend.setFrame(new BlockBorder(0, 0, 0, 90, Color.white));
    legend.setBackgroundPaint(Color.WHITE);
    legend.setItemLabelPadding(new RectangleInsets(8, 8, 8, 0));
    //RectangleInsets padding = new RectangleInsets(5, 5, 5, 5);
    //legend.setItemLabelPadding(padding);
    plot.setLegendLabelGenerator(new StandardPieSectionLabelGenerator("{1} {0}"));
    plot.setLegendItemShape(new Rectangle(25, 25));
    return panel;
}

From source file:Vista.frm_venta_diaria_informe.java

private void graficarDatos() {
    ChartPanel panel;
    DefaultCategoryDataset data = new DefaultCategoryDataset();
    String[] dias = venta_diaria.getFecha();
    float[] total = venta_diaria.getTotalVenta();
    int fila = 0;
    for (int i = 0; i < venta_diaria.getFecha().length; i++) {
        if (dias[i].equalsIgnoreCase("")) {
        } else {//from  w ww.j  ava2s . c  o m
            fila++;
        }
    }
    for (int i = 0; i < fila; i++) {
        if (total[i] == 0) {
        } else {
            data.addValue(total[i], "", dias[i]);
        }
    }
    JFreeChart chart = null;
    chart = ChartFactory.createBarChart("VENTA DIARIA", "VENTAS", "CANTIDAD", data, PlotOrientation.VERTICAL,
            true, true, true);
    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    plot.setDomainGridlinesVisible(true);
    panel = new ChartPanel(chart);
    panel.setBounds(0, 30, 450, 450);
    pan_derecha.add(panel);
}

From source file:Vista.frm_venta_mensual_informe.java

private void graficarDatos() {
    ChartPanel panel;
    DefaultCategoryDataset data = new DefaultCategoryDataset();
    String[] dias = venta_diaria.getFecha();
    float[] total = venta_diaria.getTotalVenta();
    int fila = 0;
    for (int i = 0; i < venta_diaria.getFecha().length; i++) {
        if (dias[i].equalsIgnoreCase("")) {
        } else {//  w  w w .  ja va2s.c om
            fila++;
        }
    }
    for (int i = 0; i < fila; i++) {
        if (total[i] == 0) {
        } else {
            data.addValue(total[i], "", dias[i]);
        }
    }
    JFreeChart chart = null;
    chart = ChartFactory.createBarChart("VENTA MENSUAL", "VENTAS", "CANTIDAD", data, PlotOrientation.VERTICAL,
            true, true, true);
    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    plot.setDomainGridlinesVisible(true);
    panel = new ChartPanel(chart);
    panel.setBounds(0, 30, 450, 450);
    pan_derecha.add(panel);
}

From source file:GUI.VentanaPrincipal.java

void graficaBarras() {
    barras.setVisible(true);/*from  w w w. j a va  2  s.c  o m*/
    Capas1.setLayer(barras, 0, 0);
    ChartPanel panel;
    JFreeChart chart = null;
    //grafico de barras
    DefaultCategoryDataset data = new DefaultCategoryDataset();
    String Producto1 = "Sopas";
    String Producto2 = "Soda";
    String Dia1 = "Da 1";
    String Dia2 = "Da 2";
    String Dia3 = "Da 3";
    String Dia4 = "Da 4";

    data.addValue(18, Producto1, Dia1);
    data.addValue(15, Producto1, Dia2);
    data.addValue(14, Producto1, Dia3);
    data.addValue(11, Producto1, Dia4);

    data.addValue(50, Producto2, Dia1);
    data.addValue(45, Producto2, Dia2);
    data.addValue(31, Producto2, Dia3);
    data.addValue(10, Producto2, Dia4);

    chart = ChartFactory.createBarChart("Grfico de Barras", "Da", "Cantidad", data,
            PlotOrientation.HORIZONTAL, true, true, true);
    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    plot.setDomainGridlinesVisible(true);

    panel = new ChartPanel(chart);
    panel.setBounds(5, 10, 410, 400);
    //grfico de barras
    barras.add(panel);
    barras.repaint();

}

From source file:Interfaz.adminZone.java

private void graficar() {
    ChartPanel panel;
    JFreeChart chart = null;//from ww  w  .  ja  v  a  2  s . c  o  m
    int validar = 1;
    XYSplineRenderer renderer = new XYSplineRenderer();
    XYSeriesCollection dataset = new XYSeriesCollection();

    ValueAxis x = new NumberAxis();
    ValueAxis y = new NumberAxis();

    XYSeries serie = new XYSeries("Ventas");

    XYPlot plot;

    lineas.removeAll();

    try {
        for (int fila = 0; fila < this.modeloVentasMes.getRowCount(); fila++) {
            serie.add(Float.parseFloat(String.valueOf(this.modeloVentasMes.getValueAt(fila, 0))),
                    Float.parseFloat(String.valueOf(modeloVentasMes.getValueAt(fila, 1))));

        }
    } catch (Exception es) {
        validar = 0;
    }
    if (validar == 1) {
        dataset.addSeries(serie);

        x.setLabel("Mes");
        y.setLabel("Ventas");
        plot = new XYPlot(dataset, x, y, renderer);
        chart = new JFreeChart(plot);
        chart.setTitle("Cambio en las Ventas 2016");
    }
    panel = new ChartPanel(chart);
    panel.setBounds(5, 10, 229, 219);

    lineas.add(panel);
    lineas.repaint();

}

From source file:co.edu.eam.ingesoft.egresados.vista.gui.VentanaOfertasAbiertas.java

private void cbAreaItemStateChanged(java.awt.event.ItemEvent evt) {// GEN-FIRST:event_cbAreaItemStateChanged
    // TODO add your handling code here:
    ChartPanel panel;
    try {// w w  w. j  a v a  2 s. com
        Programa programa = (Programa) cbPrograma.getSelectedItem();

        List<OfertaLaboral> listaOfertaLab = controlador.listarOfertas(programa);

        int contador = 0;
        AreaInteres areaAnterior = null;
        DefaultCategoryDataset ds = new DefaultCategoryDataset();

        for (int i = 0; i < listaOfertaLab.size(); i++) {
            jPPrimero.removeAll();
            // Validacion de oferta
            if (listaOfertaLab.get(i).isCerrarOferta() == false) {
                areaAnterior = listaOfertaLab.get(i).getAreaInteres();
                for (int j = 0; j < listaOfertaLab.size(); j++) {
                    if (listaOfertaLab.get(j).getAreaInteres() == areaAnterior) {
                        contador++;
                    }
                }
                ds.addValue(contador, listaOfertaLab.get(i).getDescripcion(),
                        listaOfertaLab.get(i).getDescripcion());
                contador = 0;
            }
        }

        JFreeChart jf = ChartFactory.createBarChart3D("Reporte de ofertas abiertas", "Nombre de las ofertas",
                "Numero de vacantes", ds, PlotOrientation.VERTICAL, true, true, true);

        panel = new ChartPanel(jf);
        panel.setBounds(20, 20, 230, 230);

        jPPrimero.add(panel);

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

From source file:co.edu.eam.ingesoft.egresados.vista.gui.VentanaOfertasAbiertas.java

/**
 * Grafica de barras//from  w w w  . j a  v  a  2s .c o m
 * 
 * @param evt
 */
private void cbProgramaItemStateChanged(java.awt.event.ItemEvent evt) {// GEN-FIRST:event_cbProgramaItemStateChanged
    // TODO add your handling code here:

    ChartPanel panel;
    try {
        Programa programa = (Programa) cbPrograma.getSelectedItem();

        List<OfertaLaboral> listaOfertaLab = controlador.listarOfertas(programa);

        int contador = 0;
        AreaInteres areaAnterior = null;
        DefaultCategoryDataset ds = new DefaultCategoryDataset();

        for (int i = 0; i < listaOfertaLab.size(); i++) {
            jPSegundo.removeAll();
            // Validacion de oferta
            if (listaOfertaLab.get(i).isCerrarOferta() == false) {
                areaAnterior = listaOfertaLab.get(i).getAreaInteres();
                for (int j = 0; j < listaOfertaLab.size(); j++) {
                    if (listaOfertaLab.get(j).getAreaInteres() == areaAnterior) {
                        contador++;
                    }
                }
                ds.addValue(contador, listaOfertaLab.get(i).getDescripcion(),
                        listaOfertaLab.get(i).getDescripcion());
                contador = 0;
            }
        }

        JFreeChart jf = ChartFactory.createBarChart3D("Reporte de ofertas abiertas", "Nombre de las ofertas",
                "Numero de vacantes", ds, PlotOrientation.VERTICAL, true, true, true);

        panel = new ChartPanel(jf);
        panel.setBounds(20, 20, 230, 230);

        jPSegundo.add(panel);

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

}