Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/package some hook in grammar #3621

Merged
merged 3 commits into from
Dec 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading