jfreechart-fse
jfreechart-fse copied to clipboard
XYPlot doesn't handle noDataMessage correctly
The XYPlot class has a method render() that states in the JavaDoc:
return A flag that indicates whether any data was actually rendered.
There is a check if the dataset is emptyOrNull. Right after this the foundData-flag is set to true, followed by conditional returns that skip rendering because of missing axes and the like. In this case, the returned value should IMHO still be false, as nothing was rendered.
Thinking a bit further about it, the plot would actually need info from the renderer if any data was rendered or not. Imagine a dataset with only null-values. The renderer wouldn't render anything but the plot couldn't know and would thus return foundData == true
.
So should the XYRenderer.drawItem()
method possibly return a boolean to indicate if anything was rendered, just like the draw()
method from the plot? What do you think?
It’s a tricky one, because if the emptyOrNull() check returns false then there is data, so in a sense we shouldn’t display the ‘no data message’ even if nothing is rendered for other reasons. Maybe there is a case for another message to be displayed when there is data but for some reason rendering is not possible.
Best regards,
David
On 11 Feb 2015, at 09:32, Martin Höller [email protected] wrote:
Thinking a bit further about it, the plot would actually need info from the renderer if any data was rendered or not. Imagine a dataset with only null-values. The renderer wouldn't render anything but the plot couldn't know and would thus return foundData == true. So should the XYRenderer.drawItem() method possibly return a boolean to indicate if anything was rendered, just like the draw() method from the plot? What do you think?
— Reply to this email directly or view it on GitHub.
Well, your arguments are valid. Still, if nothing is rendered it's going to be an empty chart and a message could make sense. Maybe we really would need another message. On the other hand, the current JavaDoc suggests something different. It clearly says "A flag that indicates whether any data was actually rendered", which might also happen with not emtpy datasets. So I at least agree with you at least, that this one is a tricky one ;-)