package Pie_Chart;
import javax.swing.*;
import java.awt.Dimension;
import java.awt.GridLayout;
import javax.swing.JPanel;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.title.TextTitle;
import org.jfree.data.general.DefaultPieDataset;
import org.jfree.ui.ApplicationFrame;
import org.jfree.ui.RectangleEdge;
import org.jfree.ui.RefineryUtilities;
public class PieChart extends ApplicationFrame
{
private Object chart;
public PieChart(String title) {
super(title);
DB db = new DB();
db.dbConnect("jdbc:sqlserver://newinfomine:3468;instanceName=MSSQL2005", "eGActiveDB_762", "eGActiveDB_762" );
JPanel panel = new JPanel(new GridLayout(2, 2));
DefaultPieDataset dataset = new DefaultPieDataset();
DefaultPieDataset dataset1 = new DefaultPieDataset();
dataset.setValue("January "+DB.ravi_case, DB.ravi_case);
dataset.setValue("February "+DB.ravi_case_feb, DB.ravi_case_feb);
dataset.setValue("March "+DB.ravi_case_mar, DB.ravi_case_mar);
dataset1.setValue("January "+DB.pradeep_case, DB.pradeep_case);
dataset1.setValue("February "+DB.pradeep_case_feb, DB.pradeep_case_feb);
dataset1.setValue("March "+DB.pradeep_case_mar, DB.pradeep_case_mar);
JFreeChart chart1 = ChartFactory.createPieChart("Ravi Case", dataset, false, false, false);
JFreeChart chart2 = ChartFactory.createPieChart("Pradeep Case", dataset1, false, false, false);
panel.add(new ChartPanel(chart1));
panel.add(new ChartPanel(chart2));
panel.setPreferredSize(new Dimension(800, 600));
setContentPane(panel);
}
public static void main(String[] args)
{
PieChart demo = new PieChart("Pie Chart");
demo.setVisible(true);
}
}