1

I am trying to generate one bar chart but it's forcing me to control width and height by calculating size of labels from domain axis and causing problems when they are too large (the start of the columns' values get in the middle of the chart).

Do you have any suggestion ?

Thank you.

mrcaramori
  • 2,503
  • 4
  • 29
  • 47
  • I'm having trouble visualizing the problem. Can you post a picture and some code? `BarChartDemo1` may be a convenient starting point: http://www.jfree.org/jfreechart/api/javadoc/org/jfree/chart/demo/BarChartDemo1.html – trashgod Aug 05 '10 at 03:00

1 Answers1

2

You can change the renderer on the chart by creating a custom painter that repaints the graphics; the Painter code doesn't seem to display correctly here. I used a widthMultiplier to control the size of my bars:

GradientXYBarPainter xyBarpainter = new GradientXYBarPainter() {

    @Override
    public void paintBar(Graphics2D g2, XYBarRenderer renderer, int row,
            int column, RectangularShape bar, RectangleEdge base) {
        Rectangle2D rect = bar.getFrame();
        rect.setRect(rect.getX(), rect.getY(),
            rect.getWidth() * widthMultiplier, rect.getHeight());
        bar.setFrame(rect);
        super.paintBar(g2, renderer, row, column, bar, base);
    }
};
StackedXYBarRenderer rend = new StackedXYBarRenderer();
rend.setBarPainter(xyBarpainter);
trashgod
  • 203,806
  • 29
  • 246
  • 1,045