Skip to content

Commit 264082d

Browse files
authored
Merge pull request #3621 from VisActor/feat/package-some-hook-in-grammar
Feat/package some hook in grammar
2 parents a51bc2e + ee3237d commit 264082d

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"changes": [
3+
{
4+
"comment": "feat: package some hook in vgrammar\n\n",
5+
"type": "none",
6+
"packageName": "@visactor/vchart"
7+
}
8+
],
9+
"packageName": "@visactor/vchart",
10+
"email": "[email protected]"
11+
}

packages/vchart/src/core/vchart.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { ISeries } from '../series/interface/series';
22
import { arrayParser } from '../data/parser/array';
33
import type { ILayoutConstructor, LayoutCallBack } from '../layout/interface';
4-
import type { IDataValues, IMarkStateSpec, IInitOption } from '../typings/spec/common';
4+
import type { IDataValues, IMarkStateSpec, IInitOption, IPerformanceHook } from '../typings/spec/common';
55
// eslint-disable-next-line no-duplicate-imports
66
import { RenderModeEnum } from '../typings/spec/common';
77
import type { ISeriesConstructor } from '../series/interface';
@@ -414,6 +414,16 @@ export class VChart implements IVChart {
414414
// 桑基图默认记载滚动条组件
415415
pluginList.push('scrollbar');
416416
}
417+
// hook增加图表实例参数
418+
const performanceHook = { ...(restOptions.performanceHook || {}) };
419+
(Object.keys(performanceHook) as (keyof IPerformanceHook)[]).forEach(hookKey => {
420+
// @ts-ignore
421+
restOptions.performanceHook[hookKey] = (...args) => {
422+
// @ts-ignore
423+
performanceHook[hookKey](...args, this as any);
424+
};
425+
});
426+
417427
this._compiler = new Compiler(
418428
{
419429
dom: this._container ?? 'none',

packages/vchart/src/typings/spec/common.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -634,6 +634,9 @@ export interface IPerformanceHook {
634634
beforeCreateVRenderMark?: () => void;
635635
afterCreateVRenderMark?: () => void;
636636

637+
// VGrammar 创建元素完成,vrender 绘图之前
638+
beforeDoRender?: (vchart?: IVChart) => void;
639+
637640
// VRender Draw 时间
638641
beforeVRenderDraw?: () => void;
639642
afterVRenderDraw?: () => void;

0 commit comments

Comments
 (0)