Skip to content

Commit 23de318

Browse files
kingyue737Justineo
andauthored
feat: dynamically update the theme (#841)
Co-authored-by: GU Yiling <[email protected]>
1 parent 9c3c230 commit 23de318

File tree

6 files changed

+48
-19
lines changed

6 files changed

+48
-19
lines changed

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ Drop `<script>` inside your HTML file and access the component via `window.VueEC
120120

121121
```html
122122
<script src="https://cdn.jsdelivr.net/npm/[email protected]"></script>
123-
<script src="https://cdn.jsdelivr.net/npm/echarts@5.5.1"></script>
123+
<script src="https://cdn.jsdelivr.net/npm/echarts@6.0.0-beta.1"></script>
124124
<script src="https://cdn.jsdelivr.net/npm/[email protected]"></script>
125125
```
126126

@@ -331,6 +331,12 @@ export default {
331331
- `clear` [](https://echarts.apache.org/en/api.html#echartsInstance.clear)
332332
- `dispose` [](https://echarts.apache.org/en/api.html#echartsInstance.dispose)
333333

334+
> [!NOTE]
335+
> The following ECharts instance methods aren't exposed because their functionality is already provided by component [props](#props):
336+
>
337+
> - [`showLoading`](https://echarts.apache.org/en/api.html#echartsInstance.showLoading) / [`hideLoading`](https://echarts.apache.org/en/api.html#echartsInstance.hideLoading): use the `loading` and `loading-options` props instead.
338+
> - `setTheme`: use the `theme` prop instead.
339+
334340
### Static Methods
335341

336342
Static methods can be accessed from [`echarts` itself](https://echarts.apache.org/en/api.html#echarts).

README.zh-Hans.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ import "echarts";
120120

121121
```html
122122
<script src="https://cdn.jsdelivr.net/npm/[email protected]"></script>
123-
<script src="https://cdn.jsdelivr.net/npm/echarts@5.5.1"></script>
123+
<script src="https://cdn.jsdelivr.net/npm/echarts@6.0.0-beta.1"></script>
124124
<script src="https://cdn.jsdelivr.net/npm/[email protected]"></script>
125125
```
126126

@@ -331,6 +331,12 @@ export default {
331331
- `clear` [](https://echarts.apache.org/zh/api.html#echartsInstance.clear)
332332
- `dispose` [](https://echarts.apache.org/zh/api.html#echartsInstance.dispose)
333333

334+
> [!NOTE]
335+
> 如下 ECharts 实例方法没有被暴露,因为它们的功能已经通过组件 [props](#props) 提供了:
336+
>
337+
> - [`showLoading`](https://echarts.apache.org/zh/api.html#echartsInstance.showLoading) / [`hideLoading`](https://echarts.apache.org/zh/api.html#echartsInstance.hideLoading):请使用 `loading``loading-options` prop。
338+
> - `setTheme`:请使用 `theme` prop。
339+
334340
### 静态方法
335341

336342
静态方法请直接通过 [`echarts` 本身](https://echarts.apache.org/zh/api.html#echarts)进行调用。

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"docs": "node ./scripts/docs.mjs",
2222
"prepublishOnly": "pnpm run typecheck && pnpm run dev:typecheck && pnpm run build && publint"
2323
},
24-
"packageManager": "pnpm@10.11.0",
24+
"packageManager": "pnpm@10.12.4",
2525
"type": "module",
2626
"main": "dist/index.js",
2727
"unpkg": "dist/index.min.js",
@@ -36,7 +36,7 @@
3636
"dist"
3737
],
3838
"peerDependencies": {
39-
"echarts": "^5.5.1",
39+
"echarts": "^6.0.0-beta.1",
4040
"vue": "^3.1.1"
4141
},
4242
"devDependencies": {
@@ -50,7 +50,7 @@
5050
"@vue/tsconfig": "^0.7.0",
5151
"@vueuse/core": "^13.1.0",
5252
"comment-mark": "^2.0.1",
53-
"echarts": "^5.5.1",
53+
"echarts": "^6.0.0-beta.1",
5454
"echarts-gl": "^2.0.9",
5555
"echarts-liquidfill": "^3.1.0",
5656
"esbuild-wasm": "^0.23.0",

pnpm-lock.yaml

Lines changed: 19 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scripts/docs.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const CDN_PREFIX = "https://cdn.jsdelivr.net/npm/";
88

99
const DEP_VERSIONS = {
1010
vue: "3.5.13",
11-
echarts: "5.5.1",
11+
echarts: "6.0.0-beta.1",
1212
[name]: version,
1313
};
1414

src/ECharts.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ export default defineComponent({
252252
);
253253

254254
watch(
255-
[realTheme, realInitOptions],
255+
realInitOptions,
256256
() => {
257257
cleanup();
258258
init();
@@ -262,6 +262,16 @@ export default defineComponent({
262262
},
263263
);
264264

265+
watch(
266+
realTheme,
267+
(theme) => {
268+
chart.value?.setTheme(theme);
269+
},
270+
{
271+
deep: true,
272+
},
273+
);
274+
265275
watchEffect(() => {
266276
if (props.group && chart.value) {
267277
chart.value.group = props.group;

0 commit comments

Comments
 (0)