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

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

Introduction

In this page you can find the example usage for org.jfree.chart.renderer.category AreaRenderer 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:unikn.dbis.univis.visualization.chart.AreaChart.java

/**
 * Makes the plot./*from  w  w  w  .j  a  v a 2s .co m*/
 */
protected void plot() {
    CategoryPlot plot = (CategoryPlot) getChart().getPlot();
    CategoryAxis axis = plot.getDomainAxis();
    plot.setForegroundAlpha(0.5f);
    axis.setTickLabelsVisible(false);
    plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);
    AreaRenderer renderer = (AreaRenderer) plot.getRenderer();
    renderer.setLegendItemLabelGenerator(new LabelGenerator(createTotal()));
    plot.setNoDataMessage("No data available");
    plot.getDomainAxis().setLabelFont(getLegendFont());
    plot.getRangeAxis().setLabelFont(getLegendFont());
}

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

/**
 * Creates a sample chart./*from   ww w  .  j av a2s.c o  m*/
 * 
 * @param dataset  the dataset.
 * 
 * @return A sample chart.
 */
protected JFreeChart createChart(CategoryDataset dataset) {

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

    chart.setBackgroundPaint(Color.white);

    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    plot.setForegroundAlpha(0.85f);
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);

    CategoryAxis domainAxis = plot.getDomainAxis();
    domainAxis.setLowerMargin(0.0);
    domainAxis.setUpperMargin(0.0);

    // change the auto tick unit selection to integer units only...
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    CategoryItemRenderer renderer = plot.getRenderer();
    renderer.setBaseItemLabelsVisible(true);
    AreaRenderer renderer2 = (AreaRenderer) plot.getRenderer();
    renderer2.setLegendItemLabelGenerator(new SOCRCategorySeriesLabelGenerator());

    return chart;

}

From source file:edu.ucla.stat.SOCR.chart.demo.AreaChartDemo1.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 va  2 s .co m*/

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

    AreaRenderer renderer = (AreaRenderer) plot.getRenderer();
    renderer.setLegendItemLabelGenerator(new SOCRCategorySeriesLabelGenerator());
    return chart;

}

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

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

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

    // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART...
    chart.setBackgroundPaint(Color.white);
    if (isDemo) {
        TextTitle subtitle = new TextTitle("An area chart demonstration.  We use this subtitle as an "
                + "example of what happens when you get a really long title or " + "subtitle.");
        subtitle.setFont(new Font("SansSerif", Font.PLAIN, 12));
        subtitle.setPosition(RectangleEdge.TOP);
        subtitle.setPadding(new RectangleInsets(UnitType.RELATIVE, 0.05, 0.05, 0.05, 0.05));
        subtitle.setVerticalAlignment(VerticalAlignment.BOTTOM);
        chart.addSubtitle(subtitle);
    }

    CategoryPlot plot = chart.getCategoryPlot();
    plot.setForegroundAlpha(0.5f);

    plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinesVisible(true);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinesVisible(true);
    plot.setRangeGridlinePaint(Color.white);

    AreaRenderer renderer = (AreaRenderer) plot.getRenderer();
    renderer.setLegendItemLabelGenerator(new SOCRCategorySeriesLabelGenerator());

    CategoryAxis domainAxis = plot.getDomainAxis();
    domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45);
    domainAxis.setLowerMargin(0.0);
    domainAxis.setUpperMargin(0.0);
    if (isDemo) {
        domainAxis.addCategoryLabelToolTip("Type 1", "The first type.");
        domainAxis.addCategoryLabelToolTip("Type 2", "The second type.");
        domainAxis.addCategoryLabelToolTip("Type 3", "The third type.");
    }
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    rangeAxis.setLabelAngle(0 * Math.PI / 2.0);
    // OPTIONAL CUSTOMISATION COMPLETED.

    setCategorySummary(dataset);
    return chart;

}