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:cv.mikusher.freechart.BubbleChart.java

public static JPanel createDemoPanel() {
    JFreeChart jfreechart = createChart(createDataset());
    ChartPanel chartpanel = new ChartPanel(jfreechart);

    chartpanel.setDomainZoomable(true);//w  w w. j a v a 2s . c o m
    chartpanel.setRangeZoomable(true);

    return chartpanel;
}

From source file:br.unicamp.cst.util.ChartViewerUtil.java

public static synchronized ChartPanel createLineXYChart(XYSeriesCollection dataset, String title,
        String categoryAxisLabel, String valueAxisLabel, long timeRefresh) {

    final JFreeChart chart = ChartFactory.createXYLineChart(title, categoryAxisLabel, valueAxisLabel, dataset,
            PlotOrientation.VERTICAL, true, true, false);

    final XYPlot plot = chart.getXYPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);
    plot.getDomainAxis().setFixedAutoRange(timeRefresh * 100);
    chart.setBackgroundPaint(Color.lightGray);

    ChartPanel localChartPanel = new ChartPanel(chart);
    localChartPanel.setVisible(true);//from   ww w . j  av a  2  s  .c o  m
    localChartPanel.setDomainZoomable(true);

    return localChartPanel;
}

From source file:CPU.StackedBarChartExample1.java

/**
 * Constructor// w w w .j a v a2 s . co m
 * @param titel
 */
StackedBarChartExample1(String titel) {
    super(titel);

    final CategoryDataset dataset = createDataset();
    final JFreeChart sbchart = createChart(dataset);
    final ChartPanel pnl = new ChartPanel(sbchart);
    pnl.setPreferredSize(new java.awt.Dimension(450, 350));
    setContentPane(pnl);

}

From source file:graphs.LimitsGraphs.java

/**
 * Creates a new demo instance.//from   ww  w . j a v a  2 s  . c  o m
 *
 * @param title  the frame title.
 */
public LimitsGraphs(final String title) {

    super(title);

    final CategoryDataset dataset = createDataset();
    final JFreeChart chart = createChart(dataset);
    final ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new Dimension(500, 270));
    setContentPane(chartPanel);

}

From source file:simulation.Graf.java

public Graf(String applicationTitle, String chartTitle, String chart, String chart2) {
    super(applicationTitle);
    JFreeChart lineChart = ChartFactory.createXYLineChart(chartTitle, chart, chart2, mnozina,
            PlotOrientation.VERTICAL, true, true, false);
    plot = (XYPlot) lineChart.getPlot();
    axis = (NumberAxis) plot.getRangeAxis();
    lineChart.getLegend().setVisible(false);
    lineChart.getLegend().setPosition(RectangleEdge.RIGHT);
    ChartPanel chartPanel = new ChartPanel(lineChart);
    chartPanel.setPreferredSize(new java.awt.Dimension(560, 367));
    p = chartPanel;/*from w w w .j av  a  2 s.  co m*/
    setContentPane(chartPanel);
}

From source file:Graphing.piChart.java

public JPanel getPiePanel() {
    PieDataset dataSet = getDataSet();/*from  www .  ja  v a 2s. c om*/
    JFreeChart pieChart = ChartFactory.createPieChart(this.name, dataSet, this.Legend, this.toolTips, false);

    return new ChartPanel(pieChart);
}

From source file:IHM.NewClass.java

/**
 *
 * @param title//from  w  ww  .j a va  2 s. com
 */
public NewClass(String title /*,*JInternalFrame jp*/) {
    super(title);
    // jp = new JInternalFrame("courbes");

    JFreeChart chart = createChart(createDataset());
    ChartPanel panel = new ChartPanel(chart);
    panel.setPreferredSize(new Dimension(500, 300));
    setContentPane(panel);
    //  jp.add(panel, BorderLayout.EAST);
    //  jp.setVisible(true);
    panel.setVisible(true);
    XYPlot plot = chart.getXYPlot();
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    plot.setRenderer(renderer);
    renderer.setSeriesPaint(0, Color.RED);
    renderer.setSeriesPaint(1, Color.GREEN);
    renderer.setSeriesPaint(2, Color.YELLOW);
    // sets thickness for series (using strokes)
    renderer.setSeriesStroke(0, new BasicStroke(4.0f));
    renderer.setSeriesStroke(1, new BasicStroke(3.0f));
    renderer.setSeriesStroke(2, new BasicStroke(2.0f));
    plot.setRenderer(renderer);
    plot.setOutlinePaint(Color.BLUE);
    plot.setOutlineStroke(new BasicStroke(2.0f));
    plot.setBackgroundPaint(Color.DARK_GRAY);
    plot.setRangeGridlinesVisible(true);
    plot.setRangeGridlinePaint(Color.BLACK);
    plot.setDomainGridlinesVisible(true);
    plot.setDomainGridlinePaint(Color.BLACK);

}

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

public static JPanel createDemoPanel() {
    JFreeChart jfreechart = createChart(createDataset());
    ChartPanel chartpanel = new ChartPanel(jfreechart);
    chartpanel.setMouseZoomable(false);// w w w  .  j a va  2 s  . co m
    return chartpanel;
}

From source file:estimatePressure.CreateGraph.java

public CreateGraph(String applicationTitle, String chartTitle, Matrix errData, int sensorNum) {
    super(applicationTitle);
    this.errorData = errData;
    this.sensorNumber = sensorNum;
    JFreeChart lineChart = ChartFactory.createLineChart(chartTitle, "Time", "Error", createDataset(),
            PlotOrientation.VERTICAL, true, true, false);
    //lineChart.setBackgroundPaint(Color.red);
    ChartPanel chartPanel = new ChartPanel(lineChart);
    chartPanel.setPreferredSize(new java.awt.Dimension(1200, 500));
    setContentPane(chartPanel);/*from w w w .j av a2  s .c  o m*/

    File fileLineChart = new File("Error values" + this.sensorNumber + ".jpeg");
    try {
        ChartUtilities.saveChartAsJPEG(fileLineChart, lineChart, 1200, 500);
    } catch (IOException e) {
        e.printStackTrace();
    }

}

From source file:simuladorruleta.Principal.java

private void graficar() {
    ChartPanel panel;//www.  j a  v  a2  s  .com
    JFreeChart chart = null;

    /* 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);

}