setDrawSeriesLineAsPath(true) causes lines to disappear

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
swdev
Posts: 13
Joined: Sat Oct 14, 2006 1:01 pm

setDrawSeriesLineAsPath(true) causes lines to disappear

Post by swdev » Mon Jun 21, 2010 10:11 am

I have an XY plot in which calling setDrawSeriesLineAsPath(true) on the
renderer causes the whole line to disappear; things work as expected
otherwise. I do not have the time to go to the bottom of this new oddity
right now but perhaps it rings a bell with someone? Thanks.

mkivinie
Posts: 51
Joined: Wed Jul 06, 2005 8:35 am

Re: setDrawSeriesLineAsPath(true) causes lines to disappear

Post by mkivinie » Mon Jun 21, 2010 11:38 am

Which version of JFreeChart are you using? There was a problem in the initial versions where this happened but it should be fixed now.

I cannot remember on the top of my head the broken version nor where it started to work. You should be able to find similar threads with the Search, though...

swdev
Posts: 13
Joined: Sat Oct 14, 2006 1:01 pm

Re: setDrawSeriesLineAsPath(true) causes lines to disappear

Post by swdev » Mon Jun 21, 2010 12:52 pm

No, I am using the latest version and of course I already searched this forum. So I digged
and I found that when drawSeriesLineAsPath is set, the drawItem method of the renderer
calls drawPrimaryLineAsPath, which only draws the path once the item index reaches
state.getLastItemIndex(). The problem is that the method is not called if the item is not
visible and that it can perfectly well happen that the last item is not visible, in which case
the path (i.e., the whole line) is never drawn! How to fix this depends on the particulars
of your data but is not difficult. I strongly feel this is a bug, though.

There is a very similar issue with legends, by the way: for no particular reason that I could
find XYLineAndShapeRenderer, unlike XYShapeRenderer, excludes from the legend any series
whose first point is not visible, which can also happen. Also a bug in my opinion.

At least these gotchas should be clearly signposted in the Javadocs or in the documentation.

Locked