Files
vueecharts/src/types.ts
Yue JIN a6ad4e70a2 feat: rendering tooltips and dataView with slots (#838)
* feat: experimental component rendered tooltip

* revert slot in VChart

* feat: use tooltip composable

* feat: try createApp

* feat: use pie chart as tooltip

* feat: switch to createVNode

The limitation is that the tooltip detached from the current component tree, not provide/inject

will try teleport next

* feat: try component with teleport

* wip

* add xAxis example

* refactor with shallowReactive

* Support dynamic slot

* fix: fill empty elements with object in array

* shallow copy option along the path

* ssr friendly

* vibe docs

* typo

* update according to the review

* add dataView slot

* chore: fix warnings and errors in demo (#839)

* chore: suppress warning in demo

* chore: prevent multiple intializations of esbuild-wasm in demo HMR

* feat: dynamically update the theme (#841)

Co-authored-by: GU Yiling <justice360@gmail.com>

* feat: add dataView slot

* vibe docs

---------

Co-authored-by: GU Yiling <justice360@gmail.com>

* fix docs typo

* update according to the review

* small fix

* remove wrapper around slotProp

* update comments

* remove anys

* add tooltip slot prop type

* target to vue 3.3

* move slot related codes to slot.ts

---------

Co-authored-by: GU Yiling <justice360@gmail.com>
2025-08-10 23:36:36 +08:00

115 lines
2.5 KiB
TypeScript

import { init } from "echarts/core";
import type { SetOptionOpts, ECElementEvent, ElementEvent } from "echarts/core";
import type { MaybeRefOrGetter } from "vue";
export type Injection<T> = MaybeRefOrGetter<T | null>;
type InitType = typeof init;
export type InitParameters = Parameters<InitType>;
export type Theme = NonNullable<InitParameters[1]>;
export type ThemeInjection = Injection<Theme>;
export type InitOptions = NonNullable<InitParameters[2]>;
export type InitOptionsInjection = Injection<InitOptions>;
export type UpdateOptions = SetOptionOpts;
export type UpdateOptionsInjection = Injection<UpdateOptions>;
export type EChartsType = ReturnType<InitType>;
export type SetOptionType = EChartsType["setOption"];
export type Option = Parameters<SetOptionType>[0];
export type AutoResize =
| boolean
| {
throttle?: number;
onResize?: () => void;
};
export type LoadingOptions = {
text?: string;
textColor?: string;
fontSize?: number | string;
fontWeight?: number | string;
fontStyle?: string;
fontFamily?: string;
maskColor?: string;
showSpinner?: boolean;
color?: string;
spinnerRadius?: number;
lineWidth?: number;
zlevel?: number;
};
export type LoadingOptionsInjection = Injection<LoadingOptions>;
type MouseEventName =
| "click"
| "dblclick"
| "mouseout"
| "mouseover"
| "mouseup"
| "mousedown"
| "mousemove"
| "contextmenu"
| "globalout";
type ElementEventName =
| MouseEventName
| "mousewheel"
| "drag"
| "dragstart"
| "dragend"
| "dragenter"
| "dragleave"
| "dragover"
| "drop";
type ZRenderEventName = `zr:${ElementEventName}`;
type OtherEventName =
| "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";
type MouseEmits = {
[key in MouseEventName]: (params: ECElementEvent) => void;
};
type ZRenderEmits = {
[key in ZRenderEventName]: (params: ElementEvent) => void;
};
type OtherEmits = {
[key in OtherEventName]: (params: any) => void;
};
export type Emits = MouseEmits &
OtherEmits & {
rendered: (params: { elapsedTime: number }) => void;
finished: () => void;
} & ZRenderEmits;