Remove shadow offset on Bar Charts?

Discussion about JFreeChart related to stockmarket charts.
Locked
ptd26
Posts: 27
Joined: Sun Nov 08, 2009 10:12 am
antibot: No, of course not.

Remove shadow offset on Bar Charts?

Post by ptd26 » Sun Nov 14, 2010 12:02 pm

Image

2 issues:

1. How do I get rid of the offset from 0? The blue bars should be touching the green bars at 0 on the x-axis (not shown).
2. How do I either get rid of the 3d or make the 3D bars render horizontally instead of vertically as shown above -- the bars above are horizontal, but the texture / shadow / 3D shape is rendering vertically (looks like bar is standing up instead of on it's side).

skunk
Posts: 1087
Joined: Thu Jun 02, 2005 10:14 pm
Location: Brisbane, Australia

Re: Remove shadow offset on Bar Charts?

Post by skunk » Sun Nov 14, 2010 3:28 pm

2. Call the following before creating any chart objects

Code: Select all

XYBarRenderer.setDefaultBarPainter(new StandardXYBarPainter() {
    @Override
    public void paintBarShadow(Graphics2D g2, XYBarRenderer renderer, int row,
        int column, RectangularShape bar, RectangleEdge base,
        boolean pegShadow) {}
});
Modify as required if you are using Category* instead of XY*

ptd26
Posts: 27
Joined: Sun Nov 08, 2009 10:12 am
antibot: No, of course not.

Re: Remove shadow offset on Bar Charts?

Post by ptd26 » Mon Nov 15, 2010 12:09 am

That didn't seem to fix it. I think the problem might not be the shadow. If you look at the bars carefully, they appear to be drawn vertically instead of horizontally. I think the gap between the 0 on the x-axis the the bottom of each bar might be the margin. I'm using a CombinedXYRangeChart and above is one of the subplots shown.

Each subplot is very simply constructed following one of the demo examples:

intervaldataset = new XYIntervalSeriesCollection();
XYBarRenderer renderer1 = new XYBarRenderer(0.20);
renderer1.setUseYInterval(true);
XYPlot subplot1 = new XYPlot(intervaldataset, new NumberAxis("Size"), null, renderer1);

The subplot is then added to the main plot:

plot.add(subplot1);

Main Plot is constructed like this:

JFreeChart jfchart = new JFreeChart("Combined (Range) XY Plot", JFreeChart.DEFAULT_TITLE_FONT, plot, false);
NumberAxis vaxis = (NumberAxis)plot.getRangeAxis();
plot.getRangeAxis().setAutoRange(true);
add(new ChartPanel(jfchart));

Locked