Skip to content
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
5 changes: 5 additions & 0 deletions packages/vchart/src/chart/base/base-chart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,11 @@ export class BaseChart<T extends IChartSpec> extends CompilableBase implements I
elements.forEach(element => element.onEvaluateEnd(option));
}

onBeforeRender() {
const elements = [...this._components, ...this._regions, ...this._series];
elements.forEach(element => element.onBeforeRender());
}

getLayoutElements(): ILayoutItem[] {
return this.getAllModels()
.map(i => i.layout)
Expand Down
2 changes: 2 additions & 0 deletions packages/vchart/src/chart/interface/chart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ export interface IChart extends ICompilable {
onEvaluateEnd: (ctx: IChartEvaluateOption) => void;
onResize: (width: number, height: number, reRender: boolean) => void;
onLayout: () => void;
onBeforeRender: () => void;

/**
* 图表更新的时候按需调用
* @since 1.11.0
Expand Down
5 changes: 4 additions & 1 deletion packages/vchart/src/compile/compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,10 @@ export class Compiler implements ICompiler {
dpr,
viewBox: this._option.viewBox,
canvasControled: this._option.canvasControled,
beforeRender: this._option.beforeRender,
beforeRender: (stage: IStage) => {
this._compileChart?.onBeforeRender();
this._option.beforeRender?.(stage);
},
afterRender: this._option.afterRender,
disableDirtyBounds: true,
autoRender: true,
Expand Down
1 change: 1 addition & 0 deletions packages/vchart/src/component/axis/base-axis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ export abstract class AxisComponent<T extends ICommonAxisSpec & Record<string, a

protected _dataFieldText: string;
protected _axisMark: IComponentMark;

protected _gridMark: IComponentMark;

protected _coordinateType: CoordinateType;
Expand Down
1 change: 1 addition & 0 deletions packages/vchart/src/component/axis/interface/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type { CoordinateType, Datum, IPolarOrientType, StringOrNumber } from '..
import type { IComponent } from '../../interface/common';
import type { ICartesianAxisSpec } from '../cartesian/interface';
import type { ITextGraphicAttribute } from '@visactor/vrender-core';
import type { IComponentMark } from '../../../mark/interface';

export interface StatisticsDomain {
domain: any[];
Expand Down
2 changes: 1 addition & 1 deletion packages/vchart/src/component/crosshair/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ export abstract class BaseCrossHair<T extends ICartesianCrosshairSpec | IPolarCr
}
}

updateLayoutAttribute() {
onBeforeRender(): void {
this._limitBounds = null;
this._showDefaultCrosshair();
}
Expand Down
2 changes: 1 addition & 1 deletion packages/vchart/src/component/crosshair/utils/cartesian.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export const layoutByValue = (
axis = item.axis;
axisLabel = axis
.getVRenderComponents()[0]
?.children[0]?.children[0]?.getChildByName('axis-label-container')
?.children[0]?.children[0]?.children[0]?.getChildByName('axis-label-container')
?.getChildByName('axis-label-container-layer-0')?.children[0];
}
const isVisible = !!currentValue.size && Number.isFinite(coord) && !Number.isNaN(coord);
Expand Down
4 changes: 4 additions & 0 deletions packages/vchart/src/model/base-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,10 @@ export abstract class BaseModel<T extends IModelSpec> extends CompilableBase imp
// do nothing
}

onBeforeRender() {
// do nothing
}

onDataUpdate() {
// do nothing
}
Expand Down
1 change: 1 addition & 0 deletions packages/vchart/src/model/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ export interface IModel extends ICompilable {

onEvaluateEnd: (ctx: IModelEvaluateOption) => void;
onDataUpdate: () => void;
onBeforeRender: () => void;

updateSpec: (spec: any, totalSpec?: any) => IUpdateSpecResult;
getSpec?: () => any;
Expand Down
Loading