echarts: simplify usage and remove current limitations #735
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.
Hello folks,
The patch attached resolves, in a fully backwards-compatible way, the problem of echarts in LoveIt unable to support Javascript.
The patch supports this new form of using the shortcode:
The shortcode expands this to a new attribute
and when the page is loaded,
theme.js
automatically recognizes which divs to load as a JS module vs with embedded specification, based on the presence of thatdata-filename
attribute.The documentation is updated accordingly, to list both ways of use: the "embedded" way (current), and the "referenced" way (with JS module).
As charts become non-trivial, the embedded way quickly become unusable, not only because it prevents using JavaScript which is essential to non-trivial charts, but also because the effort of converting specs back and forth from JavaScript to JSON/YAML/TOML when prototyping the chart with echart's editor becomes huge.
There are additional benefits of this approach:
Nota bene: I haven't committed the auto-generate
assets/js/theme.js
.Let me know if there's any additional adaptation you'd like to see in this.