You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by wa...@apache.org on 2024/02/05 15:13:34 UTC
(echarts-examples) branch gh-pages updated (21994715 -> c9bd8b9a)
This is an automated email from the ASF dual-hosted git repository.
wangzx pushed a change to branch gh-pages
in repository https://gitbox.apache.org/repos/asf/echarts-examples.git
from 21994715 use new version list API for smaller response size for Chinese example page
new 0068a81e fix `histroy` -> `history`
new c9bd8b9a feat(editor): support setting theme for charts via the URL parameter: `theme=themeName`
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
src/common/store.js | 2 ++
src/editor/Editor.vue | 2 +-
src/editor/Preview.vue | 12 +++++++++++-
src/editor/downloadExample.js | 12 ++++++++++--
src/editor/sandbox/openwith/helper.js | 4 +++-
src/editor/sandbox/setup.js | 4 ++--
6 files changed, 29 insertions(+), 7 deletions(-)
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org
(echarts-examples) 02/02: feat(editor): support setting theme for charts via the URL parameter: `theme=themeName`
Posted by wa...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
wangzx pushed a commit to branch gh-pages
in repository https://gitbox.apache.org/repos/asf/echarts-examples.git
commit c9bd8b9a2a1ef7843d60c3385ad5b5a6ac377883
Author: plainheart <yh...@all-my-life.cn>
AuthorDate: Mon Feb 5 23:11:43 2024 +0800
feat(editor): support setting theme for charts via the URL parameter: `theme=themeName`
---
src/common/store.js | 2 ++
src/editor/Editor.vue | 2 +-
src/editor/Preview.vue | 12 +++++++++++-
src/editor/downloadExample.js | 12 ++++++++++--
src/editor/sandbox/openwith/helper.js | 4 +++-
src/editor/sandbox/setup.js | 2 +-
6 files changed, 28 insertions(+), 6 deletions(-)
diff --git a/src/common/store.js b/src/common/store.js
index 59f2e3bb..268cef9b 100644
--- a/src/common/store.js
+++ b/src/common/store.js
@@ -27,6 +27,8 @@ export const store = {
version: '',
locale: '',
+ // 'light' and 'dark' are default built-in themes
+ theme: URL_PARAMS.theme === 'light' ? null : URL_PARAMS.theme,
darkMode: URL_PARAMS.theme === 'dark',
enableDecal: 'decal' in URL_PARAMS,
renderer: (() => {
diff --git a/src/editor/Editor.vue b/src/editor/Editor.vue
index 2f6e775e..ba101851 100644
--- a/src/editor/Editor.vue
+++ b/src/editor/Editor.vue
@@ -562,7 +562,7 @@ export default {
ts: store.typeCheck,
esm: this.fullCodeConfig.esm,
// legacy: true,
- theme: store.darkMode ? 'dark' : '',
+ theme: store.darkMode ? 'dark' : store.theme,
renderer: store.renderer,
useDirtyRect: store.useDirtyRect,
ROOT_PATH: store.cdnRoot,
diff --git a/src/editor/Preview.vue b/src/editor/Preview.vue
index 9f59eca8..05e078e3 100644
--- a/src/editor/Preview.vue
+++ b/src/editor/Preview.vue
@@ -191,9 +191,11 @@ function getScripts(nightly) {
const code = store.runCode;
return [
+ // echarts
echartsDir +
getScriptURL(SCRIPT_URLS.echartsJS) +
(store.isPR ? '?_=' + (store.prLatestCommit || Date.now()) : ''),
+ // echarts-gl
...(isGL
? [
isLocal
@@ -201,18 +203,26 @@ function getScripts(nightly) {
: getScriptURL(SCRIPT_URLS.echartsGLJS)
]
: []),
+ // echarts theme
+ ...(!store.darkMode && store.theme
+ ? [echartsDir + `/theme/${store.theme}.js`]
+ : []),
+ // echarts bmap extension
...(hasBMap || /coordinateSystem.*:.*['"]bmap['"]/g.test(code)
? [
SCRIPT_URLS.bmapLibJS,
echartsDir + getScriptURL(SCRIPT_URLS.echartsBMapJS)
]
: []),
+ // echarts stat
...(code.indexOf('ecStat.') > -1
? [getScriptURL(SCRIPT_URLS.echartsStatJS)]
: []),
+ // echarts map
...(/map.*:.*['"]world['"]/g.test(code)
? [SCRIPT_URLS.echartsWorldMapJS]
: []),
+ // data gui
...(code.indexOf('app.config') > -1 ? [SCRIPT_URLS.datGUIMinJS] : [])
].map((url) => ({ src: url }));
}
@@ -385,7 +395,7 @@ export default {
renderer: isCanvas ? null : store.renderer,
useDirtyRect: store.useDirtyRect && isCanvas ? 1 : null,
decal: store.enableDecal ? 1 : null,
- theme: store.darkMode ? 'dark' : null
+ theme: store.darkMode ? 'dark' : store.theme || null
};
}
},
diff --git a/src/editor/downloadExample.js b/src/editor/downloadExample.js
index 8dd4d37b..37880360 100644
--- a/src/editor/downloadExample.js
+++ b/src/editor/downloadExample.js
@@ -13,13 +13,18 @@ export function download(sourceHeader) {
const jqueryScriptCode = hasJQueryJS
? `<script type="text/javascript" src="${SCRIPT_URLS.jQueryJS}"></script>`
: '';
-
const echartsDir = SCRIPT_URLS[
store.echartsVersion.indexOf('dev') > -1
? 'echartsNightlyDir'
: 'echartsDir'
].replace('{{version}}', store.echartsVersion);
const echarts4Dir = SCRIPT_URLS.echartsDir.replace('{{version}}', '4.9.0');
+
+ const themeScriptCode =
+ !store.darkMode && store.theme
+ ? `<!-- theme -->\n <script type="text/javascript" src="${echartsDir}/theme/${store.theme}.js"></script>`
+ : '';
+
const code = `<!--
${sourceHeader}
-->
@@ -35,6 +40,7 @@ ${sourceHeader}
<script type="text/javascript" src="${echartsDir}${
SCRIPT_URLS.echartsJS
}"></script>
+ ${themeScriptCode}
<!-- Uncomment this line if you want to dataTool extension
<script type="text/javascript" src="${echartsDir}/dist/extension/dataTool.min.js"></script>
-->
@@ -57,7 +63,9 @@ ${sourceHeader}
<script type="text/javascript">
var dom = document.getElementById('container');
- var myChart = echarts.init(dom, ${store.darkMode ? "'dark'" : 'null'}, {
+ var myChart = echarts.init(dom, ${
+ store.darkMode ? "'dark'" : store.theme ? `'${store.theme}'` : 'null'
+ }, {
renderer: '${store.renderer}',
useDirtyRect: ${store.useDirtyRect}
});
diff --git a/src/editor/sandbox/openwith/helper.js b/src/editor/sandbox/openwith/helper.js
index 58a0b396..16235b25 100644
--- a/src/editor/sandbox/openwith/helper.js
+++ b/src/editor/sandbox/openwith/helper.js
@@ -46,7 +46,9 @@ export function getTemplates(title, scripts, css) {
</html>`;
const jsTpl = `var dom = document.getElementById('chart-container');
-var myChart = echarts.init(dom, ${store.darkMode ? "'dark'" : 'null'}, {
+var myChart = echarts.init(dom, ${
+ store.darkMode ? "'dark'" : store.theme ? `'${store.theme}'` : 'null'
+ }, {
renderer: '${store.renderer}',
useDirtyRect: ${store.useDirtyRect}
});
diff --git a/src/editor/sandbox/setup.js b/src/editor/sandbox/setup.js
index d50d4f95..95f368cc 100644
--- a/src/editor/sandbox/setup.js
+++ b/src/editor/sandbox/setup.js
@@ -220,7 +220,7 @@ function setup(isShared) {
this.dispose();
chartInstance = echarts.init(
document.getElementById('chart-container'),
- store.darkMode ? 'dark' : '',
+ store.darkMode ? 'dark' : store.theme,
{
renderer: store.renderer,
useDirtyRect: store.useDirtyRect
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org
(echarts-examples) 01/02: fix `histroy` -> `history`
Posted by wa...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
wangzx pushed a commit to branch gh-pages
in repository https://gitbox.apache.org/repos/asf/echarts-examples.git
commit 0068a81eb611703a734829e60b2e00f3139541cc
Author: plainheart <yh...@all-my-life.cn>
AuthorDate: Mon Feb 5 22:16:58 2024 +0800
fix `histroy` -> `history`
---
src/editor/sandbox/setup.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/editor/sandbox/setup.js b/src/editor/sandbox/setup.js
index 85b64013..d50d4f95 100644
--- a/src/editor/sandbox/setup.js
+++ b/src/editor/sandbox/setup.js
@@ -279,7 +279,7 @@ function setup(isShared) {
'globalThis',
'document',
'location',
- 'histroy',
+ 'history',
'eval',
'execScript',
'Function',
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org