Skip to content

Commit 084d5d1

Browse files
committed
feat: vchart support clickInterval params
1 parent 15d4b5e commit 084d5d1

File tree

2 files changed

+38
-9
lines changed

2 files changed

+38
-9
lines changed

packages/vchart/src/compile/compiler.ts

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -106,21 +106,32 @@ export class Compiler implements ICompiler {
106106
this._option?.onError?.(...args);
107107
});
108108
}
109+
const {
110+
performanceHook,
111+
autoRefreshDpr,
112+
dpr,
113+
mode,
114+
gestureConfig,
115+
interactive,
116+
clickInterval,
117+
autoPreventDefault,
118+
...restOption
119+
} = this._option;
109120
this._view = new View({
110121
width: this._width,
111122
height: this._height,
112123
container: this._container.dom ?? null,
113124
renderCanvas: this._container.canvas ?? null,
114-
hooks: (this._option as any).performanceHook, // vgrammar 事件改造后,性能回调函数放在了hooks中实现
115-
...this._option,
116-
autoRefresh: isValid(this._option.autoRefreshDpr) ? this._option.autoRefreshDpr : !isValid(this._option.dpr),
117-
mode: toRenderMode(this._option.mode),
125+
hooks: performanceHook, // vgrammar 事件改造后,性能回调函数放在了hooks中实现
126+
...restOption,
127+
autoRefresh: isValid(autoRefreshDpr) ? autoRefreshDpr : !isValid(dpr),
128+
mode: toRenderMode(mode),
118129
autoFit: false,
119130
eventConfig: {
120-
gesture: isValid(this._option.gestureConfig)
121-
? (this._option.gestureConfig as any)
122-
: isMobileLikeMode(this._option.mode),
123-
disable: this._option.interactive === false
131+
gesture: isValid(gestureConfig) ? (gestureConfig as any) : isMobileLikeMode(mode),
132+
disable: interactive === false,
133+
clickInterval,
134+
autoPreventDefault
124135
},
125136
doLayout: () => {
126137
this._compileChart?.onLayout(this._view);
@@ -133,7 +144,6 @@ export class Compiler implements ICompiler {
133144
// emit afterRender event
134145
this.getStage().hooks.afterRender.tap('chart-event', this.handleStageRender);
135146

136-
const interactive = this._option.interactive;
137147
if (interactive !== false) {
138148
// 将 view 实例化之前监听的事件挂载到 view 上
139149
this._viewListeners.forEach(listener => {

packages/vchart/src/compile/interface/compiler.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import type { Hooks } from '@visactor/vgrammar-core';
12
import type { IColor, IStageParams, IStage, ILayer } from '@visactor/vrender-core';
23
import type { RenderMode } from '../../typings/spec/common';
34
import type { IBoundsLike } from '@visactor/vutils';
@@ -170,4 +171,22 @@ export interface IRenderOption {
170171
* 用于vrender渲染react元素,`react-dom`包导出元素
171172
*/
172173
ReactDOM?: any;
174+
/**
175+
* @since 1.13.2
176+
* @default 200
177+
* 单位 ms
178+
* 多次点击之间的最大时间,默认为 200 ms,用于判断点击次数
179+
*/
180+
clickInterval?: number;
181+
/**
182+
* @since 1.13.2
183+
* @default false
184+
* VRender 参数 是否自动阻止事件
185+
*/
186+
autoPreventDefault?: boolean;
187+
/**
188+
* @deprecated
189+
* 请使用 hooks 代替
190+
*/
191+
performanceHook?: Hooks;
173192
}

0 commit comments

Comments
 (0)