Code: Select all
public class ChartTest {
public static void main(String[] args) {
DefaultCategoryDataset ds = new DefaultCategoryDataset();
ds.addValue(100, "A", "2001");
ds.addValue(1000, "B", "2001");
ds.addValue(600, "B", "2006");
ds.addValue(5000, "A", "2006");
JFreeChart stackedBar= ChartFactory.createStackedBarChart("My Chart", "AB", "Amounts", ds, PlotOrientation.VERTICAL, true, true, false);
ChartFrame cf = new ChartFrame("Test", stackedBar);
cf.setSize(800, 600);
cf.setVisible(true);
}
}

