How do I create a XYLineChart with gaps in between squeezed?

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Post Reply
rao.raghuba
Posts: 1
Joined: Thu Aug 31, 2017 10:30 am
antibot: No, of course not.

How do I create a XYLineChart with gaps in between squeezed?

Post by rao.raghuba » Thu Aug 31, 2017 11:08 am

Hello experts,
Suppose there are 6 points on the x-axis of a line chart. (labelled as 1,2,3,4,5 and 6). Points 1, 2 and 5, 6 have values (of range axis) associated with them whereas 3 and 4 have empty y-values associated to them. Now in the final chart (line chart), I want to hide the values of 3 and 4 since they do not have any y-values associated to them. Following table can help summarize the problem here

x| y| show (on chart)|
------------------------------------
1 | 10 | Yes
2 | 20 | Yes
3 | null| No
4 | null| No
5 | 30| Yes
6 | 25| Yes

So basically the final chart should contain only those x-axis points that have a y-value associated with them. Kindly let me know how can this be achieved?

Thanks.

daress
Posts: 22
Joined: Tue Mar 13, 2007 4:52 pm
Contact:

Re: How do I create a XYLineChart with gaps in between squee

Post by daress » Thu Aug 31, 2017 4:04 pm

You could create two different XYSeries, with points 1 and 2 in the first, and points 5 and 6 in the second.

That would create two different lines with the corresponding gap between them. They would be different colors (and two different entries in the legend), but you can override the color of each series to make them the same.

There is probably a more elegant solution, but the above should work.

Post Reply