Example usage for org.jfree.chart.renderer.category StatisticalBarRenderer setBaseItemLabelGenerator

List of usage examples for org.jfree.chart.renderer.category StatisticalBarRenderer setBaseItemLabelGenerator

Introduction

In this page you can find the example usage for org.jfree.chart.renderer.category StatisticalBarRenderer setBaseItemLabelGenerator.

Prototype

@Override
public void setBaseItemLabelGenerator(CategoryItemLabelGenerator generator) 

Source Link

Document

Sets the base item label generator and sends a RendererChangeEvent to all registered listeners.

Usage

From source file:org.jfree.chart.demo.StatisticalBarChartDemo1.java

private static JFreeChart createChart(CategoryDataset categorydataset) {
    JFreeChart jfreechart = ChartFactory.createLineChart("Statistical Bar Chart Demo 1", "Type", "Value",
            categorydataset, PlotOrientation.VERTICAL, true, true, false);
    jfreechart.setBackgroundPaint(Color.white);
    CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot();
    categoryplot.setBackgroundPaint(Color.lightGray);
    categoryplot.setRangeGridlinePaint(Color.white);
    NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis();
    numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    numberaxis.setAutoRangeIncludesZero(false);
    StatisticalBarRenderer statisticalbarrenderer = new StatisticalBarRenderer();
    statisticalbarrenderer.setErrorIndicatorPaint(Color.black);
    statisticalbarrenderer.setIncludeBaseInRange(false);
    categoryplot.setRenderer(statisticalbarrenderer);
    statisticalbarrenderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());
    statisticalbarrenderer.setBaseItemLabelsVisible(true);
    statisticalbarrenderer.setBasePositiveItemLabelPosition(
            new ItemLabelPosition(ItemLabelAnchor.INSIDE6, TextAnchor.BOTTOM_CENTER));
    return jfreechart;
}

From source file:com.orsonpdf.demo.PDFBarChartDemo1.java

/**
 * Creates a sample chart./*w  w  w. j ava 2 s . c  o m*/
 *
 * @param dataset  a dataset.
 *
 * @return The chart.
 */
private static JFreeChart createChart(CategoryDataset dataset) {

    // create the chart...
    JFreeChart chart = ChartFactory.createLineChart("Statistical Bar Chart Demo 1", "Type", "Value", dataset,
            PlotOrientation.VERTICAL, true, false, false);

    CategoryPlot plot = (CategoryPlot) chart.getPlot();

    // customise the range axis...
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    rangeAxis.setAutoRangeIncludesZero(false);

    // customise the renderer...
    StatisticalBarRenderer renderer = new StatisticalBarRenderer();
    renderer.setDrawBarOutline(false);
    renderer.setErrorIndicatorPaint(Color.black);
    renderer.setIncludeBaseInRange(false);
    plot.setRenderer(renderer);

    // ensure the current theme is applied to the renderer just added
    ChartUtilities.applyCurrentTheme(chart);

    renderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());
    renderer.setBaseItemLabelsVisible(true);
    renderer.setBaseItemLabelPaint(Color.yellow);
    renderer.setBasePositiveItemLabelPosition(
            new ItemLabelPosition(ItemLabelAnchor.INSIDE6, TextAnchor.BOTTOM_CENTER));

    // 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));
    renderer.setSeriesPaint(0, gp0);
    renderer.setSeriesPaint(1, gp1);
    return chart;
}