Skip to content

Commit

Permalink
Merge pull request #3621 from VisActor/feat/package-some-hook-in-grammar
Browse files Browse the repository at this point in the history
Feat/package some hook in grammar
  • Loading branch information
xile611 authored Dec 27, 2024
2 parents a51bc2e + ee3237d commit 264082d
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"comment": "feat: package some hook in vgrammar\n\n",
"type": "none",
"packageName": "@visactor/vchart"
}
],
"packageName": "@visactor/vchart",
"email": "[email protected]"
}
12 changes: 11 additions & 1 deletion packages/vchart/src/core/vchart.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { ISeries } from '../series/interface/series';
import { arrayParser } from '../data/parser/array';
import type { ILayoutConstructor, LayoutCallBack } from '../layout/interface';
import type { IDataValues, IMarkStateSpec, IInitOption } from '../typings/spec/common';
import type { IDataValues, IMarkStateSpec, IInitOption, IPerformanceHook } from '../typings/spec/common';
// eslint-disable-next-line no-duplicate-imports
import { RenderModeEnum } from '../typings/spec/common';
import type { ISeriesConstructor } from '../series/interface';
Expand Down Expand Up @@ -414,6 +414,16 @@ export class VChart implements IVChart {
// 桑基图默认记载滚动条组件
pluginList.push('scrollbar');
}
// hook增加图表实例参数
const performanceHook = { ...(restOptions.performanceHook || {}) };
(Object.keys(performanceHook) as (keyof IPerformanceHook)[]).forEach(hookKey => {
// @ts-ignore
restOptions.performanceHook[hookKey] = (...args) => {
// @ts-ignore
performanceHook[hookKey](...args, this as any);
};
});

this._compiler = new Compiler(
{
dom: this._container ?? 'none',
Expand Down
3 changes: 3 additions & 0 deletions packages/vchart/src/typings/spec/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -634,6 +634,9 @@ export interface IPerformanceHook {
beforeCreateVRenderMark?: () => void;
afterCreateVRenderMark?: () => void;

// VGrammar 创建元素完成,vrender 绘图之前
beforeDoRender?: (vchart?: IVChart) => void;

// VRender Draw 时间
beforeVRenderDraw?: () => void;
afterVRenderDraw?: () => void;
Expand Down

0 comments on commit 264082d

Please sign in to comment.