You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by su...@apache.org on 2020/11/16 06:28:55 UTC
[incubator-echarts-examples] branch next updated: fix: change
third-party script fetch approach.
This is an automated email from the ASF dual-hosted git repository.
sushuang pushed a commit to branch next
in repository https://gitbox.apache.org/repos/asf/incubator-echarts-examples.git
The following commit(s) were added to refs/heads/next by this push:
new 3ac6df8 fix: change third-party script fetch approach.
3ac6df8 is described below
commit 3ac6df81445d47d162a18e246e39b79e24b5c3dd
Author: 100pah <su...@gmail.com>
AuthorDate: Mon Nov 16 14:28:42 2020 +0800
fix: change third-party script fetch approach.
---
README.md | 15 +++++++++++++++
public/data/custom-combine-separate-morph.js | 15 +++++++--------
public/data/custom-story-transition.js | 12 ++++++------
3 files changed, 28 insertions(+), 14 deletions(-)
diff --git a/README.md b/README.md
index e24213b..b1450b5 100644
--- a/README.md
+++ b/README.md
@@ -55,6 +55,21 @@ describes the meta info of this example.
## Some built-in features available in examples
+
+### Import third-party library
+
+For example:
+```js
+$.when(
+ $.getScript(ROOT_PATH + '/data/asset/js/myTransform.js'),
+ $.getScript('https://cdn.jsdelivr.net/npm/d3-contour@2.0.0/dist/d3-contour.jXs'),
+).done(function () {
+ // ...
+});
+```
+
+
+
### Controller panel
Use this code to enable controller panel for a example:
diff --git a/public/data/custom-combine-separate-morph.js b/public/data/custom-combine-separate-morph.js
index e839ce2..46a6414 100644
--- a/public/data/custom-combine-separate-morph.js
+++ b/public/data/custom-combine-separate-morph.js
@@ -451,17 +451,16 @@ console.log(app.config);
-var _global = {};
-$.get(ROOT_PATH + '/data/asset/js/myTransform.js', function (aggregateJS) {
- (new Function(aggregateJS)).call(_global);
+var _global = window;
- $.get(ROOT_PATH + '/data/asset/js/transitionPlayer.js', function (transitionPlayerJS) {
- (new Function(transitionPlayerJS)).call(_global);
-
- run();
- });
+$.when(
+ $.getScript(ROOT_PATH + '/data/asset/js/myTransform.js'),
+ $.getScript(ROOT_PATH + '/data/asset/js/transitionPlayer.js'),
+).done(function () {
+ run();
});
+
function run() {
echarts.registerTransform(_global.myTransform.aggregate);
diff --git a/public/data/custom-story-transition.js b/public/data/custom-story-transition.js
index 0095014..6497271 100644
--- a/public/data/custom-story-transition.js
+++ b/public/data/custom-story-transition.js
@@ -5,13 +5,13 @@ titleCN: 极简场景变换示例
difficulty: 11
*/
-const _global = {};
-$.get(ROOT_PATH + '/data/asset/js/myTransform.js', function (aggregateJS) {
- (new Function(aggregateJS)).call(_global);
+const _global = window;
- $.get(ROOT_PATH + '/data/asset/data/life-expectancy-table.json', function (_rawData) {
- run(_rawData);
- });
+$.when(
+ $.get(ROOT_PATH + '/data/asset/data/life-expectancy-table.json'),
+ $.getScript(ROOT_PATH + '/data/asset/js/myTransform.js')
+).done(function (res) {
+ run(res[0]);
});
let _optionList;
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org