Skip to content
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

option发生变化的时候,图表不重绘。 #17

Closed
akeyz opened this issue Jul 21, 2017 · 2 comments
Closed

option发生变化的时候,图表不重绘。 #17

akeyz opened this issue Jul 21, 2017 · 2 comments

Comments

@akeyz
Copy link

akeyz commented Jul 21, 2017

这个是bug,还是本身就没有这个功能?

谢谢!

@xieziyu
Copy link
Owner

xieziyu commented Jul 21, 2017

@akeyz
这个不是bug,并且这个功能也存在。你的图表之所以没有重绘,是因为你只是改变了option的属性值,而没有改变option对象本身的引用。因此angular的change detection不会调用ngOnChanges的钩子。

ngx-echarts从性能方面做了考量,所以也不会去用ngDoCheck做深度脏检查。所以,如果你想要改变option的属性值,同时使得图表重绘,那么最简单的方式是,改变一下option对象的引用,例如:

this.myOption = Object.assign({}, this.myOption);

EDIT: demo页面有例子,可供参考。

@akeyz
Copy link
Author

akeyz commented Jul 21, 2017

好的,多谢!

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

No branches or pull requests

2 participants