Skip to content

Fix#12164 Erroneous Behavior when displaying a line chart with multiple data pushes before updating chart data while zoomed in #12266

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

cuijian-dexter
Copy link

Brief Information

This pull request is in the type of:

  • [ 1 ] bug fixing
  • [ 0 ] new feature
  • [ 0 ] others

What does this PR do?

Fixed issues

Details

Before: What was the problem?

After: How is it fixed in this PR?

Usage

Are there any API changes?

  • The API has been changed.

Related test cases or examples to use the new APIs

NA.

Others

Merging options

  • Please squash the commits into a single one when merge.

Other information

https://github.com/apache/incubator-echarts/issues/12164

@cuijian-dexter cuijian-dexter added this to the 4.8.0 milestone Mar 10, 2020
@@ -166,6 +166,7 @@ export default function (

// Diff result may be crossed if all items are changed
// Sort by data index
rawIndices = Array.from(new Set(rawIndices));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't use Array.from and Set because it's not supported in IE. See https://www.echartsjs.com/zh/coding-standard.html

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK,I will fix it

rawIndices.splice(i, 1);
}
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

O(n2) algorithm may have performance issue on large data.

Also splice is usually not a performant method and can easily get logic messed up(because the array length is changed after splice). Create a new array(when necessary) is much simpler and has better performance. Check https://jsperf.com/splice-vs-filter

Since there rawIndices has been sorted in the following code. We can loop sortedIndices, and only compare two neighbor rawIndex to see if they are the same.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants