charts
charts copied to clipboard
Enable sorting of DataSeriesItem objects by X-axis value (implement 'Comparable') in Vaadin Charts 2
Originally by basil.bourque
Using Vaadin Charts 2.
I have collections of DataSeriesItem objects cached in memory. The collections are periodically updated with fresh data. The X-axis is date-time values in my case, but I think this feature request applies in all types of X-axis.
It would be so helpful if I could add DataSeriesItem
objects to the collection, and then sort the collection. Currently that is not easy to do because DataSeriesItem
does not implement the Comparable interface.
I suggest implementing Comparable
on the X-axis value of DataSeriesItem
.
My guess is that there is no downside to this, no threat to backward-compatibility.
Imported from https://dev.vaadin.com/ issue #16488
Originally by basil.bourque
To clarify, let me give an example.
I may have a set of data with time points like this:
• 2015-03-04 15:22:00Z • 2015-03-04 15:23:00Z • 2015-03-04 15:24:00Z • 2015-03-04 15:29:00Z // Skipped ahead, missing minutes :25, :26, :27, and :28. • 2015-03-04 15:30:00Z • 2015-03-04 15:31:00Z
Soon after, one of the intermediate minutes may appear, say minute :27. This may happen because of instruments delayed in reporting data. Or in a cluster of web-scraping apps, some apps may miss an interval of data and later pick up the missing data from a sibling app.
So I have an intermediate data point to add to the chart's series. If I add the minute to the chart series, Vaadin Charts does not sort the collection of data points. Instead it adds it to the end, like this:
• 2015-03-04 15:22:00Z • 2015-03-04 15:23:00Z • 2015-03-04 15:24:00Z • 2015-03-04 15:29:00Z // Skipped ahead, missing minutes :25, :26, and :28. • 2015-03-04 15:30:00Z • 2015-03-04 15:31:00Z • 2015-03-04 15:27:00Z // Drawn on the end of the chart, on far right. Feature Request: integrate this point in between :24 & :29.
The data point for :27 appears on the far right of the chart, so the X-axis is not sorting the values by date-time order. Yet the line between data points does respect the date-time order. The line draws criss-cross, jumping from :24 point on the left over to the :27 point on the far right, and then back to the :29 minute found leftwards.