You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The desired behavior is to produce a TimeRange where timeRange.begin() < timeRange.end(). However, array sort in JS is... interesting. To quote MDN:
all non-undefined array elements are sorted by converting them to strings and comparing strings in UTF-16 code units order.
For dates before 1970, newBegin and newEnd will be negative numbers. In many cases, these numbers will be consistently reversed. For example, in the node repl:
$ node
Welcome to Node.js v14.4.0.
Type ".help" for more information.
> [-390040203141, -204123317277].sort()
[ -204123317277, -390040203141 ]
To Reproduce
Steps to reproduce the behavior:
View a ChartContainer with enableDragZoom set to true
Drag to select a time range before 1970
View the time range passed to your onTimeRangeChanged handler
Expected behavior
The values should be properly sorted. onZoom is called in three places. Before the other two calls, no sorting takes place.
The other two places might be relying on the surrounding context for sort order, but I think it'd be best to explicitly sort in all three spots.
The text was updated successfully, but these errors were encountered:
🐛Bug report
Before calling
onZoom
,EventHandler
creates the necessaryTimeRange
that will be passed toonZoom
:react-timeseries-charts/src/components/EventHandler.js
Lines 206 to 209 in aa9c9b3
The desired behavior is to produce a
TimeRange
wheretimeRange.begin() < timeRange.end()
. However, array sort in JS is... interesting. To quote MDN:For dates before 1970,
newBegin
andnewEnd
will be negative numbers. In many cases, these numbers will be consistently reversed. For example, in the node repl:To Reproduce
Steps to reproduce the behavior:
ChartContainer
withenableDragZoom
set totrue
onTimeRangeChanged
handlerExpected behavior
The values should be properly sorted.
onZoom
is called in three places. Before the other two calls, no sorting takes place.The other two places might be relying on the surrounding context for sort order, but I think it'd be best to explicitly sort in all three spots.
The text was updated successfully, but these errors were encountered: