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:com.ouc.cpss.view.EmpSaleChartBuilder.java

public static JPanel createPanel() {
    // ?JFreeChart(????)
    JFreeChart chart = createJFreeChart(createDataSet());
    // JFreeChar?JPanel
    return new ChartPanel(chart);
}

From source file:controller.DrawCurve.java

private JPanel createChart() {
    String chartTitle = "Camera Response Curve";
    String xAxisLabel = "log Exposure G(Z)";
    String yAxisLabel = "Intensity pixel Z";

    XYDataset dataset = createDataset();

    JFreeChart chart = ChartFactory.createXYLineChart(chartTitle, xAxisLabel, yAxisLabel, dataset);

    //Set custom color and thickness for line curve
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(true, false);

    // sets paint color for each series
    renderer.setSeriesPaint(0, Color.RED);
    renderer.setSeriesPaint(1, Color.GREEN);
    renderer.setSeriesPaint(2, Color.BLUE);

    // sets thickness for series (using strokes)
    renderer.setSeriesStroke(0, new BasicStroke(1.5f));
    renderer.setSeriesStroke(1, new BasicStroke(1.5f));
    renderer.setSeriesStroke(2, new BasicStroke(1.5f));

    XYPlot plot = chart.getXYPlot();// w w w . j a  va  2 s .  c  om
    plot.setRenderer(renderer);

    return new ChartPanel(chart);
}

From source file:de.tuberlin.dima.flinkhandson.utils.SingleSeriesBarChart.java

public SingleSeriesBarChart(String title, String xLabel, String yLabel, Color barColor,
        Map<String, Double> result) {

    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    for (Map.Entry<String, Double> e : result.entrySet()) {
        dataset.addValue(e.getValue(), "", e.getKey());
    }//ww w  .j  a  v  a2s. c o m

    JFreeChart chart = ChartFactory.createBarChart(title, xLabel, yLabel, dataset, PlotOrientation.VERTICAL,
            false, true, false);

    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    CategoryAxis xAxis = plot.getDomainAxis();

    xAxis.setCategoryLabelPositions(CategoryLabelPositions.DOWN_45);
    plot.setRangeGridlinesVisible(true);
    plot.setRangeGridlinePaint(Color.BLACK);
    plot.setBackgroundPaint(Color.WHITE);

    BarRenderer renderer = (BarRenderer) plot.getRenderer();
    renderer.setBarPainter(new StandardBarPainter());

    renderer.setSeriesPaint(0, barColor);

    ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new Dimension(1024, 768));
    getContentPane().add(chartPanel);

    pack();
    setVisible(true);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}

From source file:org.mc.okapi.PieChart.java

public PieChart(String[] label, double[] value, String applicationTitle, String chartTitle) {
    super(applicationTitle);

    // This will create the dataset 

    DefaultPieDataset result = new DefaultPieDataset();

    for (int i = 0; i < label.length; i++) {
        result.setValue(label[i], value[i]);
    }//from   w  ww  .jav a 2  s.  c o m
    PieDataset dataset = result;

    // based on the dataset we create the chart
    JFreeChart chart = ChartFactory.createPieChart3D(chartTitle, // 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);

    // we put the chart into a panel
    ChartPanel chartPanel = new ChartPanel(chart);
    setIconImage(Toolkit.getDefaultToolkit().getImage("images/ico/extra/science_32.png"));
    // default size
    chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
    // add it to our application
    setContentPane(chartPanel);

}

From source file:sanger.team16.gui.genevar.eqtl.gene.RegionalPlot.java

public RegionalPlot(String geneChromosome, int geneStart, int distance, double threshold,
        List<QTL> significances, List<QTL> insignificances) throws ArrayIndexOutOfBoundsException {
    XYDataset dataset = this.createDataset(significances, insignificances);
    JFreeChart chart = createChart(geneChromosome, geneStart, distance, threshold, dataset);
    chart.setBackgroundPaint(Color.white);

    ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new Dimension(680, 175));

    this.add(chartPanel);
}

From source file:userInterface.StateAdminRole.DecisionChartJPanel.java

public DecisionChartJPanel(JPanel userProcessContainer, Enterprise e, Network n) {
    initComponents();//throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    this.userProcessContainer = userProcessContainer;
    this.e = (PhdEnterprise) e;
    this.n = n;//from w  ww  . ja v a 2s.  co m
    JFreeChart jfreechart = createChart(createDataset());
    Rotator rotator = new Rotator((PiePlot3D) jfreechart.getPlot());
    rotator.start();
    ChartPanel chartpanel = new ChartPanel(jfreechart);
    chartpanel.setPreferredSize(new Dimension(1000, 540));
    pieChartPanel.add(chartpanel);
    CardLayout layout = (CardLayout) pieChartPanel.getLayout();
    layout.next(pieChartPanel);

    populate();
}

From source file:Panels.FinanzPanel.java

public FinanzPanel(DetailContainer dc) {
    this.dc = dc;
    initComponents();/*w w  w .  j av a2s  . c o m*/
    dataset = new DefaultPieDataset();
    ;
    //        //dataset.addSeries("xy", A);
    //        dataset.setValue("One", new Double(43.2));
    //        dataset.setValue("Two", new Double(10.0));
    renderer = new XYSplineRenderer();
    ////        xax = new NumberAxis("x");
    ////        yax = new NumberAxis("y");
    plot = new PiePlot(dataset);
    //        //plot = new XYPlot(dataset,xax,yax, renderer);
    chart1 = new JFreeChart(plot);
    chartPanel1 = new ChartPanel(chart1);
    chartPanel1.setMouseWheelEnabled(true);
    //        this.jPanel1.setLayout(new java.awt.BorderLayout());
    this.jPanel1.add(chartPanel1);
    this.jButton1.setModel(new DefaultButtonModel());
    //        this.add(new JButton("back"), BorderLayout.SOUTH );
    this.validate();
}

From source file:grafica.Lineal.java

private void inicializar() {
    cjto_datos = new XYSeriesCollection();
    grafico = crearGrafico(cjto_datos);/*from ww w.  j  a va 2  s  . com*/
    panel_grafico = new ChartPanel(grafico);
    panel_grafico.setFillZoomRectangle(true);
    panel_grafico.setMouseWheelEnabled(true);
}

From source file:org.jboss.seam.cron.examples.swinggrapher.SwingGrapherForm.java

/**
 * Initialise the chart visuals./*from   w w  w . j a  va2s  .c  om*/
 */
@PostConstruct
public void initChart() {
    log.info("Initializing");
    final JFreeChart chart = ChartFactory.createLineChart3D("Free Memory", "Time", "Bytes", catDataSet,
            PlotOrientation.VERTICAL, true, true, true);
    final ChartPanel chartPanel = new ChartPanel(chart);
    setContentPane(chartPanel);
}

From source file:GUI.GraficaView.java

private void init() {
    ArrayList<OperacionesDiarias> aux = operario.getArrayOperacionesDiarias();
    Collections.sort(aux);//from w ww  . java2  s . c  o  m

    panel = new JPanel();
    getContentPane().add(panel);
    // Fuente de Datos
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    for (OperacionesDiarias op : aux) {
        if (op.getListaOperaciones().size() > 0) {
            dataset.setValue(op.getPorcentaje(), operario.getNombre(), op.getFecha());
        }

    }

    // Creando el Grafico
    JFreeChart chart = ChartFactory.createBarChart3D("Rendimiento", "Dia", "Porcentaje %", dataset,
            PlotOrientation.VERTICAL, true, true, false);
    chart.setBackgroundPaint(Color.LIGHT_GRAY);
    chart.getTitle().setPaint(Color.black);
    CategoryPlot p = chart.getCategoryPlot();
    p.setRangeGridlinePaint(Color.red);

    // Mostrar Grafico
    ChartPanel chartPanel = new ChartPanel(chart);
    panel.add(chartPanel);
    repaint();
}