HanSolo/charts

Support for empty data points

Closed this issue ยท 11 comments

bgmf commented

Image a graph displaying some data from the last X days. Where some data is not available for whatever reason.

It would be great, if we could display a "broken" line etc. indicating the data point is actually missing instead of missing either a day or set the data to a zero value, so the line just drops to the bottom - which is not the same as "there is no data".

I propose to allow to set "empty" data items that specifically exist only to allow the graph to be incomplete.

Would something like on the image work for you?
InterruptedChart

bgmf commented

Yeah, that would be exactly what we need. I'd need to switch from TilesFX to Charts, but that would be acceptable. ๐Ÿ˜‰

Ok...so let me see how to make that possible. And if it will be in charts...it will probably also be in tilesfx :)

The question is how to define a "null" datapoint. Should there be a special EmptyXYChartItem for example that you create manually if needed or should the XYChartItem take Double instead of double values and in case the Double value is null it should not throw an error but use it as an empty chart item?

bgmf commented

I think from your perspective, I'd prefer the EmptyXYChartItem.

Taking a null value could be difficult in some cases: The TilesFX tile we are currently using, takes JavaFX's own XYChart.Data item. That isn't allowed to be null (triggers an NPE).

I was thinking about to add an isEmpty flag to the Item class. So you could set the item to empty and it would not matter what data is in there, it would be handled as an empty item.

bgmf commented

Sounds reasonable. In the end I'm most likely happy with everything you concoct. ๐Ÿ˜„

I have a first solution for the XYPane based charts. Here the point on position x=4 is empty. But this kind of chart does not support tooltips and interaction because it is purely based on canvas at the moment.
Charts 2021-08-27 13-54-28

bgmf commented

From the pure chart point of view, this is exactly what I would need. But as you noticed tooltips would be required rather sooner than later as well.

I'm currently looking into how to add the tooltips in a useable way into this kind of chart...

I've added support for tooltips in xycharts too. You can test it by running the EmptyItemTestLauncher in the tests package.