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

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

Introduction

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

Prototype

public void setLegendItemLabelGenerator(CategorySeriesLabelGenerator generator) 

Source Link

Document

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

Usage

From source file:edu.ucla.stat.SOCR.chart.demo.StatisticalBarChartDemo2.java

/**
 * Creates a sample chart./*from w  ww . j  a  v a2 s  . com*/
 * 
 * @param dataset  a dataset.
 * 
 * @return The chart.
 */
protected JFreeChart createChart(CategoryDataset dataset) {

    // create the chart...
    JFreeChart chart = ChartFactory.createLineChart(chartTitle, // chart title
            domainLabel, // domain axis label
            rangeLabel, // range axis label
            dataset, // data
            PlotOrientation.VERTICAL, // orientation
            !legendPanelOn, // include legend
            true, // tooltips
            false // urls
    );

    chart.setBackgroundPaint(Color.white);

    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setRangeGridlinePaint(Color.white);

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

    // customise the renderer...
    StatisticalBarRenderer renderer = new StatisticalBarRenderer();
    renderer.setErrorIndicatorPaint(Color.black);
    renderer.setLegendItemLabelGenerator(
            new SOCRCategoryCellLabelGenerator(dataset, values_storage, SERIES_COUNT, CATEGORY_COUNT));
    plot.setRenderer(renderer);

    // OPTIONAL CUSTOMISATION COMPLETED.
    return chart;
}

From source file:edu.ucla.stat.SOCR.chart.SuperCategoryChart_Stat_Raw.java

protected JFreeChart createLegend(CategoryDataset dataset) {

    //  JFreeChart chart = ChartFactory.createAreaChart(
    JFreeChart chart = ChartFactory.createLineChart(chartTitle, // chart title
            domainLabel, // domain axis label
            rangeLabel, // range axis label
            dataset, // data
            PlotOrientation.VERTICAL, // orientation
            true, // include legend
            true, // tooltips
            false // urls
    );//from w w  w . ja v a 2 s  .  com

    // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART...
    chart.setBackgroundPaint(Color.white);
    CategoryPlot plot = chart.getCategoryPlot();

    StatisticalBarRenderer renderer = new StatisticalBarRenderer();
    renderer.setErrorIndicatorPaint(Color.black);
    renderer.setLegendItemLabelGenerator(
            new SOCRCategoryCellLabelGenerator(dataset, values_storage, SERIES_COUNT, CATEGORY_COUNT));
    plot.setRenderer(renderer);
    return chart;

}