Example usage for org.jfree.chart ChartPanel ChartPanel

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

Introduction

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

Prototype

public ChartPanel(JFreeChart chart) 

Source Link

Document

Constructs a panel that displays the specified chart.

Usage

From source file:taller.GraficoTorta.java

public GraficoTorta(int posX, int posY, double[] datos, String[] labels, String titulo) {

    super("");
    try {//from  w  w w . j a  v a  2  s. c o m

        DefaultPieDataset defaultpiedataset = new DefaultPieDataset();

        for (int i = 0; i < datos.length; i++)
            defaultpiedataset.setValue(labels[i], datos[i]);

        JFreeChart jfreechart = ChartFactory.createPieChart3D(titulo, defaultpiedataset, true, true, false);
        PiePlot3D pieplot3d = (PiePlot3D) jfreechart.getPlot();
        pieplot3d.setDarkerSides(true);
        pieplot3d.setStartAngle(0D);
        pieplot3d.setDirection(Rotation.CLOCKWISE);
        pieplot3d.setForegroundAlpha(0.75F);
        pieplot3d.setNoDataMessage("No hay Datos que Mostrar");

        jpanel = new ChartPanel(jfreechart);
        jpanel.setPreferredSize(new Dimension(300, 300));
        setContentPane(jpanel);
        pack();
        RefineryUtilities.centerFrameOnScreen(this);
    } catch (Exception e) {
    }
}

From source file:no.met.jtimeseries.ChartFrame.java

public ChartFrame(JFreeChart chart, Dimension size) {
    super("JTimeseries");
    ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(size);//from www .  ja va  2s.  c om
    setContentPane(chartPanel);
    setDefaultCloseOperation(EXIT_ON_CLOSE);
}

From source file:my.demo.BarChart.java

public BarChart(String applicationTitle, String chartTitle, CategoryDataset dataset, JPanel jp) {
    super(applicationTitle);
    JFreeChart barChart = ChartFactory.createBarChart(chartTitle, "Type", "FScore", dataset,
            PlotOrientation.VERTICAL, true, true, false);

    ChartPanel chartPanel = new ChartPanel(barChart);
    chartPanel.setPreferredSize(new java.awt.Dimension(650, 350));

    setContentPane(chartPanel);/*from w  ww  .  ja v  a2 s. c  om*/
    jp.add(chartPanel);

}

From source file:logica.LGraficaAltura.java

public static void logicaBtnGraficar(JRadioButton jRLinea) {

    ChartPanel panel;//  w ww . j a  v  a 2s  .c om
    JFreeChart chart = null;

    if (jRLinea.isSelected()) {
        // ejecuto linea

        XYSplineRenderer graficoLinea = new XYSplineRenderer();

        XYSeriesCollection dataset = new XYSeriesCollection();

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

        XYSeries serie = new XYSeries("Datos");

        XYPlot plot;

        graficoLinea.setSeriesPaint(0, Color.YELLOW);

        VGraficaAltura.getPanelLinea().removeAll();

        for (int i = 0; i < VGraficaAltura.getjTable1().getRowCount(); i++) {

            float valor1 = Float.parseFloat(String.valueOf(VGraficaAltura.getjTable1().getValueAt(i, 0)));
            float valor2 = Float.parseFloat(String.valueOf(VGraficaAltura.getjTable1().getValueAt(i, 1)));

            System.out.println("valores  " + valor1 + "   " + valor2);

            serie.add(valor1, valor2);

        }

        dataset.addSeries(serie);

        x.setLabel("MES");
        y.setLabel("ALTURA");

        plot = new XYPlot(dataset, x, y, graficoLinea);

        NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
        rangeAxis.setRange(15, 30);

        chart = new JFreeChart(plot);
        chart.setTitle("grafico");

        panel = new ChartPanel(chart);
        panel.setBounds(5, 10, 410, 350);

        VGraficaAltura.getPanelLinea().add(panel);
        VGraficaAltura.getPanelLinea().repaint();

    }

}

From source file:Data.Graph.java

public ChartPanel getGraph() {
    this.barChart = makeGraph();
    ChartPanel chartPanel = new ChartPanel(this.barChart);
    return chartPanel;
}

From source file:tp2_poo.Vue_histogramme.java

public Vue_histogramme(Promotion p) {
    prom = p;//w  w  w.j a v  a2s .c o m
    h = new Histogramme(p);
    charts = h.createChart(h.createDataset(p));
    panel = new ChartPanel(charts);

    prom.addObservateur(this);
    this.add(panel);
    this.setPreferredSize(new Dimension(500, 370));
    this.pack();
    this.setVisible(true);
}

From source file:OAT.ui.AbstractChartFrame.java

/**
 * Create a packed chart frame with default size and theme.
 *
 * @param title displayed in the title bar
 * @param jFreeChart  /*from w ww  .  jav  a2 s .  c  om*/
 */
public AbstractChartFrame(String title, JFreeChart jFreeChart) {
    super(title);
    chartPanel = new ChartPanel(jFreeChart);
    initComponent();
}

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

public DualAxisDemo1(String s) {
    super(s);/*from ww  w  . j a  v a  2  s.  co m*/
    JFreeChart jfreechart = createChart();
    ChartPanel chartpanel = new ChartPanel(jfreechart);
    chartpanel.setPreferredSize(new Dimension(500, 270));
    setContentPane(chartpanel);
}

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

/**
 * Constructs a new demonstration application.
 *
 * @param title  the frame title.// ww w .  j  a v  a 2 s  .  c  o  m
 */
public Graph(final String title) {

    super(title);
    this.series = new TimeSeries("Random Data", Millisecond.class);
    final TimeSeriesCollection dataset = new TimeSeriesCollection(this.series);
    final JFreeChart chart = createChart(dataset);

    final ChartPanel chartPanel = new ChartPanel(chart);
    final JButton button = new JButton("Add New Data Item");
    button.setActionCommand("ADD_DATA");
    button.addActionListener(this);

    final JPanel content = new JPanel(new BorderLayout());
    content.add(chartPanel);
    // content.add(button, BorderLayout.SOUTH);
    chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
    setContentPane(content);

}

From source file:PRC6.Graficos.java

public void PieGraphF(ArrayList<Float> d, int pos, String s, String y, javax.swing.JPanel Pan, String p) {
    Pan.removeAll();//w  ww .j a  va2 s . co m
    // Fuente de Datos
    DefaultPieDataset data = new DefaultPieDataset();
    int tmp = 0;
    for (int i = pos; i <= pos + 11; i++) {
        tmp += 1;
        data.setValue("Mes " + tmp + ": " + d.get(i) + " ", d.get(i));
    }

    // Creando el Grafico
    JFreeChart chart = ChartFactory.createPieChart("Grfico de " + s + " para el ao " + y + " en " + p, data,
            true, true, false);

    // Mostrar Grafico
    //ChartFrame frame = new ChartFrame("JFreeChart", chart);
    ChartPanel panel = new ChartPanel(chart);
    panel.setBounds(5, 5, 450, 400);
    panel.repaint();
    Pan.add(panel);
    Pan.updateUI();

    //frame.pack();
    //frame.setVisible(true);

}