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

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

Introduction

In this page you can find the example usage for org.jfree.chart.renderer.category StackedBarRenderer 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.StackedBarChartDemo3.java

/**
 * Creates a sample chart./*from   w  w  w .ja  v a2 s .  c  o  m*/
 * 
 * @param dataset  the dataset for the chart.
 * 
 * @return a sample chart.
 */
protected JFreeChart createChart(CategoryDataset dataset) {

    JFreeChart chart = ChartFactory.createStackedBarChart(chartTitle, // chart title
            domainLabel, // domain axis label
            rangeLabel, // range axis label
            dataset, // data
            PlotOrientation.VERTICAL, // the plot orientation
            !legendPanelOn, // legend
            false, // tooltips
            false // urls
    );
    CategoryPlot plot = chart.getCategoryPlot();
    CategoryItemRenderer renderer = new ExtendedStackedBarRenderer();
    renderer.setBaseItemLabelsVisible(true);
    renderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());
    renderer.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator());
    plot.setRenderer(renderer);

    ValueAxis rangeAxis = plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    rangeAxis.setLowerMargin(0.15);
    rangeAxis.setUpperMargin(0.15);

    StackedBarRenderer renderer2 = (StackedBarRenderer) plot.getRenderer();
    renderer2.setLegendItemLabelGenerator(new SOCRCategorySeriesLabelGenerator());

    setCategorySummary(dataset);
    return chart;

}

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

/**
 * Creates a sample chart./* w w  w.j  a  v a  2 s. c o m*/
 * 
 * @param dataset  the dataset.
 * 
 * @return a sample chart.
 */
protected JFreeChart createChart(CategoryDataset dataset) {

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

    /*  CategoryPlot plot = (CategoryPlot) chart.getPlot();
      StackedBarRenderer renderer = (StackedBarRenderer) plot.getRenderer();
      renderer.setItemLabelsVisible(true);*/

    CategoryPlot plot = chart.getCategoryPlot();
    CategoryItemRenderer renderer = new ExtendedStackedBarRenderer();
    renderer.setBaseItemLabelsVisible(true);
    renderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());
    renderer.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator());
    plot.setRenderer(renderer);

    ValueAxis rangeAxis = plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    rangeAxis.setLowerMargin(0.15);
    rangeAxis.setUpperMargin(0.15);

    StackedBarRenderer renderer2 = (StackedBarRenderer) plot.getRenderer();
    renderer2.setLegendItemLabelGenerator(new SOCRCategorySeriesLabelGenerator());

    setCategorySummary(dataset);
    return chart;
}

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

/**
 * Creates a sample chart.//from   w  ww  .  j a  va  2 s  .c  o  m
 * 
 * @param dataset  the dataset for the chart.
 * 
 * @return a sample chart.
 */
protected JFreeChart createChart(CategoryDataset dataset) {

    JFreeChart chart = ChartFactory.createStackedBarChart(chartTitle, // chart title
            domainLabel, // domain axis label
            rangeLabel, // range axis label
            dataset, // data
            PlotOrientation.VERTICAL, // the plot orientation
            !legendPanelOn, // legend
            true, // tooltips
            false // urls
    );
    chart.setBackgroundPaint(Color.white);
    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setRangeGridlinePaint(Color.white);

    StackedBarRenderer renderer = (StackedBarRenderer) plot.getRenderer();
    renderer.setDrawBarOutline(false);
    renderer.setBaseItemLabelsVisible(true);
    renderer.setSeriesItemLabelGenerator(0, new StandardCategoryItemLabelGenerator());
    renderer.setLegendItemLabelGenerator(new SOCRCategorySeriesLabelGenerator());

    setCategorySummary(dataset);
    return chart;

}