Example usage for org.jfree.chart.axis CategoryAxis setVisible

List of usage examples for org.jfree.chart.axis CategoryAxis setVisible

Introduction

In this page you can find the example usage for org.jfree.chart.axis CategoryAxis setVisible.

Prototype

public void setVisible(boolean flag) 

Source Link

Document

Sets a flag that controls whether or not the axis is visible and sends an AxisChangeEvent to all registered listeners.

Usage

From source file:com.intel.stl.ui.common.view.ComponentFactory.java

@SuppressWarnings("unchecked")
public static JFreeChart createTopNBarChart2(String yAxisLabel, CategoryDataset dataset) {
    JFreeChart jfreechart = ChartFactory.createBarChart(null, null, yAxisLabel, dataset,
            PlotOrientation.HORIZONTAL, false, true, false);
    CategoryPlot categoryplot = jfreechart.getCategoryPlot();
    categoryplot.setBackgroundPaint(null);
    categoryplot.setOutlinePaint(null);/* www .ja v  a  2s.c o  m*/
    categoryplot.setDomainGridlinesVisible(true);
    categoryplot.setDomainGridlinePosition(CategoryAnchor.END);
    categoryplot.setDomainGridlineStroke(new BasicStroke(0.5F));
    categoryplot.setDomainGridlinePaint(UIConstants.INTEL_BORDER_GRAY);
    categoryplot.setRangeGridlinesVisible(false);
    categoryplot.clearRangeMarkers();
    CategoryAxis categoryaxis = categoryplot.getDomainAxis();
    categoryaxis.setVisible(false);
    categoryaxis.setCategoryMargin(0.75D);

    NumberAxis axis = (NumberAxis) categoryplot.getRangeAxis();
    axis.setRangeType(RangeType.POSITIVE);
    axis.setVisible(false);

    BarRenderer barrenderer = (BarRenderer) categoryplot.getRenderer();
    barrenderer.setShadowVisible(false);
    barrenderer.setSeriesPaint(0, UIConstants.INTEL_BLUE);
    barrenderer.setDrawBarOutline(false);
    barrenderer.setBaseItemLabelsVisible(true);
    barrenderer.setBaseItemLabelFont(UIConstants.H5_FONT);
    barrenderer.setBarPainter(new StandardBarPainter());

    List<String> names = dataset.getColumnKeys();
    for (String name : names) {
        CategoryTextAnnotation categorytextannotation = new CategoryTextAnnotation(name, name, 0.0D);
        categorytextannotation.setFont(UIConstants.H6_FONT);
        categorytextannotation.setTextAnchor(TextAnchor.BOTTOM_LEFT);
        categorytextannotation.setCategoryAnchor(CategoryAnchor.MIDDLE);
        categoryplot.addAnnotation(categorytextannotation);
    }
    return jfreechart;
}

From source file:org.squale.squaleweb.util.graph.RepartitionMaker.java

/**
 * @return le diagramme JFreeChart/*from   w ww  . j av a  2 s.c o  m*/
 */
public JFreeChart getChart() {
    JFreeChart retChart = super.getChart();
    if (null == retChart) {
        retChart = ChartFactory.createBarChart3D(mTitle, mXLabel, mYLabel, mDataSet, PlotOrientation.VERTICAL,
                false, true, true);
        CategoryPlot plot = retChart.getCategoryPlot();
        CategoryAxis xAxis = plot.getDomainAxis();
        xAxis.setAxisLineVisible(true);
        xAxis.setVisible(true);
        ValueAxis yAxis = plot.getRangeAxis();
        yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
        // On rajoute 5% pour avoir une meilleure lisibilit
        final double YAxisCoeff = 1.05;
        yAxis.setRange(PracticeResultBO.REFUSED_MIN, Math.max(mMaxValue * YAxisCoeff, 1));

        // Positionne les couleurs et les liens
        mRenderer = (CategoryItemRenderer) plot.getRenderer();
        RepartitionUrlGenerator generator = new RepartitionUrlGenerator(mProjectId, mCurrentAuditId,
                mPreviousAuditId, mPracticeId, mFactorParentId, NB_SERIES_FOR_FLOAT_GRAPH);
        mRenderer.setItemURLGenerator(generator);
        BarRenderer barRenderer = (BarRenderer) mRenderer;
        barRenderer.setBaseSeriesVisible(true);
        RepartitionToolTipGenerator toolTipGenerator = new RepartitionToolTipGenerator();
        barRenderer.setToolTipGenerator(toolTipGenerator);
        manageColor(NB_SERIES_FOR_FLOAT_GRAPH);
        retChart.setBackgroundPaint(Color.WHITE);
        super.setChart(retChart);
    }
    return retChart;
}

From source file:it.eng.spagobi.engines.chart.bo.charttypes.targetcharts.WinLose.java

@Override
public JFreeChart createChart(DatasetMap datasets) {
    logger.debug("IN");
    DefaultCategoryDataset dataset = (DefaultCategoryDataset) datasets.getDatasets().get("1");

    JFreeChart chart = ChartFactory.createBarChart(name, null, null, dataset, PlotOrientation.VERTICAL, legend,
            false, false);//from   ww  w  .j  a  v  a2 s  . c  om
    chart.setBorderVisible(false);
    chart.setBackgroundPaint(color);

    TextTitle title = setStyleTitle(name, styleTitle);
    chart.setTitle(title);
    if (subName != null && !subName.equals("")) {
        TextTitle subTitle = setStyleTitle(subName, styleSubTitle);
        chart.addSubtitle(subTitle);
    }

    CategoryPlot plot = chart.getCategoryPlot();
    plot.setOutlineVisible(false);
    plot.setInsets(new RectangleInsets(0.0, 0.0, 0.0, 0.0));
    plot.setBackgroundPaint(color);
    plot.setDomainGridlinesVisible(false);
    plot.setRangeGridlinesVisible(false);
    plot.setRangeCrosshairVisible(true);
    plot.setRangeCrosshairStroke(new BasicStroke(1f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL));
    plot.setRangeCrosshairPaint(color.BLACK);

    // customize axes 
    CategoryAxis domainAxis = plot.getDomainAxis();
    domainAxis.setVisible(false);
    domainAxis.setCategoryMargin(0.2);

    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setVisible(false);
    rangeAxis.setRange(new Range(-(barHeight + 0.2), (barHeight + 0.2)));

    // customize renderer 
    MyBarRendererThresholdPaint renderer = new MyBarRendererThresholdPaint(useTargets, thresholds, dataset,
            timeSeries, nullValues, bottomThreshold, color);

    if (wlt_mode.doubleValue() == 0) {
        renderer.setBaseItemLabelsVisible(Boolean.FALSE, true);
    } else {
        renderer.setBaseItemLabelsVisible(Boolean.TRUE, true);
        renderer.setBaseItemLabelFont(
                new Font(styleValueLabels.getFontName(), Font.PLAIN, styleValueLabels.getSize()));
        renderer.setBaseItemLabelPaint(styleValueLabels.getColor());
        renderer.setBaseItemLabelGenerator(
                new StandardCategoryItemLabelGenerator("{2}", new DecimalFormat("0.#")) {
                    public String generateLabel(CategoryDataset dataset, int row, int column) {
                        if (dataset.getValue(row, column) == null
                                || dataset.getValue(row, column).doubleValue() == 0)
                            return "";
                        String columnKey = (String) dataset.getColumnKey(column);
                        int separator = columnKey.indexOf('-');
                        String month = columnKey.substring(0, separator);
                        String year = columnKey.substring(separator + 1);
                        int monthNum = Integer.parseInt(month);
                        if (wlt_mode.doubleValue() >= 1 && wlt_mode.doubleValue() <= 4) {
                            if (wlt_mode.doubleValue() == 2 && column % 2 == 0)
                                return "";

                            Calendar calendar = Calendar.getInstance();
                            calendar.set(Calendar.MONTH, monthNum - 1);
                            SimpleDateFormat dataFormat = new SimpleDateFormat("MMM");
                            return dataFormat.format(calendar.getTime());
                        } else
                            return "" + monthNum;
                    }
                });
    }

    if (wlt_mode.doubleValue() == 3) {
        renderer.setBasePositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12,
                org.jfree.ui.TextAnchor.BOTTOM_CENTER, org.jfree.ui.TextAnchor.BOTTOM_RIGHT, Math.PI / 2));
        renderer.setBaseNegativeItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.OUTSIDE6,
                org.jfree.ui.TextAnchor.TOP_CENTER, org.jfree.ui.TextAnchor.HALF_ASCENT_LEFT, Math.PI / 2));

    } else if (wlt_mode.doubleValue() == 4 || wlt_mode.doubleValue() == 5) {
        renderer.setBasePositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12,
                org.jfree.ui.TextAnchor.BOTTOM_CENTER, org.jfree.ui.TextAnchor.BOTTOM_RIGHT, Math.PI / 4));
        renderer.setBaseNegativeItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.OUTSIDE6,
                org.jfree.ui.TextAnchor.TOP_CENTER, org.jfree.ui.TextAnchor.HALF_ASCENT_LEFT, Math.PI / 4));
    }

    if (legend == true) {
        LegendItemCollection collection = createThresholdLegend(plot);
        plot.setFixedLegendItems(collection);
    }

    if (maxBarWidth != null) {
        renderer.setMaximumBarWidth(maxBarWidth);
    }
    //renderer.setSeriesPaint(0, Color.BLUE); 
    plot.setRenderer(renderer);

    logger.debug("OUT");
    if (mainThreshold == null)
        return null;
    return chart;

}

From source file:uk.ac.lkl.cram.ui.chart.LearningExperienceChartMaker.java

/**
 * Create a chart from the provide category dataset
 * @return a Chart that can be rendered in a ChartPanel
 *///from  ww w .  j  a  v a  2  s.c om
@Override
protected JFreeChart createChart() {
    //Create a horizontal stacked bar chart from the chart factory, with no title, no axis labels, a legend, tooltips but no URLs
    JFreeChart chart = ChartFactory.createStackedBarChart(null, null, null, (CategoryDataset) dataset,
            PlotOrientation.HORIZONTAL, true, true, false);
    //Get the plot from the chart
    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    //Remove offsets from the plot
    plot.setInsets(RectangleInsets.ZERO_INSETS);
    plot.setAxisOffset(RectangleInsets.ZERO_INSETS);
    //Hide the range lines
    plot.setRangeGridlinesVisible(false);
    //Get the renderer for the plot
    StackedBarRenderer sbRenderer = (StackedBarRenderer) plot.getRenderer();
    //Set the painter for the renderer (nothing fancy)
    sbRenderer.setBarPainter(new StandardBarPainter());
    //sbRenderer.setItemMargin(0.5); //Makes no difference
    //reduces width of bar as proportion of overall width
    sbRenderer.setMaximumBarWidth(0.5);
    //Render the bars as percentages
    sbRenderer.setRenderAsPercentages(true);
    //Set the colours for the bars
    sbRenderer.setSeriesPaint(0, PERSONALISED_COLOR);
    sbRenderer.setSeriesPaint(1, SOCIAL_COLOR);
    sbRenderer.setSeriesPaint(2, ONE_SIZE_FOR_ALL_COLOR);
    //Set the tooltips to render percentages
    sbRenderer.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator() {

        @Override
        public String generateToolTip(CategoryDataset cd, int row, int column) {
            //Only interested in row, as there's only one column
            //TODO--really inefficient
            @SuppressWarnings("unchecked")
            List<Comparable> rows = cd.getRowKeys();
            Comparable columnKey = cd.getColumnKey(column);
            //Sum running total
            int total = 0;
            for (Comparable comparable : rows) {
                total += cd.getValue(comparable, columnKey).intValue();
            }
            //Get the value for the row (in our case the learning type)
            Comparable rowKey = cd.getRowKey(row);
            float value = cd.getValue(rowKey, columnKey).floatValue();
            //The tooltip is the value of the learning type divided by the total, expressed as a percentage
            @SuppressWarnings("StringBufferWithoutInitialCapacity")
            StringBuilder builder = new StringBuilder();
            builder.append("<html><center>");
            builder.append(cd.getRowKey(row));
            builder.append(" (");
            builder.append(FORMATTER.format(value / total));
            builder.append(")<br/>");
            builder.append("Double-click for more");
            return builder.toString();
        }
    });
    //Hide both axes
    CategoryAxis categoryAxis = plot.getDomainAxis();
    //categoryAxis.setCategoryMargin(0.5D);//Makes no difference
    categoryAxis.setVisible(false);
    NumberAxis numberAxis = (NumberAxis) plot.getRangeAxis();
    numberAxis.setVisible(false);
    return chart;
}

From source file:org.jfree.chart.demo.SurveyResultsDemo.java

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

    final JFreeChart chart = ChartFactory.createBarChart(null, // chart title
            null, // domain axis label
            null, // range axis label
            dataset, // data
            PlotOrientation.HORIZONTAL, // orientation
            false, // include legend
            true, false);

    chart.setBackgroundPaint(Color.white);

    final TextTitle title = new TextTitle("Figure 7 | I. Resources - The site offers users relevant, "
            + "informative and educational resources");
    title.setHorizontalAlignment(HorizontalAlignment.LEFT);
    title.setBackgroundPaint(Color.red);
    title.setPaint(Color.white);

    chart.setTitle(title);
    final CategoryPlot plot = (CategoryPlot) chart.getPlot();
    plot.setOutlinePaint(null);
    plot.setDomainGridlinesVisible(true);
    plot.setDomainGridlinePosition(CategoryAnchor.END);
    plot.setDomainGridlineStroke(new BasicStroke(0.5f));
    plot.setDomainGridlinePaint(Color.black);

    plot.setRangeGridlinesVisible(false);
    plot.clearRangeMarkers();

    final CategoryAxis domainAxis = plot.getDomainAxis();
    domainAxis.setVisible(false);
    domainAxis.setCategoryMargin(0.50);

    plot.getRangeAxis().setVisible(false);

    final CategoryItemRenderer renderer = plot.getRenderer();
    renderer.setSeriesPaint(0, new Color(0x9C, 0xA4, 0x4A));
    renderer.setOutlineStroke(null);
    renderer.setBaseOutlineStroke(null);

    renderer.setItemLabelsVisible(true);
    renderer.setItemLabelFont(new Font("SansSerif", Font.BOLD, 10));
    final ItemLabelPosition position = new ItemLabelPosition(ItemLabelAnchor.INSIDE3, TextAnchor.CENTER_RIGHT);
    renderer.setPositiveItemLabelPosition(position);

    final CategoryTextAnnotation a1 = new CategoryTextAnnotation("1. White papers are available.", "Category 1",
            0.0);
    a1.setFont(new Font("SansSerif", Font.BOLD, 12));
    a1.setTextAnchor(TextAnchor.BOTTOM_LEFT);
    a1.setCategoryAnchor(CategoryAnchor.START);
    plot.addAnnotation(a1);

    final CategoryTextAnnotation a2 = new CategoryTextAnnotation(
            "2. White papers enhance users " + "understanding of the firm and its expertise.", "Category 2",
            0.0);
    a2.setFont(new Font("SansSerif", Font.PLAIN, 12));
    a2.setTextAnchor(TextAnchor.BOTTOM_LEFT);
    a2.setCategoryAnchor(CategoryAnchor.START);
    plot.addAnnotation(a2);

    final CategoryTextAnnotation a3 = new CategoryTextAnnotation(
            "3. White papers are relevant to " + "the firm's prospects and clients.", "Category 3", 0.0);
    a3.setFont(new Font("SansSerif", Font.PLAIN, 12));
    a3.setTextAnchor(TextAnchor.BOTTOM_LEFT);
    a3.setCategoryAnchor(CategoryAnchor.START);
    plot.addAnnotation(a3);

    final CategoryTextAnnotation a4 = new CategoryTextAnnotation(
            "4. White papers are relevant to " + "the firm's positioning.", "Category 4", 0.0);
    a4.setFont(new Font("SansSerif", Font.PLAIN, 12));
    a4.setTextAnchor(TextAnchor.BOTTOM_LEFT);
    a4.setCategoryAnchor(CategoryAnchor.START);
    plot.addAnnotation(a4);

    final CategoryTextAnnotation a5 = new CategoryTextAnnotation("5. Case studies are available.", "Category 5",
            0.0);
    a5.setFont(new Font("SansSerif", Font.BOLD, 12));
    a5.setTextAnchor(TextAnchor.BOTTOM_LEFT);
    a5.setCategoryAnchor(CategoryAnchor.START);
    plot.addAnnotation(a5);

    final CategoryTextAnnotation a6 = new CategoryTextAnnotation(
            "6. Case studies enhance users " + "understanding of the firm and its expertise.", "Category 6",
            0.0);
    a6.setFont(new Font("SansSerif", Font.PLAIN, 12));
    a6.setTextAnchor(TextAnchor.BOTTOM_LEFT);
    a6.setCategoryAnchor(CategoryAnchor.START);
    plot.addAnnotation(a6);

    final CategoryTextAnnotation a7 = new CategoryTextAnnotation(
            "7. Case studies are relevant to " + "the firm's prospects and clients.", "Category 7", 0.0);
    a7.setFont(new Font("SansSerif", Font.PLAIN, 12));
    a7.setTextAnchor(TextAnchor.BOTTOM_LEFT);
    a7.setCategoryAnchor(CategoryAnchor.START);
    plot.addAnnotation(a7);

    final CategoryTextAnnotation a8 = new CategoryTextAnnotation(
            "8. White papers are relevant to the firm's positioning.", "Category 8", 0.0);
    a8.setFont(new Font("SansSerif", Font.PLAIN, 12));
    a8.setTextAnchor(TextAnchor.BOTTOM_LEFT);
    a8.setCategoryAnchor(CategoryAnchor.START);
    plot.addAnnotation(a8);

    final CategoryTextAnnotation a9 = new CategoryTextAnnotation("9. Case studies are available.", "Category 9",
            0.0);
    a9.setFont(new Font("SansSerif", Font.BOLD, 12));
    a9.setTextAnchor(TextAnchor.BOTTOM_LEFT);
    a9.setCategoryAnchor(CategoryAnchor.START);
    plot.addAnnotation(a9);

    final CategoryTextAnnotation a10 = new CategoryTextAnnotation(
            "10. Case studies enhance users " + "understanding of the firm and its expertise.", "Category 10",
            0.0);
    a10.setFont(new Font("SansSerif", Font.PLAIN, 12));
    a10.setTextAnchor(TextAnchor.BOTTOM_LEFT);
    a10.setCategoryAnchor(CategoryAnchor.START);
    plot.addAnnotation(a10);

    final CategoryTextAnnotation a11 = new CategoryTextAnnotation(
            "11. Case studies are relevant " + "to the firm's prospects and clients.", "Category 11", 0.0);
    a11.setFont(new Font("SansSerif", Font.PLAIN, 12));
    a11.setTextAnchor(TextAnchor.BOTTOM_LEFT);
    a11.setCategoryAnchor(CategoryAnchor.START);
    plot.addAnnotation(a11);

    final CategoryTextAnnotation a12 = new CategoryTextAnnotation(
            "12. White papers are relevant to the firm's positioning.", "Category 12", 0.0);
    a12.setFont(new Font("SansSerif", Font.PLAIN, 12));
    a12.setTextAnchor(TextAnchor.BOTTOM_LEFT);
    a12.setCategoryAnchor(CategoryAnchor.START);
    plot.addAnnotation(a12);

    final CategoryTextAnnotation a13 = new CategoryTextAnnotation(
            "13. Users can easily access " + "resources based on viewer interest.", "Category 13", 0.0);
    a13.setFont(new Font("SansSerif", Font.BOLD, 12));
    a13.setTextAnchor(TextAnchor.BOTTOM_LEFT);
    a13.setCategoryAnchor(CategoryAnchor.START);
    plot.addAnnotation(a13);

    final CategoryTextAnnotation a14 = new CategoryTextAnnotation(
            "14. Access to additional hyperlinks enhances users's ability to find relevant " + "information.",
            "Category 14", 0.0);
    a14.setFont(new Font("SansSerif", Font.BOLD, 12));
    a14.setTextAnchor(TextAnchor.BOTTOM_LEFT);
    a14.setCategoryAnchor(CategoryAnchor.START);
    plot.addAnnotation(a14);

    final CategoryTextAnnotation a15 = new CategoryTextAnnotation("15. OVERALL EFFECTIVENESS.", "Overall", 0.0);
    a15.setFont(new Font("SansSerif", Font.BOLD, 12));
    a15.setTextAnchor(TextAnchor.BOTTOM_LEFT);
    a15.setCategoryAnchor(CategoryAnchor.START);
    plot.addAnnotation(a15);

    return chart;

}

From source file:org.openfaces.component.chart.impl.plots.GridCategoryPlotAdapter.java

public GridCategoryPlotAdapter(CategoryDataset ds, AbstractCategoryItemRenderer renderer,
        GridChartView chartView) {//from   w ww . ja  v a 2s .com
    setDataset(ds);
    setRenderer(renderer);

    ChartAxis baseAxis = chartView.getBaseAxis();
    ChartAxis keyAxis = chartView.getKeyAxis();
    ChartAxis valueAxis = chartView.getValueAxis();
    ChartDomain showAxes = chartView.getShowAxes();
    if (showAxes == null) {
        showAxes = ChartDomain.BOTH;
        chartView.setShowAxes(showAxes);
    }
    boolean keyAxisVisible = showAxes.equals(ChartDomain.BOTH) || showAxes.equals(ChartDomain.KEY);
    boolean valueAxisVisible = showAxes.equals(ChartDomain.BOTH) || showAxes.equals(ChartDomain.VALUE);

    if (!(keyAxis instanceof ChartCategoryAxis))
        keyAxis = null;

    if (!(valueAxis instanceof ChartNumberAxis))
        valueAxis = null;

    CategoryAxis categoryAxis = chartView.isEnable3D()
            ? new CategoryAxis3DAdapter(chartView.getKeyAxisLabel(), keyAxisVisible,
                    (ChartCategoryAxis) keyAxis, baseAxis, chartView)
            : new CategoryAxisAdapter(chartView.getKeyAxisLabel(), keyAxisVisible, (ChartCategoryAxis) keyAxis,
                    baseAxis, chartView);
    NumberAxis numberAxis = chartView.isEnable3D()
            ? new NumberAxis3DAdapter(chartView.getValueAxisLabel(), valueAxisVisible,
                    (ChartNumberAxis) valueAxis, baseAxis, chartView)
            : new NumberAxisAdapter(chartView.getValueAxisLabel(), valueAxisVisible,
                    (ChartNumberAxis) valueAxis, baseAxis, chartView);

    if (ds == null) {
        categoryAxis.setVisible(false);
        numberAxis.setVisible(false);
    }

    setDomainAxis(categoryAxis);
    setRangeAxis(numberAxis);

    setOrientation(PropertiesConverter.toPlotOrientation(chartView.getOrientation()));

    addConfigurator(new PlotColorsConfigurator());
    addConfigurator(new PlotGridLinesConfigurator(ds));
    addConfigurator(new PlotSelectionConfigurator());

    configure(chartView);
}

From source file:org.sakaiproject.sitestats.impl.ServerWideReportManagerImpl.java

private byte[] createToolAnalysisChart(int width, int height) {
    CategoryDataset dataset = getToolAnalysisDataSet();

    if (dataset == null) {
        return generateNoDataChart(width, height);
    }//  ww w .  j  a v  a2 s  .  co  m

    JFreeChart chart = ChartFactory.createBarChart(null, // chart title
            null, // domain axis label
            null, // range axis label
            dataset, // data
            PlotOrientation.HORIZONTAL, // the plot orientation
            false, // legend
            false, // tooltips
            false // urls
    );

    // set background
    chart.setBackgroundPaint(parseColor(statsManager.getChartBackgroundColor()));

    // set chart border
    chart.setPadding(new RectangleInsets(10, 5, 5, 5));
    chart.setBorderVisible(true);
    chart.setBorderPaint(parseColor("#cccccc"));

    // set anti alias
    chart.setAntiAlias(true);

    CategoryPlot plot = (CategoryPlot) chart.getPlot();

    // set transparency
    plot.setForegroundAlpha(0.7f);
    plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinesVisible(false);
    plot.setRangeGridlinesVisible(true);
    plot.setRangeGridlinePaint(Color.white);

    CategoryAxis domainAxis = plot.getDomainAxis();
    domainAxis.setVisible(false);
    domainAxis.setUpperMargin(0);
    domainAxis.setLowerMargin(0);

    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setUpperMargin(0.20);
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    BarRenderer renderer = (BarRenderer) plot.getRenderer();
    CategoryItemLabelGenerator generator = new StandardCategoryItemLabelGenerator("{1}",
            NumberFormat.getInstance(new ResourceLoader().getLocale()));
    renderer.setBaseItemLabelGenerator(generator);
    renderer.setBaseItemLabelFont(new Font("SansSerif", Font.PLAIN, 9));
    renderer.setBaseItemLabelsVisible(true);
    renderer.setItemMargin(0);
    renderer.setSeriesPaint(0, Color.BLUE);

    BufferedImage img = chart.createBufferedImage(width, height);
    final ByteArrayOutputStream out = new ByteArrayOutputStream();
    try {
        ImageIO.write(img, "png", out);
    } catch (IOException e) {
        log.warn("Error occurred while generating SiteStats chart image data", e);
    }
    return out.toByteArray();
}