Example usage for org.jfree.chart ChartFrame ChartFrame

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

Introduction

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

Prototype

public ChartFrame(String title, JFreeChart chart) 

Source Link

Document

Constructs a frame for a chart.

Usage

From source file:server.ServerUI.java

void displayUsersStatusChart(int availableNum, int busyNum, int awayNum, int offlineNum) {
    DefaultPieDataset pieDataset = new DefaultPieDataset();
    pieDataset.setValue("Avaliable", new Integer(availableNum));
    pieDataset.setValue("Away", new Integer(awayNum));
    pieDataset.setValue("Busy", new Integer(busyNum));
    pieDataset.setValue("Offline", new Integer(offlineNum));
    JFreeChart chart = ChartFactory.createPieChart("Users Statistics", pieDataset, true, true, true);
    PiePlot p;/*  w  ww.  ja  va 2  s  .c  o m*/
    p = (PiePlot) chart.getPlot();
    ChartFrame chartPanelObj = new ChartFrame("USERS", chart);
    chartPanelObj.setVisible(true);
    chartPanelObj.setSize(450, 500);
}

From source file:br.unicamp.cst.behavior.bn.support.Grafico.java

public Grafico(String frametitle, String charttitle, String xlabel, String ylabel, XYSeriesCollection dataset) {
    JFreeChart chart = ChartFactory.createXYLineChart(charttitle, xlabel, ylabel, dataset,
            PlotOrientation.VERTICAL, true, true, false);

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

    plot.setBackgroundPaint(Color.lightGray);
    plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);
    XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer();
    renderer.setShapesVisible(true);// w  w w .  ja  va2s  .  com
    renderer.setShapesFilled(true);

    setXyplot(plot);
    setChart(chart);

    ChartFrame frame = new ChartFrame(frametitle, chart);

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

From source file:dumbara.view.Chart1.java

public static void byIncome() {
    DefaultCategoryDataset objDataset = new DefaultCategoryDataset();
    try {/*  w w  w.  ja  v a 2 s  .c o  m*/
        Sale[] sale = SalesController.viewAllSales();
        for (Sale sale1 : sale) {
            objDataset.setValue(sale1.getIncome(), "Sales Progress", sale1.getSalesID());
        }
    } catch (ClassNotFoundException | SQLException ex) {
        Logger.getLogger(Chart1.class.getName()).log(Level.SEVERE, null, ex);
    }
    Calendar cal = Calendar.getInstance();
    cal.add(Calendar.MONTH, -1);
    Date result = cal.getTime();
    SimpleDateFormat simpleDateFormat = new SimpleDateFormat("E yyyy.MM.dd");
    String format = simpleDateFormat.format(result);
    Date date = new Date();
    String format1 = simpleDateFormat.format(date);

    JFreeChart objChart = ChartFactory.createBarChart(
            "Sales Comparisson by Sales ID from " + format + " to " + format1, "Sales ID", "Sales Income",
            objDataset, PlotOrientation.VERTICAL, true, true, false

    );
    ChartFrame frame = new ChartFrame("Data Analysis Wizard - v2.1.4", objChart);
    frame.pack();
    frame.setSize(1300, 600);
    frame.setVisible(true);
    frame.setLocationRelativeTo(null);
}

From source file:graficar.Graficar.java

public void dibujaGrafica() {
    construirGrafica();
    frame = new ChartFrame(nombreFrame, chart);
    frame.pack();
    frame.setVisible(true);
}

From source file:br.unicamp.cst.motivational.MotivationalMonitor.java

@Override
public synchronized void run() {

    DefaultCategoryDataset dataset = new DefaultCategoryDataset();

    final JFreeChart chart = ChartFactory.createBarChart(getTitle(), getEntity(), "Value", dataset,
            PlotOrientation.VERTICAL, true, true, false);

    final CategoryPlot plot = chart.getCategoryPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);
    chart.setBackgroundPaint(Color.lightGray);

    ChartFrame frame = new ChartFrame(getTitle(), chart);
    frame.pack();/*ww w.j  av  a 2s. c o  m*/
    frame.setVisible(true);

    while (true) {
        ArrayList<Codelet> tempCodeletsList = new ArrayList<Codelet>();
        tempCodeletsList.addAll(this.getListOfMotivationalEntities());

        synchronized (tempCodeletsList) {

            for (Codelet co : tempCodeletsList) {
                dataset.addValue(co.getActivation(), co.getName(), "activation");
            }
            try {
                Thread.currentThread().sleep(getRefreshPeriod());
            } catch (InterruptedException e) {
                e.printStackTrace();
            }

        }
    }
}

From source file:lectorarchivos.MostrarGraficaCSV.java

/**
 * Creates new form MostrarGraficaCSV// w w w  . jav  a2  s. co m
 */
public MostrarGraficaCSV(JTable jTableInfoCSV) {
    initComponents();
    this.setDefaultCloseOperation(DISPOSE_ON_CLOSE);

    panel = new JPanel();
    getContentPane().add(panel);

    //Fuente de datos
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();

    //Recorremos la columna del consumo de la tabla
    for (int i = jTableInfoCSV.getRowCount() - 1; i >= 0; i--) {
        if (Double.parseDouble(jTableInfoCSV.getValueAt(i, 4).toString()) > 0)
            dataset.setValue(Double.parseDouble(jTableInfoCSV.getValueAt(i, 4).toString()), "Consumo",
                    jTableInfoCSV.getValueAt(i, 0).toString());
    }

    //Creando el grfico
    JFreeChart chart = ChartFactory.createBarChart3D("Consumo", "Fecha", "Consumo", dataset,
            PlotOrientation.VERTICAL, true, true, false);
    chart.setBackgroundPaint(Color.cyan);
    chart.getTitle().setPaint(Color.black);
    chart.setBackgroundPaint(Color.white);
    chart.removeLegend();

    //Cambiar color de barras
    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    BarRenderer barRenderer = (BarRenderer) plot.getRenderer();
    barRenderer.setSeriesPaint(0, Color.decode("#5882FA"));

    // Mostrar Grafico
    ChartFrame frame = new ChartFrame("CONSUMO", chart);
    frame.pack();
    frame.getChartPanel().setMouseZoomable(false);
    frame.setVisible(true);

    panel.add(frame);

}

From source file:br.fapesp.myutils.TestMyUtils.java

@Test
@Ignore//  w ww .java2  s  .  co m
public void testJFreeChart() {
    double[][] data = new double[][] { { 1, 2 }, { 3, 4 }, { 5, 6 } };
    XYSeries xy = new XYSeries("Teste");
    xy.add(1, 2);
    xy.add(2, 4);
    xy.add(3, 6);

    XYSeriesCollection dataset = new XYSeriesCollection();
    dataset.addSeries(xy);

    JFreeChart chart = ChartFactory.createScatterPlot("Scatter teste", "x", "y", dataset);

    ChartFrame frame = new ChartFrame("XYLine Chart", chart);
    frame.pack();
    frame.setVisible(true);
}

From source file:com.hello2morrow.sonargraph.jenkinsplugin.controller.util.ChartTestUtil.java

private void createChart(AbstractPlot plot, SonargraphMetrics metric, int maxDataPoints, boolean hideLegend) {
    JFreeChart chart = plot.createXYChart(metric, BUILD, maxDataPoints, true);
    ChartFrame frame1 = new ChartFrame(metric.getShortDescription(), chart);
    frame1.setVisible(true);//from   ww w.  j av  a2  s  .  com
    frame1.setSize(500, 350);
}

From source file:prc2.Graficos.java

public void PieGraphI(ArrayList<Integer> d, int pos, String s, String y) {
    //System.out.println("Estoy EN PIEGRAPH");
    // Fuente de Datos
    DefaultPieDataset data = new DefaultPieDataset();
    int tmp = 0;//from ww w  .  j  a va2  s.  c  o m
    for (int i = pos; i <= pos + 11; i++) {
        tmp += 1;
        data.setValue("Mes " + tmp + ": " + d.get(i) + " ", d.get(i));

        //data.setValue(d.get(pos), 45);
        //data.setValue("Python", 15);
    }

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

    // Mostrar Grafico
    ChartFrame frame = new ChartFrame("JFreeChart", chart);

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

From source file:jmbench.plots.SummaryWhiskerPlot.java

public void displayWindow(int width, int height) {

    JFreeChart chart = createChart();/*w ww  .j a va 2  s  . c  o m*/

    ChartFrame window = new ChartFrame(chart.getTitle().getText(), chart);

    window.setMinimumSize(new Dimension(width, height));
    window.setPreferredSize(window.getMinimumSize());
    window.setVisible(true);
}