List of usage examples for org.jfree.chart ChartFactory createStackedBarChart
public static JFreeChart createStackedBarChart(String title, String domainAxisLabel, String rangeAxisLabel, CategoryDataset dataset)
From source file:be.pendragon.j2s.seventhcontinent.plot.jfreechart.JFreeChartPlotter.java
@Override public void plot(Statistics[] stats, String[] seriesNames, String title, File outputFile) { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); for (int series = 0; series < stats.length; series++) { for (int pct = 1; pct <= 100; pct++) { double pctValue = stats[series].getPercentile(pct); // # of stars if (series > 0) { pctValue = pctValue - stats[series - 1].getPercentile(pct); // deltas are stackables }/*ww w . j a v a 2 s. c o m*/ dataset.addValue(pctValue, seriesNames[series], new Integer(pct)); } } final JFreeChart barChart = ChartFactory.createStackedBarChart(title, "%", "# stars", dataset); try { ChartUtilities.saveChartAsJPEG(outputFile, barChart, width, height); } catch (IOException ex) { // LOG.log(Level.SEVERE, "Plotting chart to file", ex); throw new RuntimeException("Plotting with JFreeChart chart to file", ex); } }