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


Java CategoryPlot.getDomainAxis方法代碼示例

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


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

示例1: createChart

import org.jfree.chart.plot.CategoryPlot; //導入方法依賴的package包/類
private JFreeChart createChart(CategoryDataset dataset, HttpServletRequest request) {
    JFreeChart chart = ChartFactory.createBarChart(null, null, null, dataset, PlotOrientation.HORIZONTAL, false, false, false);

    CategoryPlot plot = chart.getCategoryPlot();
    Paint background = new GradientPaint(0, 0, Color.lightGray, 0, IMAGE_MIN_HEIGHT, Color.white);
    plot.setBackgroundPaint(background);
    plot.setDomainGridlinePaint(Color.white);
    plot.setDomainGridlinesVisible(true);
    plot.setRangeGridlinePaint(Color.white);
    plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);

    LogarithmicAxis rangeAxis = new LogarithmicAxis(null);
    rangeAxis.setStrictValuesFlag(false);
    rangeAxis.setAllowNegativesFlag(true);
    plot.setRangeAxis(rangeAxis);

    // Disable bar outlines.
    BarRenderer renderer = (BarRenderer) plot.getRenderer();
    renderer.setDrawBarOutline(false);

    // Set up gradient paint for series.
    GradientPaint gp0 = new GradientPaint(
            0.0f, 0.0f, Color.blue,
            0.0f, 0.0f, new Color(0, 0, 64)
    );
    renderer.setSeriesPaint(0, gp0);

    // Rotate labels.
    CategoryAxis domainAxis = plot.getDomainAxis();
    domainAxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0));

    // Set theme-specific colors.
    Color bgColor = getBackground(request);
    Color fgColor = getForeground(request);

    chart.setBackgroundPaint(bgColor);

    domainAxis.setTickLabelPaint(fgColor);
    domainAxis.setTickMarkPaint(fgColor);
    domainAxis.setAxisLinePaint(fgColor);

    rangeAxis.setTickLabelPaint(fgColor);
    rangeAxis.setTickMarkPaint(fgColor);
    rangeAxis.setAxisLinePaint(fgColor);

    return chart;
}
 
開發者ID:airsonic,項目名稱:airsonic,代碼行數:48,代碼來源:UserChartController.java

示例2: BarChart

import org.jfree.chart.plot.CategoryPlot; //導入方法依賴的package包/類
public BarChart() {
    CategoryDataset dataset = getDataSet();
    JFreeChart chart = ChartFactory.createBarChart3D(
            "水果", // 圖表標題
            "水果種類", // 目錄軸的顯示標簽
            "數量", // 數值軸的顯示標簽
            dataset, // 數據集
            PlotOrientation.VERTICAL, // 圖表方向:水平、垂直
            true,           // 是否顯示圖例(對於簡單的柱狀圖必須是false)
            false,          // 是否生成工具
            false           // 是否生成URL鏈接
    );

    //從這裏開始
    CategoryPlot plot = chart.getCategoryPlot();//獲取圖表區域對象
    CategoryAxis domainAxis = plot.getDomainAxis();         //水平底部列表
    domainAxis.setLabelFont(new Font("黑體", Font.BOLD, 14));         //水平底部標題
    domainAxis.setTickLabelFont(new Font("宋體", Font.BOLD, 12));  //垂直標題
    ValueAxis rangeAxis = plot.getRangeAxis();//獲取柱狀
    rangeAxis.setLabelFont(new Font("黑體", Font.BOLD, 15));
    chart.getLegend().setItemFont(new Font("黑體", Font.BOLD, 15));
    chart.getTitle().setFont(new Font("宋體", Font.BOLD, 20));//設置標題字體

    //到這裏結束,雖然代碼有點多,但隻為一個目的,解決漢字亂碼問題

    frame1 = new ChartPanel(chart, true);        //這裏也可以用chartFrame,可以直接生成一個獨立的Frame

}
 
開發者ID:leon66666,項目名稱:financehelper,代碼行數:29,代碼來源:BarChart.java

示例3: createChart

import org.jfree.chart.plot.CategoryPlot; //導入方法依賴的package包/類
/**
 * Creates a chart for recent time to fix.
 *
 */
public void createChart(final SortedMap time, final String valueKey, final Color lineColor, final OutputStream out) throws IOException {

  final DefaultCategoryDataset dataset = new DefaultCategoryDataset();
  addTimeToDataSet(dataset, time, valueKey);

  // create the chart object

  // This generates a stacked bar - more suitable

  final JFreeChart chart = ChartFactory.createLineChart(null,
    "Recent builds", "Time", 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(StatisticsUtils.createWordedTimeTickUnits());

  // rotate X dates

  final CategoryAxis domainAxis = plot.getDomainAxis();
  domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45);

  // set bar colors

  final LineAndShapeRenderer line = (LineAndShapeRenderer)plot.getRenderer();
  line.setSeriesPaint(0, lineColor);
  line.setStroke(StatisticsUtils.DEFAULT_LINE_STROKE);

  // write to reposnce

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

示例4: createChart

import org.jfree.chart.plot.CategoryPlot; //導入方法依賴的package包/類
public void createChart(final SortedMap stats, 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 buildNumber = (Integer)entry.getKey();
      final Integer violations = (Integer)entry.getValue();
      dataset.addValue(violations, categoryDescription, buildNumber);
    }

    // create the chart object

    // This generates a stacked bar - more suitable
    final JFreeChart chart = ChartFactory.createLineChart(null,
      "Recent builds", valueAxisLabel, 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 LineAndShapeRenderer line = (LineAndShapeRenderer)plot.getRenderer();
    line.setSeriesPaint(0, Color.RED);
    line.setStroke(StatisticsUtils.DEFAULT_LINE_STROKE);

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

示例5: createTestsResultsChartHelper

import org.jfree.chart.plot.CategoryPlot; //導入方法依賴的package包/類
/**
   *
   */
  private static void createTestsResultsChartHelper(final String categoryLabel, final DefaultCategoryDataset dataset, final OutputStream out, final CategoryLabelPositions categoryLabelPosition) throws IOException {
    final JFreeChart chart = ChartFactory.createStackedAreaChart(null,
            categoryLabel, "Tests", 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 LogarithmicAxis logarithmicAxis = new LogarithmicAxis("Tests");
    logarithmicAxis.setStrictValuesFlag(false);
    logarithmicAxis.setAutoRangeIncludesZero(true);
    logarithmicAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    plot.setRangeAxis(logarithmicAxis);
//    final NumberAxis rangeAxis = (NumberAxis)plot.getRangeAxis();

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

    // set area colors

    final StackedAreaRenderer area = (StackedAreaRenderer) plot.getRenderer();
    area.setSeriesPaint(0, Color.RED); // first area
    area.setSeriesPaint(1, Color.PINK); // second area
    area.setSeriesPaint(2, Color.GREEN); // thirs area
    //plot.setRenderer(area);

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

示例6: createRecentBuildTimesChart

import org.jfree.chart.plot.CategoryPlot; //導入方法依賴的package包/類
public static void createRecentBuildTimesChart(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 buildNumber = (Integer) entry.getKey();
      final Integer timeInSeconds = (Integer) entry.getValue();
      dataset.addValue(timeInSeconds, "Build time", buildNumber);
    }

    // create the chart object

    // This generates a stacked bar - more suitable
    final JFreeChart chart = ChartFactory.createLineChart(null,
            categoryLabel, "Build time", 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());
    rangeAxis.setStandardTickUnits(createWordedTimeTickUnits());

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

    // set bar colors

    final LineAndShapeRenderer line = (LineAndShapeRenderer) plot.getRenderer();
    line.setSeriesPaint(0, Color.BLUE);
    line.setStroke(DEFAULT_LINE_STROKE);

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

示例7: createChart

import org.jfree.chart.plot.CategoryPlot; //導入方法依賴的package包/類
private JFreeChart createChart() {
	if (data.getItemCount() > 0) {
		// get cumulative percentages
		KeyedValues cumulative = DataUtilities.getCumulativePercentages(data);

		CategoryDataset categoryDataset = DatasetUtilities.createCategoryDataset(
				"Count for " + this.dataTable.getColumnName(this.countColumn) + " = " + countValue, data);

		// create the chart...
		final JFreeChart chart = ChartFactory.createBarChart(null, // chart title
				this.dataTable.getColumnName(this.groupByColumn), // domain axis label
				"Count", // range axis label
				categoryDataset, // data
				PlotOrientation.VERTICAL, true, // include legend
				true, false);

		// set the background color for the chart...
		chart.setBackgroundPaint(Color.WHITE);

		// get a reference to the plot for further customization...
		CategoryPlot plot = chart.getCategoryPlot();

		CategoryAxis domainAxis = plot.getDomainAxis();
		domainAxis.setLowerMargin(0.02);
		domainAxis.setUpperMargin(0.02);
		domainAxis.setLabelFont(LABEL_FONT_BOLD);
		domainAxis.setTickLabelFont(LABEL_FONT);

		// set the range axis to display integers only...
		NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
		rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits(Locale.US));
		rangeAxis.setLabelFont(LABEL_FONT_BOLD);
		rangeAxis.setTickLabelFont(LABEL_FONT);

		// second data set (cumulative percentages)
		CategoryDataset dataset2 = DatasetUtilities.createCategoryDataset("Cumulative (Percent)", cumulative);

		LineAndShapeRenderer renderer2 = new LineAndShapeRenderer();
		renderer2.setSeriesPaint(0, SwingTools.VERY_DARK_BLUE.darker());

		NumberAxis axis2 = new NumberAxis("Percent of " + countValue);
		axis2.setNumberFormatOverride(NumberFormat.getPercentInstance());
		axis2.setLabelFont(LABEL_FONT_BOLD);
		axis2.setTickLabelFont(LABEL_FONT);

		plot.setRangeAxis(1, axis2);
		plot.setDataset(1, dataset2);
		plot.setRenderer(1, renderer2);
		plot.mapDatasetToRangeAxis(1, 1);

		axis2.setTickUnit(new NumberTickUnit(0.1));

		// show grid lines
		plot.setRangeGridlinesVisible(true);

		// bring cumulative line to front
		plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);

		if (isLabelRotating()) {
			domainAxis.setTickLabelsVisible(true);
			domainAxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 2.0d));
		}

		return chart;
	} else {
		return null;
	}
}
 
開發者ID:transwarpio,項目名稱:rapidminer,代碼行數:69,代碼來源:ParetoChartPlotter.java

示例8: init

import org.jfree.chart.plot.CategoryPlot; //導入方法依賴的package包/類
@SuppressWarnings("deprecation")
	public void init() {
		CategoryDataset dataset = getDataSet();
		JFreeChart chart = ChartFactory.createBarChart3D("Number Ranking", // 圖表標題
				"Book Types", // 目錄軸的顯示標簽
				"The Number of Books", // 數值軸的顯示標簽
				dataset, // 數據集
				PlotOrientation.VERTICAL, // 圖表方向:水平、垂直
				true, false, // 是否生成工具
				false // 是否生成URL鏈接
		);
		// 從這裏開始
		CategoryPlot plot = chart.getCategoryPlot();// 獲取圖表區域對象
		
		BarRenderer3D renderer =new BarRenderer3D();

		renderer.setItemLabelGenerator(new StandardCategoryItemLabelGenerator());
		renderer.setItemLabelFont(new Font("黑體",Font.BOLD,14));//12號黑體加粗
        renderer.setItemLabelPaint(Color.black);//字體為黑色
        
        renderer.setBasePositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.OUTSIDE3, TextAnchor.BASELINE_CENTER));  
        renderer.setItemLabelsVisible(true);

		plot.setRenderer(renderer);
		
		CategoryAxis domainAxis = plot.getDomainAxis(); // 水平底部列表
		domainAxis.setLabelFont(new Font("黑體", Font.BOLD, 14)); // 水平底部標題
		domainAxis.setTickLabelFont(new Font("宋體", Font.BOLD, 12)); // 垂直標題
		
		ValueAxis rangeAxis = plot.getRangeAxis();// 獲取柱狀
		rangeAxis.setUpperMargin(0.1);
		rangeAxis.setLabelFont(new Font("黑體", Font.BOLD, 15));
		chart.getLegend().setItemFont(new Font("黑體", Font.BOLD, 15));
		chart.getTitle().setFont(new Font("宋體", Font.BOLD, 20));// 設置標題字體

		
		chartPane = new ChartPanel(chart, true);

//		File dir = new File("images\\");
//		if (!dir.exists()) {
//			dir.mkdir();
//		}
//		String fName = String.valueOf(System.currentTimeMillis()) + "bar.png";
//		File file = new File("images\\", fName);
//		try {
//			ChartUtilities.saveChartAsPNG(file, chart, 550, 400);
//		} catch (IOException e) {
//
//			e.printStackTrace();
//		}
	}
 
開發者ID:metaotao,項目名稱:doubanbook,代碼行數:52,代碼來源:BarChart.java

示例9: createChart

import org.jfree.chart.plot.CategoryPlot; //導入方法依賴的package包/類
/**
 * Creates a sample chart.
 * 
 * @param dataset  the dataset.
 * 
 * @return The chart.
 */
private static JFreeChart createChart(CategoryDataset dataset) {
    
    // create the chart...
    JFreeChart chart = ChartFactory.createBarChart(
        "Bar Chart Demo",         // chart title
        "Category",               // domain axis label
        "Value",                  // range axis label
        dataset,                  // data
        PlotOrientation.VERTICAL, // orientation
        true,                     // include legend
        true,                     // tooltips?
        false                     // URLs?
    );

    // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART...

    // set the background color for the chart...
    chart.setBackgroundPaint(Color.white);

    // get a reference to the plot for further customisation...
    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setDomainGridlinesVisible(true);
    plot.setRangeGridlinePaint(Color.white);

    // set the range axis to display integers only...
    final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    // disable bar outlines...
    BarRenderer renderer = (BarRenderer) plot.getRenderer();
    renderer.setDrawBarOutline(false);

    CategoryAxis domainAxis = plot.getDomainAxis();
    domainAxis.setCategoryLabelPositions(
        CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0)
    );
    // OPTIONAL CUSTOMISATION COMPLETED.
    
    return chart;
    
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:51,代碼來源:SWTBarChartDemo1.java

示例10: createChart

import org.jfree.chart.plot.CategoryPlot; //導入方法依賴的package包/類
/**
 * Creates a sample chart.
 * 
 * @param dataset  the dataset.
 * 
 * @return The chart.
 */
private static JFreeChart createChart(CategoryDataset dataset) {
    
    // create the chart...
    JFreeChart chart = ChartFactory.createBarChart(
        "Bar Chart Demo 1",       // chart title
        "Category",               // domain axis label
        "Value",                  // range axis label
        dataset,                  // data
        PlotOrientation.VERTICAL, // orientation
        true,                     // include legend
        true,                     // tooltips?
        false                     // URLs?
    );

    // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART...

    // set the background color for the chart...
    chart.setBackgroundPaint(Color.white);

    // get a reference to the plot for further customisation...
    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setDomainGridlinesVisible(true);
    plot.setRangeGridlinePaint(Color.white);

    // ******************************************************************
    //  More than 150 demo applications are included with the JFreeChart
    //  Developer Guide...for more information, see:
    //
    //  >   http://www.object-refinery.com/jfreechart/guide.html
    //
    // ******************************************************************
    
    // set the range axis to display integers only...
    final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    // disable bar outlines...
    BarRenderer renderer = (BarRenderer) plot.getRenderer();
    renderer.setDrawBarOutline(false);
    
    // set up gradient paints for series...
    GradientPaint gp0 = new GradientPaint(0.0f, 0.0f, Color.blue, 
            0.0f, 0.0f, new Color(0, 0, 64));
    GradientPaint gp1 = new GradientPaint(0.0f, 0.0f, Color.green, 
            0.0f, 0.0f, new Color(0, 64, 0));
    GradientPaint gp2 = new GradientPaint(0.0f, 0.0f, Color.red, 
            0.0f, 0.0f, new Color(64, 0, 0));
    renderer.setSeriesPaint(0, gp0);
    renderer.setSeriesPaint(1, gp1);
    renderer.setSeriesPaint(2, gp2);

    CategoryAxis domainAxis = plot.getDomainAxis();
    domainAxis.setCategoryLabelPositions(
            CategoryLabelPositions.createUpRotationLabelPositions(
                    Math.PI / 6.0));
    // OPTIONAL CUSTOMISATION COMPLETED.
    
    return chart;
    
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:70,代碼來源:BarChartDemo1.java

示例11: createBuildResultsBarChart

import org.jfree.chart.plot.CategoryPlot; //導入方法依賴的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

示例12: createChangeListsBarChart

import org.jfree.chart.plot.CategoryPlot; //導入方法依賴的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

示例13: generate

import org.jfree.chart.plot.CategoryPlot; //導入方法依賴的package包/類
public ImmutableImage generate(final List samples) {
  try {
    final DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    for (int i = 0; i < samples.size(); i++) {
      final AgentStatusSample sample = (AgentStatusSample) samples.get(i);
      dataset.addValue(sample.getBusyCounter(), "Load", new ColumnKey(i));
    }

    final JFreeChart chart = ChartFactory.createLineChart(null,
            "Last 24 Hours", "Builds", dataset,
            PlotOrientation.VERTICAL,
            false, 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 LineAndShapeRenderer line = (LineAndShapeRenderer) plot.getRenderer();
    line.setSeriesPaint(0, Color.BLUE);
    line.setStroke(StatisticsUtils.DEFAULT_LINE_STROKE);

    // Write to byte array

    final ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection());
    final ByteArrayOutputStream out = new ByteArrayOutputStream(1000);
    ChartUtilities.writeChartAsPNG(out, chart, width, height, info);
    out.flush();
    out.close();

    // Return result
    return new ImmutableImage(out.toByteArray(), width, height);
  } catch (IOException e) {
    final ErrorManager errorManager = ErrorManagerFactory.getErrorManager();
    final Error error = new Error("Error generating agent status chart: " + StringUtils.toString(e), e);
    errorManager.reportSystemError(error);
    return ImmutableImage.ZERO_SIZE_IMAGE;
  }
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:49,代碼來源:AgentStatusChartGenerator.java

示例14: createChart

import org.jfree.chart.plot.CategoryPlot; //導入方法依賴的package包/類
/**
 * Creates a sample chart.
 * @param dataset  the dataset.
 * @return The chart.
 */
private JFreeChart createChart(CategoryDataset dataset) {
    // create the chart...
    JFreeChart chart = ChartFactory.createBarChart(
        "jaffa.sf.net 2005 Statistics",// chart title
        "Month",                  // domain axis label
        "Hits",                  // range axis label
        dataset,                  // data
        PlotOrientation.VERTICAL, // orientation
        true,                     // include legend
        true,                     // tooltips?
        false                     // URLs?
    );
 
    // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART...
 
    // set the background color for the chart...
    chart.setBackgroundPaint(Color.white);
 
    // get a reference to the plot for further customisation...
    CategoryPlot plot = chart.getCategoryPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setDomainGridlinesVisible(true);
    plot.setRangeGridlinePaint(Color.white);
 
    // set the range axis to display integers only...
    final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
 
    // disable bar outlines...
    BarRenderer renderer = (BarRenderer) plot.getRenderer();
    renderer.setDrawBarOutline(false);
 
    // set up gradient paints for series...
    GradientPaint gp0 = new GradientPaint(
        0.0f, 0.0f, Color.blue,
        0.0f, 0.0f, new Color(0, 0, 64)
    );
    GradientPaint gp1 = new GradientPaint(
        0.0f, 0.0f, Color.green,
        0.0f, 0.0f, new Color(0, 64, 0)
    );
    GradientPaint gp2 = new GradientPaint(
        0.0f, 0.0f, Color.red,
        0.0f, 0.0f, new Color(64, 0, 0)
    );
    renderer.setSeriesPaint(0, gp0);
    renderer.setSeriesPaint(1, gp1);
    renderer.setSeriesPaint(2, gp2);
 
    CategoryAxis domainAxis = plot.getDomainAxis();
    domainAxis.setCategoryLabelPositions(
        CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0)
    );
    // OPTIONAL CUSTOMISATION COMPLETED.
 
    return chart;
}
 
開發者ID:jaffa-projects,項目名稱:jaffa-framework,代碼行數:64,代碼來源:ImageDom.java

示例15: getDomainAxis

import org.jfree.chart.plot.CategoryPlot; //導入方法依賴的package包/類
/**
 * Returns a domain axis for a plot.
 * 
 * @param plot  the plot.
 * @param index  the axis index.
 * 
 * @return A domain axis.
 */
protected CategoryAxis getDomainAxis(CategoryPlot plot, int index) {
    CategoryAxis result = plot.getDomainAxis(index);
    if (result == null) {
        result = plot.getDomainAxis();
    }
    return result;
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:16,代碼來源:AbstractCategoryItemRenderer.java


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