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:gov.sandia.umf.platform.ui.jobs.Plot.java

public JPanel createGraphPanel() {
    XYDataset dataset = createDataset();
    JFreeChart chart = createChart(dataset);
    return new ChartPanel(chart);
}

From source file:moviedatas.View.GlobalChart.java

public JPanel initView() {
    observer = this;
    ArrayList<Movie> movies = MovieListController.allMovies;
    XYSeries series = new XYSeries("Movie");
    for (int i = 0; i < movies.size(); i++) {
        Movie currentMovie = movies.get(i);
        series.add(currentMovie.getGross(), currentMovie.getScore());
    }/*from www .  j ava  2 s  . c  o  m*/
    XYSeriesCollection dataset = new XYSeriesCollection();
    dataset.addSeries(series);
    JFreeChart scatterPlot = ChartFactory.createScatterPlot("", "Gross (in $)", "Score", dataset, VERTICAL,
            true, true, false);

    cPanel = new ChartPanel(scatterPlot);
    cPanel.setPreferredSize(new Dimension(500, 250));
    return cPanel;
}

From source file:gov.nih.nci.caintegrator.ui.graphing.test.KaplanMeierGraphTester.java

public KaplanMeierGraphTester(String title) {
    super(title);
    Collection<KaplanMeierPlotPointSeriesSet> sets = new ArrayList<KaplanMeierPlotPointSeriesSet>();
    KaplanMeierPlotPointSeriesSet set1 = createKMPlotPointSeriesSet("Up Regulated", 10, .15);
    set1.setColor(Color.BLUE);//  w  w  w .  j  a v  a  2  s  .c  om
    sets.add(set1);

    KaplanMeierPlotPointSeriesSet set2 = createKMPlotPointSeriesSet("Down Regulated", 15, .25);
    set2.setColor(Color.RED);
    sets.add(set2);

    KaplanMeierPlotPointSeriesSet set3 = createKMPlotPointSeriesSet("Intermediate", 18, .07);
    set3.setColor(Color.GREEN);
    sets.add(set3);

    KaplanMeierPlot kmPlot = new KaplanMeierPlot(sets);
    JFreeChart chart = kmPlot.getKmChart();
    ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new java.awt.Dimension(800, 600));
    setContentPane(chartPanel);
}

From source file:com.chris.brkopani.gui.analytics.Graph.java

public void createAndShowGui(JDesktopPane desk) throws SQLException {

    //? tabed pane   ?  
    WebLookAndFeel.install();/* w w w  . java  2  s.  co m*/
    frame = new JInternalFrame("PieChart", true, true, true, true);
    frame.setFrameIcon(new ImageIcon("res/br.png"));
    frame.setBounds(530, 5, 520, 350);
    frame.getContentPane().getBackground();
    // This will create the dataset 
    PieDataset dataset = createDataset();
    // based on the dataset we create the chart
    JFreeChart chart = createChart(dataset, "PieChart");
    // we put the chart into a panel
    ChartPanel chartPanel = new ChartPanel(chart);
    chart.setBackgroundPaint(Color.GRAY);
    // default size
    chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
    // add it to our application
    frame.add(chartPanel);

    frame.setVisible(true);
    desk.add(frame);

}

From source file:Graphing.barGraph.java

public JPanel getBarGraph() {
    CategoryDataset dataSet = getDataSet();
    JFreeChart chart = ChartFactory.createBarChart(this.name, this.X, this.Y, dataSet, this.p, this.Legend,
            this.toolTip, false);

    return new ChartPanel(chart);
}

From source file:com.sigueros.charts.LinearRegressionExample.java

public LinearRegressionExample(String applicationTitle, String chartTitle) {
    super(applicationTitle);

    fillinDataArray();/*from   w  w w . ja v a2  s  . c o m*/

    // based on the dataset we create the chart
    JFreeChart chart = createChart(chartTitle);
    // we put the chart into a panel
    ChartPanel chartPanel = new ChartPanel(chart);
    // default size
    chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
    // add it to our application
    setContentPane(chartPanel);
}

From source file:spminiproject.lab2.chart.Histogram2.java

public static JPanel createPanel(String title, double vector[], int intervals, String labelx, String labely) {
    JFreeChart chart = createChart(createDataset(title, vector, intervals), labelx, labely);
    return new ChartPanel(chart);
}

From source file:bbank.CurrentStockWindow.java

/**
 * Creates new form CurrentStockWindow/* w ww .  j  av a 2s.  c om*/
 */
public CurrentStockWindow() {
    initComponents();
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    BloodStock.CalculateTotalBlood();
    dataset.addValue(BloodStock.total_A_accepted, "", "Total Accepted A");
    dataset.addValue(BloodStock.total_A_rejected, "", "Total Rejected A");
    dataset.addValue(BloodStock.total_B_accepted, "", "Total Accepted B");
    dataset.addValue(BloodStock.total_B_rejected, "", "Total Rejected B");
    dataset.addValue(BloodStock.total_O_accepted, "", "Total Accepted O");
    dataset.addValue(BloodStock.total_O_rejected, "", "Total Rejected O");

    JFreeChart chart = ChartFactory.createBarChart("Current Total Blood Stock", "Blood type", "Amount (litres)",
            dataset, PlotOrientation.VERTICAL, false, false, false);
    CategoryPlot catPlot = chart.getCategoryPlot();
    catPlot.setRangeGridlinePaint(Color.BLACK);

    ChartPanel chartpanel = new ChartPanel(chart);
    jPanel1.removeAll();
    jPanel1.add(chartpanel);
    jPanel1.validate();
}

From source file:netplot.BarPlotPanel.java

public void init() {
    finalize();
    series = new XYSeries("");
    chart = createChart();
    add(new ChartPanel(chart));
}

From source file:stratego.neural.net.RandomSampleTest.java

private static void plotDataSet(List<double[]> data) {

    XYSeriesCollection plotData = new XYSeriesCollection();

    for (double[] ds : data) {

        XYSeries series = new XYSeries("Winrate");

        for (int i = 0; i < ds.length; i++) {
            series.add((double) i, ds[i]);
        }/*from   w  ww .  j a  v  a  2 s.co  m*/

        plotData.addSeries(series);
    }

    String title = "Simulating Random Samples";
    String xAxisLabel = "Matches";
    String yAxisLabel = "Winrate";
    PlotOrientation orientation = PlotOrientation.VERTICAL;
    boolean legend = false; // might wanna set this to true at some point, but research the library
    boolean tooltips = false;
    boolean urls = false;
    JFreeChart chart = ChartFactory.createScatterPlot(title, xAxisLabel, yAxisLabel, plotData, orientation,
            legend, tooltips, urls);

    JPanel panel = new ChartPanel(chart);

    JFrame f = new JFrame();
    f.add(panel);
    f.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    f.pack();
    f.setTitle("Random test simulation");

    f.setVisible(true);
}