当前位置: 首页>>代码示例>>Java>>正文


Java CategoryAxis.setCategoryLabelPositions方法代码示例

本文整理汇总了Java中org.jfree.chart.axis.CategoryAxis.setCategoryLabelPositions方法的典型用法代码示例。如果您正苦于以下问题:Java CategoryAxis.setCategoryLabelPositions方法的具体用法?Java CategoryAxis.setCategoryLabelPositions怎么用?Java CategoryAxis.setCategoryLabelPositions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.jfree.chart.axis.CategoryAxis的用法示例。


在下文中一共展示了CategoryAxis.setCategoryLabelPositions方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createCategoryDomainAxis

import org.jfree.chart.axis.CategoryAxis; //导入方法依赖的package包/类
public static CategoryAxis createCategoryDomainAxis(PlotConfiguration plotConfiguration) {
	CategoryAxis domainAxis = new CategoryAxis(null);
	String label = plotConfiguration.getDomainConfigManager().getLabel();
	if (label == null) {
		label = I18N.getGUILabel("plotter.unnamed_value_label");
	}
	domainAxis.setLabel(label);

	Font axesFont = plotConfiguration.getAxesFont();
	if (axesFont != null) {
		domainAxis.setLabelFont(axesFont);
		domainAxis.setTickLabelFont(axesFont);
	}

	// rotate labels
	if (plotConfiguration.getOrientation() != PlotOrientation.HORIZONTAL) {
		domainAxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 2.0d));
	}

	formatAxis(plotConfiguration, domainAxis);
	return domainAxis;
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:23,代码来源:ChartAxisFactory.java

示例2: createChart

import org.jfree.chart.axis.CategoryAxis; //导入方法依赖的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

示例3: addChart

import org.jfree.chart.axis.CategoryAxis; //导入方法依赖的package包/类
/**
 * It creates a chart for the given dataset and adds the chart to the panel.
 *
 * @param dataset The dataset that will provide the values for the chart.
 */
private void addChart() {
    JFreeChart chart = ChartFactory.createStackedBarChart3D(
            getTitle(), null, "Breakdown" + unitSuffix(),
            dataset, PlotOrientation.VERTICAL, true, true, false);
    CategoryAxis domainAxis = chart.getCategoryPlot().getDomainAxis();
    domainAxis.setCategoryLabelPositions(
            CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0));
    chart.addProgressListener(locker);
    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    CategoryItemRenderer renderer = plot.getRenderer();
    renderer.setToolTipGenerator(dataset);
    
    mainPanel().add(BorderLayout.CENTER, new ChartPanel(chart));
}
 
开发者ID:vimerzhao,项目名称:gchisto,代码行数:20,代码来源:BreakdownChartPanelMulti.java

示例4: testEquals

import org.jfree.chart.axis.CategoryAxis; //导入方法依赖的package包/类
/**
 * Confirm that the equals method can distinguish all the required fields.
 */
public void testEquals() {
    
    CategoryAxis a1 = new CategoryAxis("Test");
    CategoryAxis a2 = new CategoryAxis("Test");
    assertTrue(a1.equals(a2));
    
    // lowerMargin 
    a1.setLowerMargin(0.15);
    assertFalse(a1.equals(a2));
    a2.setLowerMargin(0.15);
    assertTrue(a1.equals(a2));

    // upperMargin 
    a1.setUpperMargin(0.15);
    assertFalse(a1.equals(a2));
    a2.setUpperMargin(0.15);
    assertTrue(a1.equals(a2));
  
    // categoryMargin 
    a1.setCategoryMargin(0.15);
    assertFalse(a1.equals(a2));
    a2.setCategoryMargin(0.15);
    assertTrue(a1.equals(a2));
    
    // maxCategoryLabelWidthRatio
    a1.setMaximumCategoryLabelWidthRatio(0.98f);
    assertFalse(a1.equals(a2));
    a2.setMaximumCategoryLabelWidthRatio(0.98f);
    assertTrue(a1.equals(a2));
    
    // categoryLabelPositionOffset
    a1.setCategoryLabelPositionOffset(11);
    assertFalse(a1.equals(a2));
    a2.setCategoryLabelPositionOffset(11);
    assertTrue(a1.equals(a2));
    
    // categoryLabelPositions
    a1.setCategoryLabelPositions(CategoryLabelPositions.DOWN_45);
    assertFalse(a1.equals(a2));
    a2.setCategoryLabelPositions(CategoryLabelPositions.DOWN_45);
    assertTrue(a1.equals(a2));
    
    // categoryLabelToolTips
    a1.addCategoryLabelToolTip("Test", "Check");
    assertFalse(a1.equals(a2));
    a2.addCategoryLabelToolTip("Test", "Check");
    assertTrue(a1.equals(a2));
    
    // tickLabelFont
    a1.setTickLabelFont("C1", new Font("Dialog", Font.PLAIN, 21));
    assertFalse(a1.equals(a2));
    a2.setTickLabelFont("C1", new Font("Dialog", Font.PLAIN, 21));
    assertTrue(a1.equals(a2));
    
    // tickLabelPaint
    a1.setTickLabelPaint("C1", Color.red);
    assertFalse(a1.equals(a2));
    a2.setTickLabelPaint("C1", Color.red);
    assertTrue(a1.equals(a2));

    // tickLabelPaint2
    a1.setTickLabelPaint("C1", new GradientPaint(1.0f, 2.0f, Color.red, 
            3.0f, 4.0f, Color.yellow));
    assertFalse(a1.equals(a2));
    a2.setTickLabelPaint("C1", new GradientPaint(1.0f, 2.0f, Color.red, 
            3.0f, 4.0f, Color.yellow));
    assertTrue(a1.equals(a2));

}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:73,代码来源:CategoryAxisTests.java

示例5: createChart

import org.jfree.chart.axis.CategoryAxis; //导入方法依赖的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

示例6: createChart

import org.jfree.chart.axis.CategoryAxis; //导入方法依赖的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

示例7: createTestsResultsChartHelper

import org.jfree.chart.axis.CategoryAxis; //导入方法依赖的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

示例8: createRecentBuildTimesChart

import org.jfree.chart.axis.CategoryAxis; //导入方法依赖的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

示例9: createChart

import org.jfree.chart.axis.CategoryAxis; //导入方法依赖的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

示例10: testEquals

import org.jfree.chart.axis.CategoryAxis; //导入方法依赖的package包/类
/**
 * Confirm that the equals method can distinguish all the required fields.
 */
public void testEquals() {
    
    CategoryAxis a1 = new CategoryAxis("Test");
    CategoryAxis a2 = new CategoryAxis("Test");
    assertTrue(a1.equals(a2));
    
    // lowerMargin 
    a1.setLowerMargin(0.15);
    assertFalse(a1.equals(a2));
    a2.setLowerMargin(0.15);
    assertTrue(a1.equals(a2));

    // upperMargin 
    a1.setUpperMargin(0.15);
    assertFalse(a1.equals(a2));
    a2.setUpperMargin(0.15);
    assertTrue(a1.equals(a2));
  
    // categoryMargin 
    a1.setCategoryMargin(0.15);
    assertFalse(a1.equals(a2));
    a2.setCategoryMargin(0.15);
    assertTrue(a1.equals(a2));
    
    // maxCategoryLabelWidthRatio
    a1.setMaxCategoryLabelWidthRatio(0.98f);
    assertFalse(a1.equals(a2));
    a2.setMaxCategoryLabelWidthRatio(0.98f);
    assertTrue(a1.equals(a2));
    
    // categoryLabelPositionOffset
    a1.setCategoryLabelPositionOffset(11);
    assertFalse(a1.equals(a2));
    a2.setCategoryLabelPositionOffset(11);
    assertTrue(a1.equals(a2));
    
    // categoryLabelPositions
    a1.setCategoryLabelPositions(CategoryLabelPositions.DOWN_45);
    assertFalse(a1.equals(a2));
    a2.setCategoryLabelPositions(CategoryLabelPositions.DOWN_45);
    assertTrue(a1.equals(a2));
    
    // categoryLabelToolTips
    a1.addCategoryLabelToolTip("Test", "Check");
    assertFalse(a1.equals(a2));
    a2.addCategoryLabelToolTip("Test", "Check");
    assertTrue(a1.equals(a2));
    
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:53,代码来源:CategoryAxisTests.java

示例11: createChart

import org.jfree.chart.axis.CategoryAxis; //导入方法依赖的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

示例12: createChart

import org.jfree.chart.axis.CategoryAxis; //导入方法依赖的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

示例13: createBuildResultsBarChart

import org.jfree.chart.axis.CategoryAxis; //导入方法依赖的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

示例14: createChangeListsBarChart

import org.jfree.chart.axis.CategoryAxis; //导入方法依赖的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

示例15: generate

import org.jfree.chart.axis.CategoryAxis; //导入方法依赖的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


注:本文中的org.jfree.chart.axis.CategoryAxis.setCategoryLabelPositions方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。