Support for gaps in XYLineAndShapeRenderer?

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
mpassell
Posts: 5
Joined: Wed Oct 07, 2009 7:15 pm
antibot: No, of course not.
Location: Waltham, MA USA
Contact:

Support for gaps in XYLineAndShapeRenderer?

Post by mpassell » Fri Feb 17, 2012 9:51 pm

I'm working with some old code that uses StandardXYItemRenderers. I saw the class comment saying it "has been retained for historical reasons and, in general, you should use the XYLineAndShapeRenderer class instead." I was considering changing the code to use the newer renderer. However, it looks like XYLineAndShapeRenderer lacks the support for gaps/discontinuous lines present in StandardXYItemRenderer. Are there any plans to add support for that in XYLineAndShapeRenderer?

--Matt

matinh
Posts: 483
Joined: Fri Aug 11, 2006 10:08 am
Location: Austria

Re: Support for gaps in XYLineAndShapeRenderer?

Post by matinh » Mon Mar 05, 2012 3:22 pm

This should work. See for example XYSeriesDemo1, which uses XYLineAndShapeRenderer and has gaps (null-values) in it.
If it doesn't work for you, please provide an small, self-contained demo to reproduce the problem.

thanks,
- martin

mpassell
Posts: 5
Joined: Wed Oct 07, 2009 7:15 pm
antibot: No, of course not.
Location: Waltham, MA USA
Contact:

Re: Support for gaps in XYLineAndShapeRenderer?

Post by mpassell » Mon Mar 05, 2012 3:47 pm

Hi Martin,

Thanks for the reply. It's good to know that XYLineAndShapeRenderer supports gaps using explicit null values. I guess what I should have said is that it lacks gap detection. In contrast, with StandardXYItemRenderer set to draw discontinuous lines, if you have x values of 1, 2, 3, 7, 8, and 9, it can detect that there is a gap between 3 and 7 and not try to draw a line between those two points. In the application I'm working on, we're not otherwise aware of gaps, so unless we duplicated the gap detection logic in our own code, we wouldn't know where we needed to insert null values.

Thanks,
Matt

matinh
Posts: 483
Joined: Fri Aug 11, 2006 10:08 am
Location: Austria

Re: Support for gaps in XYLineAndShapeRenderer?

Post by matinh » Mon Mar 05, 2012 3:55 pm

I don't know the StandardXYItemRenderer code but if it really detects missing values by itself, this is IMHO a bad practice! Not everybody wants gaps if a value is missing.
You should probably port your application to insert null-values into the dataset if you want gaps.

- martin

mpassell
Posts: 5
Joined: Wed Oct 07, 2009 7:15 pm
antibot: No, of course not.
Location: Waltham, MA USA
Contact:

Re: Support for gaps in XYLineAndShapeRenderer?

Post by mpassell » Mon Mar 05, 2012 4:05 pm

Notice that I said
with StandardXYItemRenderer set to draw discontinuous lines
It's an option that you can choose to turn on. It's worked quite well for us for years, but I understand that not everyone would want that behavior.

--Matt

matinh
Posts: 483
Joined: Fri Aug 11, 2006 10:08 am
Location: Austria

Re: Support for gaps in XYLineAndShapeRenderer?

Post by matinh » Mon Mar 05, 2012 4:31 pm

Ah, I see. I didn't know this option and it is not present in XYLineAndShapeRenderer.
So, if you want to switch the renderer, you would have to adapt your application to in a way that the dataset will return null-values when gaps are required.

hth,
- martin

Locked