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

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

Introduction

In this page you can find the example usage for org.jfree.chart.renderer.category StatisticalLineAndShapeRenderer 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.StatisticalLineChartDemo2.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.  j  av a 2s . c om*/

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

    StatisticalLineAndShapeRenderer renderer = new StatisticalLineAndShapeRenderer(true, false);
    renderer.setLegendItemLabelGenerator(
            new SOCRCategoryCellLabelGenerator(dataset, values_storage, SERIES_COUNT, CATEGORY_COUNT));
    plot.setRenderer(renderer);
    return chart;

}

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

/**
 * Creates a sample chart.//from   w ww. ja va2  s. c o m
 * 
 * @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
    );

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

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

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

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

    // customise the renderer...
    StatisticalLineAndShapeRenderer renderer = new StatisticalLineAndShapeRenderer(true, false);
    renderer.setLegendItemLabelGenerator(
            new SOCRCategoryCellLabelGenerator(dataset, values_storage, SERIES_COUNT, CATEGORY_COUNT));
    plot.setRenderer(renderer);

    // OPTIONAL CUSTOMISATION COMPLETED.
    return chart;
}