feat(api): use api and spec together #5074
Merged
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.
chart.options
Spec API和 Chart API 可以同时使用。
开始使用
Spec API 和 Chart API 理论上应该分开使用,但是两者也有点细小的区别:
所以两者混合的一个场景可以如下:
实现思路
chart.options(spec)
类似声明 innerHTML,如果当前没有 node tree,内部会将 spec 解析成一棵 node tree,否者会根据当前 options 更新该 node tree。(详见讨论:#4718 )案例
根据 height 和 index 去更新树。
先使用 API,再使用 Spec 也是可以的。