Skip to content

Commit

Permalink
feat: add basic types for events
Browse files Browse the repository at this point in the history
  • Loading branch information
Justineo committed Dec 18, 2022
1 parent 5f57d3f commit 0bb1839
Show file tree
Hide file tree
Showing 7 changed files with 93 additions and 16 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 6.3.2

* Added basic types for events (only event names).

## 6.3.1

* Revert the style change to prevent tooltips from being clipped.
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -308,9 +308,9 @@ Drop `<script>` inside your HTML file and access the component via `window.VueEC

<!-- vue3Scripts:start -->
```html
<script src="https://cdn.jsdelivr.net/npm/[email protected].45"></script>
<script src="https://cdn.jsdelivr.net/npm/echarts@5.4.1"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected].1"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected].37"></script>
<script src="https://cdn.jsdelivr.net/npm/echarts@5.3.3"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected].2"></script>
```
<!-- vue3Scripts:end -->

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

<!-- vue2Scripts:start -->
```html
<script src="https://cdn.jsdelivr.net/npm/[email protected].14"></script>
<script src="https://cdn.jsdelivr.net/npm/echarts@5.4.1"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected].1"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected].5"></script>
<script src="https://cdn.jsdelivr.net/npm/echarts@5.3.3"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected].2"></script>
```
<!-- vue2Scripts:end -->

Expand Down
12 changes: 6 additions & 6 deletions README.zh-Hans.md
Original file line number Diff line number Diff line change
Expand Up @@ -307,9 +307,9 @@ export default {

<!-- vue3Scripts:start -->
```html
<script src="https://cdn.jsdelivr.net/npm/[email protected].45"></script>
<script src="https://cdn.jsdelivr.net/npm/echarts@5.4.1"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected].1"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected].37"></script>
<script src="https://cdn.jsdelivr.net/npm/echarts@5.3.3"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected].2"></script>
```
<!-- vue3Scripts:end -->

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

<!-- vue2Scripts:start -->
```html
<script src="https://cdn.jsdelivr.net/npm/[email protected].14"></script>
<script src="https://cdn.jsdelivr.net/npm/echarts@5.4.1"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected].1"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected].5"></script>
<script src="https://cdn.jsdelivr.net/npm/echarts@5.3.3"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected].2"></script>
```
<!-- vue2Scripts:end -->

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vue-echarts",
"version": "6.3.1",
"version": "6.3.2",
"description": "Vue.js component for Apache ECharts.",
"author": "GU Yiling <[email protected]>",
"scripts": {
Expand Down
4 changes: 3 additions & 1 deletion src/ECharts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ import type {
InitOptions,
InitOptionsInjection,
UpdateOptions,
UpdateOptionsInjection
UpdateOptionsInjection,
Emits
} from "./types";
import {
usePublicAPI,
Expand Down Expand Up @@ -66,6 +67,7 @@ export default defineComponent({
...autoresizeProps,
...loadingProps
},
emits: [] as unknown as Emits,
inheritAttrs: false,
setup(props, { attrs }) {
const root = shallowRef<HTMLElement>();
Expand Down
13 changes: 11 additions & 2 deletions src/index.vue2.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
/* eslint-disable @typescript-eslint/ban-types */
import type { Ref, DefineComponent } from "vue-demi";
import type { Option, InitOptions, UpdateOptions, EChartsType } from "./types";
import type {
Option,
InitOptions,
UpdateOptions,
EChartsType,
Emits
} from "./types";

declare const LOADING_OPTIONS_KEY = "ecLoadingOptions";
declare const THEME_KEY = "ecTheme";
Expand Down Expand Up @@ -47,7 +53,10 @@ declare const Chart: DefineComponent<
},
{},
{},
ChartMethods
ChartMethods,
{},
{},
Emits
>;

export default Chart;
Expand Down
62 changes: 62 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,65 @@ type ZRenderType = ReturnType<EChartsType["getZr"]>;
export type EventTarget = EChartsType | ZRenderType;
type SetOptionType = EChartsType["setOption"];
export type Option = Parameters<SetOptionType>[0];

type EChartsEventName =
| "click"
| "dblclick"
| "mousedown"
| "mousemove"
| "mouseup"
| "mouseover"
| "mouseout"
| "globalout"
| "contextmenu"
| "highlight"
| "downplay"
| "selectchanged"
| "legendselectchanged"
| "legendselected"
| "legendunselected"
| "legendselectall"
| "legendinverseselect"
| "legendscroll"
| "datazoom"
| "datarangeselected"
| "graphroam"
| "georoam"
| "treeroam"
| "timelinechanged"
| "timelineplaychanged"
| "restore"
| "dataviewchanged"
| "magictypechanged"
| "geoselectchanged"
| "geoselected"
| "geounselected"
| "axisareaselected"
| "brush"
| "brushEnd"
| "brushselected"
| "globalcursortaken"
| "rendered"
| "finished";
type ZRenderEventName =
| "click"
| "dblclick"
| "mousewheel"
| "mouseout"
| "mouseover"
| "mouseup"
| "mousedown"
| "mousemove"
| "contextmenu"
| "drag"
| "dragstart"
| "dragend"
| "dragenter"
| "dragleave"
| "dragover"
| "drop"
| "globalout";
type EventName = EChartsEventName | `zr:${ZRenderEventName}`;
export type Emits = {
[key in EventName]: null;
};

1 comment on commit 0bb1839

@vercel
Copy link

@vercel vercel bot commented on 0bb1839 Dec 18, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.