Example usage for org.jfree.chart.renderer.category StackedBarRenderer3D setSeriesPaint

List of usage examples for org.jfree.chart.renderer.category StackedBarRenderer3D setSeriesPaint

Introduction

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

Prototype

public void setSeriesPaint(int series, Paint paint) 

Source Link

Document

Sets the paint used for a series and sends a RendererChangeEvent to all registered listeners.

Usage

From source file:org.sonar.plugins.scmstats.charts.StackedBarChart3D.java

private JFreeChart createChart(CategoryDataset categorydataset) {
    JFreeChart jfreechart = ChartFactory.createStackedBarChart3D(null, "Authors", "Activity", categorydataset,
            PlotOrientation.HORIZONTAL, true, true, false);
    CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot();

    NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis();
    numberaxis.setNumberFormatOverride(new DecimalFormat("0%"));

    StackedBarRenderer3D stackedbarrenderer3d = (StackedBarRenderer3D) categoryplot.getRenderer();
    stackedbarrenderer3d.setRenderAsPercentages(true);
    stackedbarrenderer3d.setDrawBarOutline(false);
    stackedbarrenderer3d.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator("{3}",
            NumberFormat.getIntegerInstance(), new DecimalFormat("0.0%")));
    stackedbarrenderer3d.setBaseItemLabelsVisible(true);
    stackedbarrenderer3d/* ww w.ja  v  a 2 s.  c  o m*/
            .setBasePositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER));
    stackedbarrenderer3d
            .setBaseNegativeItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER));

    stackedbarrenderer3d.setSeriesPaint(0, Color.decode("#66CD00"));
    stackedbarrenderer3d.setSeriesPaint(1, Color.decode("#4F94CD"));
    stackedbarrenderer3d.setSeriesPaint(2, Color.decode("#FF4040"));
    return jfreechart;
}