Skip to content

Commit 0bb1839

Browse files
committed
feat: add basic types for events
1 parent 5f57d3f commit 0bb1839

File tree

7 files changed

+93
-16
lines changed

7 files changed

+93
-16
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 6.3.2
2+
3+
* Added basic types for events (only event names).
4+
15
## 6.3.1
26

37
* Revert the style change to prevent tooltips from being clipped.

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -308,9 +308,9 @@ Drop `<script>` inside your HTML file and access the component via `window.VueEC
308308

309309
<!-- vue3Scripts:start -->
310310
```html
311-
<script src="https://cdn.jsdelivr.net/npm/[email protected].45"></script>
312-
<script src="https://cdn.jsdelivr.net/npm/echarts@5.4.1"></script>
313-
<script src="https://cdn.jsdelivr.net/npm/[email protected].1"></script>
311+
<script src="https://cdn.jsdelivr.net/npm/[email protected].37"></script>
312+
<script src="https://cdn.jsdelivr.net/npm/echarts@5.3.3"></script>
313+
<script src="https://cdn.jsdelivr.net/npm/[email protected].2"></script>
314314
```
315315
<!-- vue3Scripts:end -->
316316

@@ -328,9 +328,9 @@ app.component('v-chart', VueECharts)
328328

329329
<!-- vue2Scripts:start -->
330330
```html
331-
<script src="https://cdn.jsdelivr.net/npm/[email protected].14"></script>
332-
<script src="https://cdn.jsdelivr.net/npm/echarts@5.4.1"></script>
333-
<script src="https://cdn.jsdelivr.net/npm/[email protected].1"></script>
331+
<script src="https://cdn.jsdelivr.net/npm/[email protected].5"></script>
332+
<script src="https://cdn.jsdelivr.net/npm/echarts@5.3.3"></script>
333+
<script src="https://cdn.jsdelivr.net/npm/[email protected].2"></script>
334334
```
335335
<!-- vue2Scripts:end -->
336336

README.zh-Hans.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -307,9 +307,9 @@ export default {
307307

308308
<!-- vue3Scripts:start -->
309309
```html
310-
<script src="https://cdn.jsdelivr.net/npm/[email protected].45"></script>
311-
<script src="https://cdn.jsdelivr.net/npm/echarts@5.4.1"></script>
312-
<script src="https://cdn.jsdelivr.net/npm/[email protected].1"></script>
310+
<script src="https://cdn.jsdelivr.net/npm/[email protected].37"></script>
311+
<script src="https://cdn.jsdelivr.net/npm/echarts@5.3.3"></script>
312+
<script src="https://cdn.jsdelivr.net/npm/[email protected].2"></script>
313313
```
314314
<!-- vue3Scripts:end -->
315315

@@ -327,9 +327,9 @@ app.component('v-chart', VueECharts)
327327

328328
<!-- vue2Scripts:start -->
329329
```html
330-
<script src="https://cdn.jsdelivr.net/npm/[email protected].14"></script>
331-
<script src="https://cdn.jsdelivr.net/npm/echarts@5.4.1"></script>
332-
<script src="https://cdn.jsdelivr.net/npm/[email protected].1"></script>
330+
<script src="https://cdn.jsdelivr.net/npm/[email protected].5"></script>
331+
<script src="https://cdn.jsdelivr.net/npm/echarts@5.3.3"></script>
332+
<script src="https://cdn.jsdelivr.net/npm/[email protected].2"></script>
333333
```
334334
<!-- vue2Scripts:end -->
335335

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vue-echarts",
3-
"version": "6.3.1",
3+
"version": "6.3.2",
44
"description": "Vue.js component for Apache ECharts.",
55
"author": "GU Yiling <[email protected]>",
66
"scripts": {

src/ECharts.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ import type {
2727
InitOptions,
2828
InitOptionsInjection,
2929
UpdateOptions,
30-
UpdateOptionsInjection
30+
UpdateOptionsInjection,
31+
Emits
3132
} from "./types";
3233
import {
3334
usePublicAPI,
@@ -66,6 +67,7 @@ export default defineComponent({
6667
...autoresizeProps,
6768
...loadingProps
6869
},
70+
emits: [] as unknown as Emits,
6971
inheritAttrs: false,
7072
setup(props, { attrs }) {
7173
const root = shallowRef<HTMLElement>();

src/index.vue2.d.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
/* eslint-disable @typescript-eslint/ban-types */
22
import type { Ref, DefineComponent } from "vue-demi";
3-
import type { Option, InitOptions, UpdateOptions, EChartsType } from "./types";
3+
import type {
4+
Option,
5+
InitOptions,
6+
UpdateOptions,
7+
EChartsType,
8+
Emits
9+
} from "./types";
410

511
declare const LOADING_OPTIONS_KEY = "ecLoadingOptions";
612
declare const THEME_KEY = "ecTheme";
@@ -47,7 +53,10 @@ declare const Chart: DefineComponent<
4753
},
4854
{},
4955
{},
50-
ChartMethods
56+
ChartMethods,
57+
{},
58+
{},
59+
Emits
5160
>;
5261

5362
export default Chart;

src/types.ts

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,65 @@ type ZRenderType = ReturnType<EChartsType["getZr"]>;
1919
export type EventTarget = EChartsType | ZRenderType;
2020
type SetOptionType = EChartsType["setOption"];
2121
export type Option = Parameters<SetOptionType>[0];
22+
23+
type EChartsEventName =
24+
| "click"
25+
| "dblclick"
26+
| "mousedown"
27+
| "mousemove"
28+
| "mouseup"
29+
| "mouseover"
30+
| "mouseout"
31+
| "globalout"
32+
| "contextmenu"
33+
| "highlight"
34+
| "downplay"
35+
| "selectchanged"
36+
| "legendselectchanged"
37+
| "legendselected"
38+
| "legendunselected"
39+
| "legendselectall"
40+
| "legendinverseselect"
41+
| "legendscroll"
42+
| "datazoom"
43+
| "datarangeselected"
44+
| "graphroam"
45+
| "georoam"
46+
| "treeroam"
47+
| "timelinechanged"
48+
| "timelineplaychanged"
49+
| "restore"
50+
| "dataviewchanged"
51+
| "magictypechanged"
52+
| "geoselectchanged"
53+
| "geoselected"
54+
| "geounselected"
55+
| "axisareaselected"
56+
| "brush"
57+
| "brushEnd"
58+
| "brushselected"
59+
| "globalcursortaken"
60+
| "rendered"
61+
| "finished";
62+
type ZRenderEventName =
63+
| "click"
64+
| "dblclick"
65+
| "mousewheel"
66+
| "mouseout"
67+
| "mouseover"
68+
| "mouseup"
69+
| "mousedown"
70+
| "mousemove"
71+
| "contextmenu"
72+
| "drag"
73+
| "dragstart"
74+
| "dragend"
75+
| "dragenter"
76+
| "dragleave"
77+
| "dragover"
78+
| "drop"
79+
| "globalout";
80+
type EventName = EChartsEventName | `zr:${ZRenderEventName}`;
81+
export type Emits = {
82+
[key in EventName]: null;
83+
};

0 commit comments

Comments
 (0)