vue-echarts 8.1.0 → 8.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -102,6 +102,14 @@ But if you really want to import the whole ECharts bundle without having to impo
102
102
  import "echarts";
103
103
  ```
104
104
 
105
+ #### Styles
106
+
107
+ When Vue ECharts is imported in a browser, it injects its base styles into the global document, so no CSS import is normally required. For a shadow root or another document, include `vue-echarts/style.css` in that styling scope; see [CSP](#csp-style-src-or-style-src-elem) for the fallback required by older browsers.
108
+
109
+ ### Server-side rendering
110
+
111
+ `VChart` can be rendered and hydrated by Vue SSR frameworks. The server renders only the chart container; ECharts initializes after the component mounts in the browser. The low-level ECharts `ssr` field in `init-options` does not enable server-side chart rendering in `VChart`.
112
+
105
113
  ### CDN
106
114
 
107
115
  Drop `<script>` inside your HTML file and access the component via `window.VueECharts`.
@@ -113,8 +121,8 @@ Drop `<script>` inside your HTML file and access the component via `window.VueEC
113
121
 
114
122
  ```html
115
123
  <script src="https://cdn.jsdelivr.net/npm/echarts@6.1.0"></script>
116
- <script src="https://cdn.jsdelivr.net/npm/vue@3.5.40"></script>
117
- <script src="https://cdn.jsdelivr.net/npm/vue-echarts@8.1.0"></script>
124
+ <script src="https://cdn.jsdelivr.net/npm/vue@3.5.41"></script>
125
+ <script src="https://cdn.jsdelivr.net/npm/vue-echarts@8.2.0"></script>
118
126
  ```
119
127
 
120
128
  <!-- scripts:end -->
@@ -142,16 +150,20 @@ See more examples [here](https://github.com/ecomfe/vue-echarts/tree/main/demo).
142
150
 
143
151
  Theme to be applied. See `echarts.init`'s `theme` parameter [here →](https://echarts.apache.org/en/api.html#echarts.init)
144
152
 
153
+ Pass an empty string to use ECharts' default theme while overriding an injected theme.
154
+
145
155
  Injection key: `THEME_KEY`.
146
156
 
147
157
  - `option: object`
148
158
 
149
159
  ECharts' universal interface. Modifying this prop triggers Vue ECharts to compute an update plan and call `setOption`. Read more [here →](https://echarts.apache.org/en/option.html)
160
+ Temporarily removing the prop pauses automatic updates without letting a later theme change roll the chart back to its initial option.
150
161
 
151
162
  #### Smart update
152
- - If you supply `update-options` (via prop or injection), Vue ECharts forwards it directly to `setOption` and skips the planner.
163
+ - If you supply `update-options` (via prop or injection), Vue ECharts forwards it directly to `setOption` and skips the planner. After you remove it, the first smart update rebuilds once to establish a safe structural baseline.
153
164
  - Manual `setOption` calls (only available when `manual-update` is `true`) behave like native ECharts, honouring only the per-call override you pass in and are not carried across re-initializations.
154
- - Otherwise, Vue ECharts analyses the change: removed objects become `null`, removed arrays become `[]` with `replaceMerge`, ID/anonymous deletions trigger `replaceMerge`, and risky changes fall back to `notMerge: true`.
165
+ - Updates containing a graphic element `$action` keep normal merge for `graphic` so the command can target the existing element tree; safe removals of unrelated components still use `replaceMerge`.
166
+ - Otherwise, Vue ECharts analyses the change: component removals, reordering, and deletions inside anonymous components use `replaceMerge` when it can reproduce the requested order; deletions inside ID-matched components, identity ordering that `replaceMerge` cannot reproduce, newly introduced or shrinking non-component arrays, first-time ARIA configuration, and other risky changes fall back to `notMerge: true`.
155
167
 
156
168
  - `update-options: object`
157
169
 
@@ -165,21 +177,44 @@ See more examples [here](https://github.com/ecomfe/vue-echarts/tree/main/demo).
165
177
 
166
178
  - `autoresize: boolean | { throttle?: number, onResize?: () => void }` (default: `false`)
167
179
 
168
- Whether the chart should be resized automatically whenever its root is resized. Use the options object to specify a custom throttle delay (in milliseconds) and/or an extra resize callback function.
180
+ Whether to resize the chart automatically when its rendering container changes size. Use the options object to specify a custom throttle delay (in milliseconds) and/or an extra resize callback function. Zero-sized containers are not resized; the configured throttle also applies when they recover.
169
181
 
170
182
  - `loading: boolean` (default: `false`)
171
183
 
172
184
  Whether the chart is in loading state.
173
185
 
186
+ - `loading-type: string`
187
+
188
+ Name of the registered loading effect. It is passed as the first argument to `echartsInstance.showLoading`; omit it to use the default effect.
189
+
174
190
  - `loading-options: object`
175
191
 
176
- Configuration item of loading animation. See `echartsInstance.showLoading`'s `opts` parameter [here →](https://echarts.apache.org/en/api.html#echartsInstance.showLoading)
192
+ Configuration item of loading animation. Default-effect fields are typed explicitly, and additional fields for custom effects are forwarded to `echartsInstance.showLoading`. See its `opts` parameter [here →](https://echarts.apache.org/en/api.html#echartsInstance.showLoading)
177
193
 
178
194
  Injection key: `LOADING_OPTIONS_KEY`.
179
195
 
180
196
  - `manual-update: boolean` (default: `false`)
181
197
 
182
- Handy for performance-sensitive charts (large or high-frequency updates). When set to `true`, Vue only uses the `option` prop for the initial render; later prop changes do nothing and you must drive updates via `setOption` on a template ref. If the chart re-initializes (for example due to `init-options` changes, flipping `manual-update`, or a remount), the manual state is discarded and the chart is rendered again from the current `option` value.
198
+ Handy for performance-sensitive charts (large or high-frequency updates). When set to `true`, Vue uses the `option` prop for the initial render but does not deeply observe it afterwards; later prop changes do nothing and you must drive updates via `setOption` on a template ref. The component-managed initial render still honors `update-options`, while later manual calls use only their per-call arguments. If `autoresize` defers that first render and you successfully call `setOption` first, the manual call takes precedence. If the chart re-initializes (for example due to `init-options` changes, flipping `manual-update`, or a remount), the manual state is discarded and the chart is rendered again from the current `option` value.
199
+
200
+ #### TypeScript
201
+
202
+ Component-specific prop types are available from the package root:
203
+
204
+ ```ts
205
+ import type { AutoResize, LoadingOptions } from "vue-echarts";
206
+ ```
207
+
208
+ For a typed template ref:
209
+
210
+ ```ts
211
+ import VChart from "vue-echarts";
212
+ import { ref } from "vue";
213
+
214
+ const chart = ref<InstanceType<typeof VChart> | null>(null);
215
+ ```
216
+
217
+ Vue 3.5's `useTemplateRef` can infer this type automatically.
183
218
 
184
219
  ### Events
185
220
 
@@ -192,9 +227,9 @@ You can bind events with Vue's `v-on` directive.
192
227
  ```
193
228
 
194
229
  > [!NOTE]
195
- > Only the `.once` event modifier is supported as other modifiers are tightly coupled with the DOM event system.
230
+ > ECharts and ZRender events only support the `.once` modifier; other modifiers are specific to DOM events. Listeners using the `native:` prefix support Vue's normal DOM event modifiers.
196
231
 
197
- Vue ECharts support the following events:
232
+ Vue ECharts supports the following events:
198
233
 
199
234
  - `highlight` [→](https://echarts.apache.org/en/api.html#events.highlight)
200
235
  - `downplay` [→](https://echarts.apache.org/en/api.html#events.downplay)
@@ -207,6 +242,13 @@ Vue ECharts support the following events:
207
242
  - `legendscroll` [→](https://echarts.apache.org/en/api.html#events.legendscroll)
208
243
  - `datazoom` [→](https://echarts.apache.org/en/api.html#events.datazoom)
209
244
  - `datarangeselected` [→](https://echarts.apache.org/en/api.html#events.datarangeselected)
245
+ - `graphroam` [→](https://echarts.apache.org/en/api.html#events.graphroam)
246
+ - `georoam` [→](https://echarts.apache.org/en/api.html#events.georoam)
247
+ - `treeroam` [→](https://echarts.apache.org/en/api.html#events.treeroam)
248
+ - `sankeyroam` [→](https://echarts.apache.org/en/api.html#events.sankeyroam)
249
+ - `focusnodeadjacency`, `unfocusnodeadjacency` (legacy graph adjacency focus actions)
250
+ - `dragnode` [→](https://echarts.apache.org/en/api.html#events.dragnode)
251
+ - `treeexpandandcollapse` [→](https://echarts.apache.org/en/api.html#events.treeexpandandcollapse)
210
252
  - `timelinechanged` [→](https://echarts.apache.org/en/api.html#events.timelinechanged)
211
253
  - `timelineplaychanged` [→](https://echarts.apache.org/en/api.html#events.timelineplaychanged)
212
254
  - `restore` [→](https://echarts.apache.org/en/api.html#events.restore)
@@ -215,11 +257,16 @@ Vue ECharts support the following events:
215
257
  - `geoselectchanged` [→](https://echarts.apache.org/en/api.html#events.geoselectchanged)
216
258
  - `geoselected` [→](https://echarts.apache.org/en/api.html#events.geoselected)
217
259
  - `geounselected` [→](https://echarts.apache.org/en/api.html#events.geounselected)
260
+ - `axisbreakchanged` [→](https://echarts.apache.org/en/api.html#events.axisbreakchanged)
218
261
  - `axisareaselected` [→](https://echarts.apache.org/en/api.html#events.axisareaselected)
219
262
  - `brush` [→](https://echarts.apache.org/en/api.html#events.brush)
220
- - `brushEnd` [→](https://echarts.apache.org/en/api.html#events.brushEnd)
263
+ - `brushend` [→](https://echarts.apache.org/en/api.html#events.brushEnd)
221
264
  - `brushselected` [→](https://echarts.apache.org/en/api.html#events.brushselected)
265
+ - `showtip` [→](https://echarts.apache.org/en/api.html#action.tooltip.showTip)
266
+ - `hidetip` [→](https://echarts.apache.org/en/api.html#action.tooltip.hideTip)
267
+ - `updateaxispointer` [→](https://echarts.apache.org/en/api.html#action.axisPointer.updateAxisPointer)
222
268
  - `globalcursortaken` [→](https://echarts.apache.org/en/api.html#events.globalcursortaken)
269
+ - `updated` (after an ECharts update completes)
223
270
  - `rendered` [→](https://echarts.apache.org/en/api.html#events.rendered)
224
271
  - `finished` [→](https://echarts.apache.org/en/api.html#events.finished)
225
272
  - Mouse events
@@ -234,11 +281,22 @@ Vue ECharts support the following events:
234
281
  - `contextmenu` [→](https://echarts.apache.org/en/api.html#events.Mouse%20events.contextmenu)
235
282
  - ZRender events
236
283
  - `zr:click`
237
- - `zr:mousedown`
238
- - `zr:mouseup`
239
- - `zr:mousewheel`
240
284
  - `zr:dblclick`
285
+ - `zr:mouseout`
286
+ - `zr:mouseover`
287
+ - `zr:mouseup`
288
+ - `zr:mousedown`
289
+ - `zr:mousemove`
241
290
  - `zr:contextmenu`
291
+ - `zr:globalout`
292
+ - `zr:mousewheel`
293
+ - `zr:drag`
294
+ - `zr:dragstart`
295
+ - `zr:dragend`
296
+ - `zr:dragenter`
297
+ - `zr:dragleave`
298
+ - `zr:dragover`
299
+ - `zr:drop`
242
300
 
243
301
  See supported events in the [ECharts API reference →](https://echarts.apache.org/en/api.html#events)
244
302
 
@@ -252,12 +310,18 @@ As Vue ECharts binds events to the ECharts instance by default, there is some ca
252
310
  </template>
253
311
  ```
254
312
 
255
- Event handlers passed via attrs are reactive by default. Updating `onClick`, `onZr:*`, or `onNative:*` handlers will rebind them automatically.
313
+ Case-sensitive custom events are supported by writing their exact name after `native:`, for example `@native:ChartReady`.
314
+
315
+ Event handlers passed via attrs are reactive by default. Updates to `onClick`, `onZr:*`, or `onNative:*` handlers take effect automatically.
316
+ Multiword handlers accept idiomatic camel case, such as `onDataZoom`, `onBrushEnd`, and `onZr:mouseMove`; existing forms such as `onDatazoom`, `onBrushend`, and `onZr:mousemove` remain supported.
256
317
 
257
318
  ### Provide / inject
258
319
 
259
320
  Vue ECharts provides provide/inject API for `theme`, `init-options`, `update-options` and `loading-options` to help configuring contextual options. eg. for `theme` you can use the provide API like this:
260
321
 
322
+ Explicit props take precedence over injected values.
323
+ Reactive providers may resolve to `null` or `undefined` while a contextual value is unavailable.
324
+
261
325
  <details>
262
326
  <summary>Composition API</summary>
263
327
 
@@ -280,56 +344,87 @@ provide(THEME_KEY, () => theme.value);
280
344
  <details>
281
345
  <summary>Options API</summary>
282
346
 
347
+ Static value:
348
+
283
349
  ```js
284
- import { THEME_KEY } from 'vue-echarts'
285
- import { computed } from 'vue'
350
+ import { THEME_KEY } from "vue-echarts";
286
351
 
287
352
  export default {
288
- {
289
- provide: {
290
- [THEME_KEY]: 'dark'
291
- }
292
- }
293
- }
353
+ provide: {
354
+ [THEME_KEY]: "dark",
355
+ },
356
+ };
357
+ ```
358
+
359
+ Reactive value:
360
+
361
+ ```js
362
+ import { THEME_KEY } from "vue-echarts";
363
+ import { computed } from "vue";
294
364
 
295
- // Or make injections reactive
296
365
  export default {
297
366
  data() {
298
367
  return {
299
- theme: 'dark'
300
- }
368
+ theme: "dark",
369
+ };
301
370
  },
302
371
  provide() {
303
372
  return {
304
- [THEME_KEY]: computed(() => this.theme)
305
- }
306
- }
307
- }
373
+ [THEME_KEY]: computed(() => this.theme),
374
+ };
375
+ },
376
+ };
308
377
  ```
309
378
 
310
379
  </details>
311
380
 
381
+ ### Properties
382
+
383
+ - `chart: ECharts | undefined`
384
+
385
+ The current underlying ECharts instance. This property is read-only and changes when the component re-initializes the chart; it becomes `undefined` after disposal. Prefer the methods below for supported operations. Direct option mutations are not tracked by the smart updater, so use `manual-update` when driving `setOption` imperatively.
386
+
387
+ - `root: HTMLElement | undefined`
388
+
389
+ The component's read-only `<x-vue-echarts>` root element, available after mounting.
390
+
312
391
  ### Methods
313
392
 
314
393
  - `setOption` [→](https://echarts.apache.org/en/api.html#echartsInstance.setOption)
315
394
  - `getWidth` [→](https://echarts.apache.org/en/api.html#echartsInstance.getWidth)
316
395
  - `getHeight` [→](https://echarts.apache.org/en/api.html#echartsInstance.getHeight)
317
396
  - `getDom` [→](https://echarts.apache.org/en/api.html#echartsInstance.getDom)
397
+ - `getZr` [→](https://echarts.apache.org/en/api.html#echartsInstance.getZr)
398
+ - `getId` [→](https://echarts.apache.org/en/api.html#echartsInstance.getId)
318
399
  - `getOption` [→](https://echarts.apache.org/en/api.html#echartsInstance.getOption)
400
+ - `isSSR` [→](https://echarts.apache.org/en/api.html#echartsInstance.isSSR)
401
+ - `getDevicePixelRatio` [→](https://echarts.apache.org/en/api.html#echartsInstance.getDevicePixelRatio)
319
402
  - `resize` [→](https://echarts.apache.org/en/api.html#echartsInstance.resize)
403
+ - `makeActionFromEvent` [→](https://echarts.apache.org/en/api.html#echartsInstance.makeActionFromEvent)
320
404
  - `dispatchAction` [→](https://echarts.apache.org/en/api.html#echartsInstance.dispatchAction)
405
+ - `updateLabelLayout` [→](https://echarts.apache.org/en/api.html#echartsInstance.updateLabelLayout)
321
406
  - `convertToPixel` [→](https://echarts.apache.org/en/api.html#echartsInstance.convertToPixel)
407
+ - `convertToLayout` [→](https://echarts.apache.org/en/api.html#echartsInstance.convertToLayout)
322
408
  - `convertFromPixel` [→](https://echarts.apache.org/en/api.html#echartsInstance.convertFromPixel)
323
409
  - `containPixel` [→](https://echarts.apache.org/en/api.html#echartsInstance.containPixel)
410
+ - `getVisual` [→](https://echarts.apache.org/en/api.html#echartsInstance.getVisual)
411
+ - `renderToCanvas` [→](https://echarts.apache.org/en/api.html#echartsInstance.renderToCanvas)
412
+ - `renderToSVGString` [→](https://echarts.apache.org/en/api.html#echartsInstance.renderToSVGString)
413
+ - `getSvgDataURL` [→](https://echarts.apache.org/en/api.html#echartsInstance.getSvgDataURL)
324
414
  - `getDataURL` [→](https://echarts.apache.org/en/api.html#echartsInstance.getDataURL)
325
415
  - `getConnectedDataURL` [→](https://echarts.apache.org/en/api.html#echartsInstance.getConnectedDataURL)
416
+ - `appendData` [→](https://echarts.apache.org/en/api.html#echartsInstance.appendData)
326
417
  - `clear` [→](https://echarts.apache.org/en/api.html#echartsInstance.clear)
418
+ - `isDisposed` [→](https://echarts.apache.org/en/api.html#echartsInstance.isDisposed)
327
419
  - `dispose` [→](https://echarts.apache.org/en/api.html#echartsInstance.dispose)
328
420
 
421
+ `dispose` is terminal for the current component instance. Use it instead of calling `dispose` on
422
+ the raw `chart` instance; remount the component to initialize a new chart.
423
+
329
424
  > [!NOTE]
330
425
  > The following ECharts instance methods aren't exposed because their functionality is already provided by component [props](#props):
331
426
  >
332
- > - [`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.
427
+ > - [`showLoading`](https://echarts.apache.org/en/api.html#echartsInstance.showLoading) / [`hideLoading`](https://echarts.apache.org/en/api.html#echartsInstance.hideLoading): use the `loading`, `loading-type` and `loading-options` props instead.
333
428
  > - [`setTheme`](https://echarts.apache.org/en/api.html#echartsInstance.setTheme): use the `theme` prop instead.
334
429
 
335
430
  ### Slots
@@ -345,16 +440,21 @@ Vue ECharts supports three slot categories:
345
440
  These naming rules apply to callback slots only. The graphic slot name is always `#graphic`.
346
441
 
347
442
  - Slot names begin with `tooltip`/`dataView`, followed by hyphen-separated path segments to the target.
348
- - Each segment corresponds to an `option` property name or an array index (for arrays, use the numeric index).
443
+ - If `tooltip` or `toolbox` is an array, place its numeric component index immediately after the slot prefix; any remaining segments still locate the owning option.
444
+ - Each non-empty segment corresponds to an `option` property name or an array index (for arrays, use the numeric index).
445
+ - Array segments are patched only when the corresponding array entries already exist; callback slots do not create missing component or data arrays.
446
+ - The reserved JavaScript path segment `__proto__` is rejected.
349
447
  - The constructed slot name maps directly to the nested callback it overrides.
350
448
 
351
449
  **Example mappings**:
352
450
 
353
451
  - `tooltip` → `option.tooltip.formatter`
452
+ - `tooltip-0` → `option.tooltip[0].formatter`
354
453
  - `tooltip-baseOption` → `option.baseOption.tooltip.formatter`
355
454
  - `tooltip-xAxis-1` → `option.xAxis[1].tooltip.formatter`
356
455
  - `tooltip-series-2-data-4` → `option.series[2].data[4].tooltip.formatter`
357
456
  - `dataView` → `option.toolbox.feature.dataView.optionToContent`
457
+ - `dataView-1` → `option.toolbox[1].feature.dataView.optionToContent`
358
458
  - `dataView-media-1-option` → `option.media[1].option.toolbox.feature.dataView.optionToContent`
359
459
 
360
460
  The slot props correspond to the first parameter of the callback function.
@@ -407,6 +507,8 @@ The slot props correspond to the first parameter of the callback function.
407
507
 
408
508
  > [!NOTE]
409
509
  > Slots take precedence over the corresponding callback defined in `props.option`.
510
+ > Removing a callback slot explicitly clears its injected function without rebuilding the chart.
511
+ > After adding or removing a callback slot in `manual-update` mode, call `chartRef.setOption(...)` to submit the latest slot set.
410
512
 
411
513
  #### Graphic slot&nbsp;<sup><a href="#slots"><img src="https://img.shields.io/badge/new-A855F7" alt="new" align="middle" height="16"></a></sup>
412
514
 
@@ -419,6 +521,7 @@ Available components:
419
521
  - `GGroup`
420
522
  - `GRect`
421
523
  - `GCircle`
524
+ - `GEllipse`
422
525
  - `GText`
423
526
  - `GLine`
424
527
  - `GPolyline`
@@ -428,7 +531,6 @@ Available components:
428
531
  - `GRing`
429
532
  - `GArc`
430
533
  - `GBezierCurve`
431
- - `GCompoundPath`
432
534
 
433
535
  Read more at [ECharts `option.graphic` →](https://echarts.apache.org/en/option.html#graphic)
434
536
 
@@ -436,6 +538,9 @@ Read more at [ECharts `option.graphic` →](https://echarts.apache.org/en/option
436
538
  >
437
539
  > - Graphic element events additionally support `dblclick` and `contextmenu`.
438
540
  > - Event listeners support the `.once` modifier.
541
+ > - Returning `true` from a graphic element listener stops the event from bubbling.
542
+ > - Path components accept `auto-batch` to opt into ZRender's Canvas path batching.
543
+ > - The `option` prop may be omitted for graphic-only charts.
439
544
  > - `#graphic` overrides `option.graphic`. In `manual-update` mode, call `chartRef.setOption(...)` to apply changes.
440
545
 
441
546
  <details>
@@ -469,7 +574,7 @@ function onDrag(event: ElementEvent) {
469
574
  :x="10"
470
575
  :y="8"
471
576
  :text="`x: ${Math.round(overlay.x)} y: ${Math.round(overlay.y)}`"
472
- text-fill="#fff"
577
+ fill="#fff"
473
578
  />
474
579
  </GGroup>
475
580
  </template>
@@ -485,6 +590,10 @@ Static methods can be accessed from [`echarts` itself](https://echarts.apache.or
485
590
 
486
591
  ## CSP: `style-src` or `style-src-elem`
487
592
 
593
+ Vue ECharts injects its base styles into the global document when its module is evaluated. Shadow
594
+ roots and other documents do not receive these styles; include `vue-echarts/style.css` in each
595
+ target styling scope when needed.
596
+
488
597
  If you are **both** enforcing a strict CSP that prevents inline `<style>` injection and targeting browsers that don't support the [CSSStyleSheet() constructor](https://developer.mozilla.org/en-US/docs/Web/API/CSSStyleSheet/CSSStyleSheet#browser_compatibility), you need to manually include `vue-echarts/style.css`.
489
598
 
490
599
  ## Migration to v8