Updating chart stops following last value
See original GitHub issueHello! There is a little bug - updating chart stops following last value. It happens randomly. If you run “updating data” example on max speed (update speed is not the reason) and wait - you’ll see it.
I’ve spent some time debugging this and I’ve figured out the issue: getDataBetween calculates wrong newRightIndex. Maybe getClosestItemIndexes is the reason. I don’t really understand why we need this calculations, but I’ve found fix: change it
var newLeftIndex = getClosestItemIndexes(dataForInterval, left, xAccessor).right;
var newRightIndex = getClosestItemIndexes(dataForInterval, right, xAccessor).left;
to
var newLeftIndex = getClosestItemIndexes(dataForInterval, left, xAccessor).left;
var newRightIndex = getClosestItemIndexes(dataForInterval, right, xAccessor).right;
Also, I’ve created this fiddle with my data. So, you can reproduce the issue. getDataBetween’ve called form https://github.com/rrag/react-stockcharts/blob/master/src/lib/EventHandler.js#L160 . There is array[364] and last index should be 363 but left == 362 and at the next update last item will become invisible.
Should I create PR for this?
Issue Analytics
- State:
- Created 7 years ago
- Comments:8 (8 by maintainers)
Top GitHub Comments
Added this fix in the new scale will be published as part of 0.5
@rrag ooh… it makes sense now. Such a dumb comment from me) I’m not familiar with d3 yet.
So, I believe we can safely put it inside invert method
It’ll fix the issue