my.demo.BarChart.java Source code

Java tutorial

Introduction

Here is the source code for my.demo.BarChart.java

Source

/*
 * Copyright (C) 2015 Mastek Ltd
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

/**
 *
 * @author 
 * Alok Joshi, 
 * Mounika G, 
 * Rahul Gope, 
 * Sri Harsha Moturi
 * Bhushan Kharbikar
 */

package my.demo;

import javax.swing.JFrame;
import javax.swing.JPanel;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.data.category.CategoryDataset;

public class BarChart extends JFrame {

    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);
        jp.add(chartPanel);

    }

}