A discussion forum for JFreeChart (a 2D chart library for the Java platform).
-
stu
- Posts: 10
- Joined: Mon Aug 01, 2005 1:44 pm
Post
by stu » Wed Oct 29, 2008 6:52 pm
I've just upgraded from 1.0.6 to 1.0.11 and have found three problems with an existing chart that uses XYBarRenderer.
These may be bugs or they could be new features of the API that I'm not familiar with. Either way, your help would be greatly appreciated.
I'm using a very basic XYBarRenderer that overrides getItemPaint to provide custom colours as follows:
Code: Select all
protected class CustomXYBarRenderer extends XYBarRenderer {
@Override
@SuppressWarnings("unused")
public Paint getItemPaint(final int row, final int column) {
if (column % 2 == 0) {
return Color.YELLOW;
}
return Color.CYAN;
}
}
The problems I am finding are that:
- Drop shadows appear and I can't see how to disable them. setShadowVisible() doesn't appear to have any effect.
- Borders no longer appear on the bars. I am using setSeriesOutlinePaint(0, Color.BLACK) to try and set the border
- All of the bars have a fake 3D effect applied to them. I can't see how to turn on this off.
Can anybody help?
-
RugWarrior
- Posts: 17
- Joined: Wed Jul 30, 2008 11:54 am
Post
by RugWarrior » Wed Oct 29, 2008 8:18 pm
Hi Stu,
please use the search function before posting
from david.gilbert ("fake 3D "):
I made the decision to change the default look in the 1.0.11 release. I knew it would be inconvenient for some users, but I'm getting positive feedback about the new look, so on balance I think the inconvenience is worth it.
The migration section in the JFreeChart Developer Guide explains how to restore the default "look" - essentially you put the following code somewhere near the start of your application (before you create any charts):
Code: Select all
ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme());
You'll also need:
Code: Select all
BarRenderer.setDefaultPainter(new StandardBarPainter());
from skunk ("shadow"):
There is a bug
http://www.jfree.org/phpBB2/viewtopic.php?t=25743
If you can't wait for 1.0.12, then insert the following block of code so that it will execute before any charts are created
Code: Select all
static {
XYBarRenderer.setDefaultBarPainter(new StandardXYBarPainter() {
public void paintBarShadow(Graphics2D g2, XYBarRenderer renderer, int row,
int column, RectangularShape bar, RectangleEdge base,
boolean pegShadow) {}
});
}
-
stu
- Posts: 10
- Joined: Mon Aug 01, 2005 1:44 pm
Post
by stu » Thu Oct 30, 2008 10:48 am
Hi RugWarrior, thanks for the quick reply. Believe me I'd done a lot of searching but all my emphasis was on XYBarRenderer so I totally missed the fake 3d post. Many thanks for the heads up though!
I can live with the shadows until 1.0.12. Any timescales on that btw?
And that just leaves the borders around bars not working. Or is that related to the shadows?
-
stu
- Posts: 10
- Joined: Mon Aug 01, 2005 1:44 pm
Post
by stu » Thu Oct 30, 2008 12:02 pm
I've just found that switching back to the legacy theme has given me the borders back!
Thanks again for your help RugWarrior

-
RugWarrior
- Posts: 17
- Joined: Wed Jul 30, 2008 11:54 am
Post
by RugWarrior » Thu Oct 30, 2008 8:17 pm
Hi Stu,
no problem
With luck 1.0.12 will be released in November (that is what I read so far)
-
apanag
- Posts: 6
- Joined: Wed Apr 05, 2006 2:43 pm
- Location: Zürich
-
Contact:
Post
by apanag » Wed Dec 10, 2008 2:48 pm
Code: Select all
JFreeChart jFreeChart = ChartFactory.createXYBarChart(...);
XYPlot xyPlot = jFreeChart.getXYPlot();
XYBarRenderer renderer = (XYBarRenderer) xyPlot.getRenderer();
renderer.setShadowVisible(false); //line 6
renderer.setBarPainter(new StandardXYBarPainter()); //line 7
line 6 removes the shadows
line 7 removes the 3D effect[/code]
Andreas