Example usage for org.jfree.chart.renderer.category CategoryItemRenderer setSeriesItemLabelsVisible

List of usage examples for org.jfree.chart.renderer.category CategoryItemRenderer setSeriesItemLabelsVisible

Introduction

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

Prototype

public void setSeriesItemLabelsVisible(int series, Boolean visible);

Source Link

Document

Sets a flag that controls the visibility of the item labels for a series.

Usage

From source file:com.mergano.core.GraphChart.java

private JFreeChart createChart(final CategoryDataset dataset) {

    final JFreeChart chart = ChartFactory.createBarChart("Revenue", "Monthly", "Amount", dataset,
            PlotOrientation.VERTICAL, false, true, false);

    // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART...
    // set the background color for the chart...
    chart.setBackgroundPaint(Color.white);

    // get a reference to the plot for further customisation...
    final CategoryPlot plot = chart.getCategoryPlot();
    plot.setBackgroundPaint(Color.white);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);

    // set the range axis to display integers only...
    final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    rangeAxis.setUpperMargin(0.15);/*w  w  w .j ava 2 s.c o  m*/

    // disable bar outlines...
    final CategoryItemRenderer renderer = plot.getRenderer();
    renderer.setSeriesItemLabelsVisible(0, Boolean.TRUE);

    final CategoryAxis domainAxis = plot.getDomainAxis();
    domainAxis.setCategoryLabelPositions(CategoryLabelPositions.DOWN_90);

    return chart;

}

From source file:j2se.jfreechart.barchart.BarChartDemo8.java

/**
 * Creates a sample chart./* w  w  w  .  j  a  va2 s . c o m*/
 * 
 * @param dataset  the dataset.
 * 
 * @return The chart.
 */
private JFreeChart createChart(final CategoryDataset dataset) {

    // create the chart...
    final JFreeChart chart = ChartFactory.createBarChart("Bar Chart Demo 8", // chart title
            "Category", // domain axis label
            "Value", // range axis label
            dataset, // data
            PlotOrientation.VERTICAL, // orientation
            false, // include legend
            true, // tooltips?
            false // URLs?
    );

    // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART...

    // set the background color for the chart...
    chart.setBackgroundPaint(Color.white);

    // get a reference to the plot for further customisation...
    final CategoryPlot plot = chart.getCategoryPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);

    // set the range axis to display integers only...
    final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    rangeAxis.setUpperMargin(0.15);

    // disable bar outlines...
    final CategoryItemRenderer renderer = plot.getRenderer();
    renderer.setSeriesItemLabelsVisible(0, Boolean.TRUE);

    final CategoryAxis domainAxis = plot.getDomainAxis();
    domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45);

    // OPTIONAL CUSTOMISATION COMPLETED.

    return chart;

}

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

/**
 * Creates a sample chart./*from w  w  w  . ja  va2s . com*/
 * 
 * @param dataset  the dataset.
 * 
 * @return The chart.
 */
protected JFreeChart createChart(CategoryDataset dataset) {

    // create the chart...
    JFreeChart chart = ChartFactory.createBarChart(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);

    // get a reference to the plot for further customisation...
    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setRangeGridlinePaint(Color.white);

    // set the range axis to display integers only...
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    rangeAxis.setUpperMargin(0.15);

    CategoryItemRenderer renderer = plot.getRenderer();
    renderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());
    renderer.setSeriesItemLabelsVisible(0, Boolean.TRUE);

    CategoryAxis domainAxis = plot.getDomainAxis();
    domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45);

    BarRenderer seriesRenderer = (BarRenderer) plot.getRenderer();
    seriesRenderer.setLegendItemLabelGenerator(new SOCRCategorySeriesLabelGenerator());

    setCategorySummary(dataset);
    return chart;

}

From source file:view.tabtables.EmulationTablesDrawer.java

protected void graphsInitialize() {
    JPanel panel;/*from  ww w .  ja v a2 s.c o m*/
    JFreeChart chart;

    frequencyDataset = new DefaultCategoryDataset();
    chart = ChartFactory.createBarChart("Frequency", // chart title
            "Marking", // domain axis label
            "Value", // range axis label
            frequencyDataset, // data
            PlotOrientation.VERTICAL, // orientation
            false, // include legend
            true, // tooltips?
            false // URLs?
    );
    CategoryPlot plot = chart.getCategoryPlot();
    CategoryItemRenderer renderer = plot.getRenderer();
    renderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());
    renderer.setSeriesItemLabelsVisible(0, Boolean.TRUE);
    panel = new ChartPanel(chart, false);
    add(panel);

    timeAvgDataset = new DefaultCategoryDataset();
    chart = ChartFactory.createBarChart("Avg Time", // chart title
            "Marking", // domain axis label
            "Value", // range axis label
            timeAvgDataset, // data
            PlotOrientation.VERTICAL, // orientation
            false, // include legend
            true, // tooltips?
            false // URLs?
    );
    plot = chart.getCategoryPlot();
    renderer = plot.getRenderer();
    renderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());
    renderer.setSeriesItemLabelsVisible(0, Boolean.TRUE);
    panel = new ChartPanel(chart, false);
    add(panel);

    timeAvgReturnDataset = new DefaultCategoryDataset();
    chart = ChartFactory.createBarChart("Avg Return Time", // chart title
            "Marking", // domain axis label
            "Value", // range axis label
            timeAvgReturnDataset, // data
            PlotOrientation.VERTICAL, // orientation
            false, // include legend
            true, // tooltips?
            false // URLs?
    );
    plot = chart.getCategoryPlot();
    renderer = plot.getRenderer();
    renderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());
    renderer.setSeriesItemLabelsVisible(0, Boolean.TRUE);
    panel = new ChartPanel(chart, false);
    add(panel);

    probabilityDataset = new DefaultCategoryDataset();
    chart = ChartFactory.createBarChart("Probability", // chart title
            "Marking", // domain axis label
            "Value", // range axis label
            probabilityDataset, // data
            PlotOrientation.VERTICAL, // orientation
            false, // include legend
            true, // tooltips?
            false // URLs?
    );
    plot = chart.getCategoryPlot();
    renderer = plot.getRenderer();
    renderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());
    renderer.setSeriesItemLabelsVisible(0, Boolean.TRUE);
    panel = new ChartPanel(chart, false);
    add(panel);
}

From source file:de.dekarlab.moneybuilder.view.AnalyticsView.java

/**
 * Create pie chart./* ww w . j  a va 2 s . c  om*/
 * 
 * @param dataset
 * @param title
 * @return
 */
protected JFreeChart createBarChart(final CategoryDataset dataset, final String title) {
    final JFreeChart chart = ChartFactory.createBarChart("", // chart title
            App.getGuiProp("report.period.lbl"), // domain axis label
            App.getGuiProp("report.value.lbl"), // range axis label
            dataset, // data
            PlotOrientation.VERTICAL, // orientation
            false, // include legend
            true, // tooltips
            false // urls
    );

    final CategoryPlot plot = (CategoryPlot) chart.getPlot();
    plot.setNoDataMessage(App.getGuiProp("report.nodata.msg"));
    plot.setBackgroundPaint(Color.white);
    ((NumberAxis) plot.getRangeAxis()).setAutoRangeIncludesZero(false);
    ((CategoryAxis) plot.getDomainAxis()).setMaximumCategoryLabelLines(10);
    ((CategoryAxis) plot.getDomainAxis()).setCategoryLabelPositions(CategoryLabelPositions.DOWN_90);
    plot.setDomainGridlinesVisible(true);
    plot.setDomainGridlinePaint(Color.gray);
    plot.setRangeGridlinePaint(Color.gray);
    plot.setRangeGridlinesVisible(true);
    plot.setRangeZeroBaselinePaint(Color.black);
    plot.setRangeZeroBaselineVisible(true);
    int color = 0;
    ((BarRenderer) plot.getRenderer()).setBarPainter(new StandardBarPainter());
    CategoryItemRenderer renderer = plot.getRenderer();
    for (int ser = 0; ser < dataset.getColumnCount(); ser++) {
        renderer.setSeriesPaint(ser, COLORS[color]);
        renderer.setSeriesItemLabelGenerator(ser,
                new StandardCategoryItemLabelGenerator("{2}", NumberFormat.getInstance(Locale.GERMAN)));
        renderer.setSeriesItemLabelsVisible(ser, true);
        color++;
        if (COLORS.length == color) {
            color = 0;
        }
    }
    return chart;
}

From source file:de.dekarlab.moneybuilder.view.AnalyticsView.java

/**
 * Create pie chart./*from w ww.  j  a  va 2 s.com*/
 * 
 * @param dataset
 * @param title
 * @return
 */
protected JFreeChart createLineChart(final CategoryDataset dataset, final String title) {
    final JFreeChart chart = ChartFactory.createLineChart("", // chart title
            App.getGuiProp("report.period.lbl"), // domain axis label
            App.getGuiProp("report.value.lbl"), // range axis label
            dataset, // data
            PlotOrientation.VERTICAL, // orientation
            true, // include legend
            true, // tooltips
            false // urls
    );
    final CategoryPlot plot = (CategoryPlot) chart.getPlot();
    plot.setNoDataMessage(App.getGuiProp("report.nodata.msg"));
    plot.setBackgroundPaint(Color.white);
    plot.setBackgroundPaint(Color.white);
    ((NumberAxis) plot.getRangeAxis()).setAutoRangeIncludesZero(false);
    ((CategoryAxis) plot.getDomainAxis()).setMaximumCategoryLabelLines(10);
    ((CategoryAxis) plot.getDomainAxis()).setCategoryLabelPositions(CategoryLabelPositions.DOWN_90);
    plot.setDomainGridlinesVisible(true);
    plot.setDomainGridlinePaint(Color.gray);
    plot.setRangeGridlinePaint(Color.gray);
    plot.setRangeGridlinesVisible(true);
    plot.setRangeZeroBaselinePaint(Color.black);
    plot.setRangeZeroBaselineVisible(true);
    int color = 0;
    CategoryItemRenderer renderer = plot.getRenderer();
    for (int ser = 0; ser < dataset.getColumnCount(); ser++) {
        renderer.setSeriesPaint(ser, COLORS[color]);
        renderer.setSeriesStroke(ser, new BasicStroke(4));
        StandardCategoryItemLabelGenerator gen = new StandardCategoryItemLabelGenerator("{2}",
                NumberFormat.getInstance(Locale.GERMAN)) {
            private static final long serialVersionUID = 1L;

            public String generateLabel(CategoryDataset dataset, int series, int item) {
                if (item % 3 == 0) {
                    return super.generateLabelString(dataset, series, item);
                } else {
                    return null;
                }
            }
        };

        renderer.setSeriesItemLabelGenerator(ser, gen);
        renderer.setSeriesItemLabelsVisible(ser, true);

        color++;
        if (COLORS.length == color) {
            color = 0;
        }
    }
    return chart;
}