fix(lines): discard extraneous data-points during lines animation #13638
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Brief Information
This pull request is in the type of:
What does this PR do?
Discards data-points that were erroneously added to the chart during the lines animation.
Fixed issues
There are multiple issues currently open about this problem and they might all be related.
Details
Add a test to easily reproduce the bug where points are erroneously added to the chart during the lines animation and make a naive attempt at fixing it.
Before: What was the problem?
This bug happens during line-animations and it makes the chart display some invalid data-points after the animation is complete.
These erroneous data-points seem to be transient and they seem to go away after some interactions with the chart (e.g.: by manually changing the data-zoom).
This is a screenshot of the bug from the added test case (there are only two points in the series so there should only be one segment):
Reproduction link: https://jsfiddle.net/8kv71j0w/7/ (also see added test case in
test/lines-extraneous.html
).After: How is it fixed in this PR?
Due to some items in the old series having been filtered out (e.g.: by the data-zoom component), the
rawIndex
of the removed items is different than theindex
. Therefore, this condition evaluates totrue
which results in this particular code path being executed. This in turn has the effect of keeping these removed points in the line during (and after) the animation.The naive fix as part of this pull-request was to remove that code-block all together.
Warning: I don't have enough context to understand the full-implications of this change and it's very likely that this is not a good fix for this problem.
The main reason for opening this pull-request was to start a discussion and get some feedback from the developers about what would a proper fix look like.
That being said, this proposed change does seem to produce the expected result in the attached test case:
Usage
Are there any API changes?
Related test cases or examples to use the new APIs
See test case in:
test/lines-extraneous.html
Others
Merging options
Other information
See the linked issues for more details about other instances where this bug happens.