diff --git a/common/changes/@visactor/vchart/feat-support-clickInterval-for-dblclick_2024-12-20-07-55.json b/common/changes/@visactor/vchart/feat-support-clickInterval-for-dblclick_2024-12-20-07-55.json new file mode 100644 index 0000000000..6810a9c093 --- /dev/null +++ b/common/changes/@visactor/vchart/feat-support-clickInterval-for-dblclick_2024-12-20-07-55.json @@ -0,0 +1,10 @@ +{ + "changes": [ + { + "packageName": "@visactor/vchart", + "comment": "feat: vchart support clickInterval params", + "type": "none" + } + ], + "packageName": "@visactor/vchart" +} \ No newline at end of file diff --git a/packages/vchart/src/compile/compiler.ts b/packages/vchart/src/compile/compiler.ts index 9adcdd00c7..18c0a00692 100644 --- a/packages/vchart/src/compile/compiler.ts +++ b/packages/vchart/src/compile/compiler.ts @@ -106,21 +106,32 @@ export class Compiler implements ICompiler { this._option?.onError?.(...args); }); } + const { + performanceHook, + autoRefreshDpr, + dpr, + mode, + gestureConfig, + interactive, + clickInterval, + autoPreventDefault, + ...restOption + } = this._option; this._view = new View({ width: this._width, height: this._height, container: this._container.dom ?? null, renderCanvas: this._container.canvas ?? null, - hooks: (this._option as any).performanceHook, // vgrammar 事件改造后,性能回调函数放在了hooks中实现 - ...this._option, - autoRefresh: isValid(this._option.autoRefreshDpr) ? this._option.autoRefreshDpr : !isValid(this._option.dpr), - mode: toRenderMode(this._option.mode), + hooks: performanceHook, // vgrammar 事件改造后,性能回调函数放在了hooks中实现 + ...restOption, + autoRefresh: isValid(autoRefreshDpr) ? autoRefreshDpr : !isValid(dpr), + mode: toRenderMode(mode), autoFit: false, eventConfig: { - gesture: isValid(this._option.gestureConfig) - ? (this._option.gestureConfig as any) - : isMobileLikeMode(this._option.mode), - disable: this._option.interactive === false + gesture: isValid(gestureConfig) ? (gestureConfig as any) : isMobileLikeMode(mode), + disable: interactive === false, + clickInterval, + autoPreventDefault }, doLayout: () => { this._compileChart?.onLayout(this._view); @@ -133,7 +144,6 @@ export class Compiler implements ICompiler { // emit afterRender event this.getStage().hooks.afterRender.tap('chart-event', this.handleStageRender); - const interactive = this._option.interactive; if (interactive !== false) { // 将 view 实例化之前监听的事件挂载到 view 上 this._viewListeners.forEach(listener => { diff --git a/packages/vchart/src/compile/interface/compiler.ts b/packages/vchart/src/compile/interface/compiler.ts index 8a5de79bd8..eedcfe354d 100644 --- a/packages/vchart/src/compile/interface/compiler.ts +++ b/packages/vchart/src/compile/interface/compiler.ts @@ -1,3 +1,4 @@ +import type { Hooks } from '@visactor/vgrammar-core'; import type { IColor, IStageParams, IStage, ILayer } from '@visactor/vrender-core'; import type { RenderMode } from '../../typings/spec/common'; import type { IBoundsLike } from '@visactor/vutils'; @@ -170,4 +171,22 @@ export interface IRenderOption { * 用于vrender渲染react元素,`react-dom`包导出元素 */ ReactDOM?: any; + /** + * @since 1.13.2 + * @default 200 + * 单位 ms + * 多次点击之间的最大时间,默认为 200 ms,用于判断点击次数 + */ + clickInterval?: number; + /** + * @since 1.13.2 + * @default false + * VRender 参数 是否自动阻止事件 + */ + autoPreventDefault?: boolean; + /** + * @deprecated + * 请使用 hooks 代替 + */ + performanceHook?: Hooks; }