當前位置: 首頁>>代碼示例>>Java>>正文


Java ChartFactory.createStackedBarChart方法代碼示例

本文整理匯總了Java中org.jfree.chart.ChartFactory.createStackedBarChart方法的典型用法代碼示例。如果您正苦於以下問題:Java ChartFactory.createStackedBarChart方法的具體用法?Java ChartFactory.createStackedBarChart怎麽用?Java ChartFactory.createStackedBarChart使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.jfree.chart.ChartFactory的用法示例。


在下文中一共展示了ChartFactory.createStackedBarChart方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createChart

import org.jfree.chart.ChartFactory; //導入方法依賴的package包/類
/**
 * Create a horizontal bar chart with sample data in the range -3 to +3.
 *
 * @return the chart.
 */
private static JFreeChart createChart() {

    // create a dataset...
    Number[][] data = new Integer[][]
        {{new Integer(-3), new Integer(-2)},
         {new Integer(-1), new Integer(1)},
         {new Integer(2), new Integer(3)}};

    CategoryDataset dataset = DatasetUtilities.createCategoryDataset("S", "C", data);

    // create the chart...
    return ChartFactory.createStackedBarChart(
        "Stacked Bar Chart",  // chart title
        "Domain", "Range",
        dataset,      // data
        PlotOrientation.HORIZONTAL,
        true,         // include legend
        true,
        false
    );

}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:28,代碼來源:StackedBarChartTests.java

示例2: createChart

import org.jfree.chart.ChartFactory; //導入方法依賴的package包/類
/**
 * Create a stacked bar chart with sample data in the range -3 to +3.
 *
 * @return The chart.
 */
private static JFreeChart createChart() {

    // create a dataset...
    Number[][] data = new Integer[][]
        {{new Integer(-3), new Integer(-2)},
         {new Integer(-1), new Integer(1)},
         {new Integer(2), new Integer(3)}};

    CategoryDataset dataset = DatasetUtilities.createCategoryDataset("S", 
            "C", data);

    // create the chart...
    return ChartFactory.createStackedBarChart(
        "Stacked Bar Chart",  // chart title
        "Domain", "Range",
        dataset,      // data
        PlotOrientation.HORIZONTAL,
        true,         // include legend
        true,
        true
    );

}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:29,代碼來源:StackedBarChartTests.java

示例3: createChart

import org.jfree.chart.ChartFactory; //導入方法依賴的package包/類
public ChartPanel createChart(final String title,
                              final CategoryDataset dataset,
                              final String xlabel,
                              final String ylable) {
    JFreeChart chart = ChartFactory.createStackedBarChart(title, xlabel, ylable, dataset);
    ChartUtils.setAntiAlias(chart);
    ChartUtils.setStackBarRender(chart.getCategoryPlot());
    ChartUtils.setXAixs(chart.getCategoryPlot());
    ChartUtils.setYAixs(chart.getCategoryPlot());
    chart.getLegend().setFrame(new BlockBorder(Color.WHITE));
    ChartPanel chartPanel = new ChartPanel(chart);
    return chartPanel;
}
 
開發者ID:Fanping,項目名稱:iveely.ml,代碼行數:14,代碼來源:StackedBarChart.java

示例4: createHourlyBreakageDistributionChart

import org.jfree.chart.ChartFactory; //導入方法依賴的package包/類
public static void createHourlyBreakageDistributionChart(final SortedMap stats, final String categoryLabel, final OutputStream out) throws IOException {

    final DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    for (final Iterator iter = stats.entrySet().iterator(); iter.hasNext();) {
      final Map.Entry entry = (Map.Entry) iter.next();
      final Integer hour = (Integer) entry.getKey();
      final BuildStatistics bst = (BuildStatistics) entry.getValue();
      dataset.addValue(new Integer(bst.getFailedBuilds()), "Failed builds", hour);
    }

    // create the chart object

    // This generates a stacked bar - more suitable
    final JFreeChart chart = ChartFactory.createStackedBarChart(null,
            categoryLabel, "Builds", dataset,
            PlotOrientation.VERTICAL,
            true, false, false);
    chart.setBackgroundPaint(Color.white);

    // change the auto tick unit selection to integer units only
    final CategoryPlot plot = chart.getCategoryPlot();
    final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    // set bar colors
    final BarRenderer bar = (BarRenderer) plot.getRenderer();
    bar.setItemMargin(0); // reduce the width between the bars.
    bar.setSeriesPaint(0, Color.RED); // first bar

    // write to reposnce
    final ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection());
    ChartUtilities.writeChartAsPNG(out, chart, IMG_WIDTH, IMG_HEIGHT, info);
  }
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:34,代碼來源:StatisticsUtils.java

示例5: createDayOfWeekBreakageDistributionChart

import org.jfree.chart.ChartFactory; //導入方法依賴的package包/類
public static void createDayOfWeekBreakageDistributionChart(final SortedMap stats, final String categoryLabel, final OutputStream out) throws IOException {


    final DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    for (final Iterator iter = stats.entrySet().iterator(); iter.hasNext();) {
      final Map.Entry entry = (Map.Entry) iter.next();
      final Integer dayOfWeek = (Integer) entry.getKey();
      final BuildStatistics bst = (BuildStatistics) entry.getValue();
      dataset.addValue(new Integer(bst.getFailedBuilds()), "Failed builds", new ComparableDayOfWeek(dayOfWeek));
    }

    // create the chart object

    // This generates a stacked bar - more suitable
    final JFreeChart chart = ChartFactory.createStackedBarChart(null,
            categoryLabel, "Builds", dataset,
            PlotOrientation.VERTICAL,
            true, false, false);
    chart.setBackgroundPaint(Color.white);

    // change the auto tick unit selection to integer units only
    final CategoryPlot plot = chart.getCategoryPlot();
    final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    // set bar colors
    final BarRenderer bar = (BarRenderer) plot.getRenderer();
    bar.setItemMargin(0); // reduce the width between the bars.
    bar.setSeriesPaint(0, Color.RED); // first bar

    // write to reposnce
    final ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection());
    ChartUtilities.writeChartAsPNG(out, chart, IMG_WIDTH, IMG_HEIGHT, info);
  }
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:35,代碼來源:StatisticsUtils.java

示例6: createBuildResultsBarChart

import org.jfree.chart.ChartFactory; //導入方法依賴的package包/類
/**
 * Creates a distribution image for build results.
 *
 * @param stats         SortedMap with dates as keys and
 *                      BuildStatistics as value.
 * @param categoryLabel - label to place on X axis.
 * @param out           OutputStream to write image to.
 */
public static void createBuildResultsBarChart(final SortedMap stats, final String categoryLabel,
                                              final String dateFormat, final OutputStream out) throws IOException {

  final DefaultCategoryDataset dataset = new DefaultCategoryDataset();
  for (final Iterator iter = stats.entrySet().iterator(); iter.hasNext();) {
    final Map.Entry entry = (Map.Entry) iter.next();
    final Date date = (Date) entry.getKey();
    final BuildStatistics bst = (BuildStatistics) entry.getValue();
    final String dateAsString = StringUtils.formatDate(date, dateFormat);
    dataset.addValue(new Integer(bst.getFailedBuilds()), "Failed builds", dateAsString);
    dataset.addValue(new Integer(bst.getSuccessfulBuilds()), "Successful builds", dateAsString);
  }

  // create the chart object

  // This generates a stacked bar - more suitable
  final JFreeChart chart = ChartFactory.createStackedBarChart(null,
          categoryLabel, "Builds", dataset,
          PlotOrientation.VERTICAL,
          true, false, false);
  chart.setBackgroundPaint(Color.white);

  // change the auto tick unit selection to integer units only
  final CategoryPlot plot = chart.getCategoryPlot();
  final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
  rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

  // rotate X dates
  final CategoryAxis domainAxis = plot.getDomainAxis();
  domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45);

  // set bar colors

  final BarRenderer bar = (BarRenderer) plot.getRenderer();
  bar.setItemMargin(0); // reduce the width between the bars.
  bar.setSeriesPaint(0, Color.RED); // first bar
  bar.setSeriesPaint(1, Color.GREEN); // second bar
  //plot.setRenderer(bar);

  // write to reposnce
  final ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection());
  ChartUtilities.writeChartAsPNG(out, chart, IMG_WIDTH, IMG_HEIGHT, info);
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:52,代碼來源:StatisticsUtils.java

示例7: createChangeListsBarChart

import org.jfree.chart.ChartFactory; //導入方法依賴的package包/類
/**
 * Creates a distribution image for build results.
 *
 * @param stats         SortedMap with dates as keys and
 *                      BuildStatistics as value.
 * @param categoryLabel - label to place on X axis.
 * @param out           OutputStream to write image to.
 */
public static void createChangeListsBarChart(final SortedMap stats, final String categoryLabel,
                                             final String dateFormat, final OutputStream out) throws IOException {

  final DefaultCategoryDataset dataset = new DefaultCategoryDataset();
  for (final Iterator iter = stats.entrySet().iterator(); iter.hasNext();) {
    final Map.Entry entry = (Map.Entry) iter.next();
    final Date date = (Date) entry.getKey();
    final BuildStatistics bst = (BuildStatistics) entry.getValue();
    final String dateAsString = StringUtils.formatDate(date, dateFormat);
    dataset.addValue(new Integer(bst.getChangeLists()), "Change lists", dateAsString);
  }

  // create the chart object

  // This generates a stacked bar - more suitable
  final JFreeChart chart = ChartFactory.createStackedBarChart(null,
          categoryLabel, "Change lists", dataset,
          PlotOrientation.VERTICAL,
          true, false, false);
  chart.setBackgroundPaint(Color.white);

  // change the auto tick unit selection to integer units only
  final CategoryPlot plot = chart.getCategoryPlot();
  final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
  rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

  // rotate X dates
  final CategoryAxis domainAxis = plot.getDomainAxis();
  domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45);

  // set bar colors

  final BarRenderer bar = (BarRenderer) plot.getRenderer();
  bar.setItemMargin(0); // reduce the width between the bars.
  bar.setSeriesPaint(0, Color.BLUE); // first bar
  //bar.setSeriesPaint(1, Color.GREEN); // second bar

  // write to reposnce
  final ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection());
  ChartUtilities.writeChartAsPNG(out, chart, IMG_WIDTH, IMG_HEIGHT, info);
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:50,代碼來源:StatisticsUtils.java


注:本文中的org.jfree.chart.ChartFactory.createStackedBarChart方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。