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/support vtable #194

Merged
merged 6 commits into from
Dec 26, 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
89 changes: 50 additions & 39 deletions common/config/rush/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/vstory-animate/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
},
"dependencies": {
"@visactor/vchart": "1.13.2-vstory.2",
"@visactor/vtable": "1.10.1",
"@visactor/vtable": "1.14.1",
"@visactor/vrender": "0.21.5-vstory.2",
"@visactor/vrender-core": "0.21.5-vstory.2",
"@visactor/vrender-kits": "0.21.5-vstory.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/vstory-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
},
"dependencies": {
"@visactor/vchart": "1.13.2-vstory.2",
"@visactor/vtable": "1.10.1",
"@visactor/vtable": "1.14.1",
"@visactor/vrender": "0.21.5-vstory.2",
"@visactor/vrender-core": "0.21.5-vstory.2",
"@visactor/vrender-kits": "0.21.5-vstory.2",
Expand Down
14 changes: 7 additions & 7 deletions packages/vstory-core/src/character/chart/character-chart.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { IGraphic, ITicker, ITimeline } from '@visactor/vrender-core';
import type { ITicker, ITimeline } from '@visactor/vrender-core';
import { DefaultTimeline, ManualTicker } from '@visactor/vrender-core';
import type { ICharacterPickInfo, IStoryEvent } from '../../interface/event';
import { CharacterBase } from '../character-base';
Expand All @@ -10,7 +10,7 @@ import type { IChartCharacterConfig } from '../../interface/dsl/chart';
import { getLayoutFromWidget } from '../../utils/layout';
import type { IChartCharacterRuntime, IUpdateConfigParams } from './interface/runtime';
import { CommonSpecRuntimeInstance } from './runtime/common-spec';
import { CommonLayoutRuntimeInstance } from './runtime/common-layout';
import { CommonLayoutRuntimeInstance } from '../common/runtime/common-layout';
import { ChartConfigProcess } from './chart-config-process';
import type { ICharacterChart } from './interface/character-chart';
import { mergeChartOption } from '../../utils/chart';
Expand All @@ -26,8 +26,8 @@ export class CharacterChart<T extends IChartGraphicAttribute>
protected declare _graphic: VChartGraphic;
protected declare _config: IChartCharacterConfig;

// 临时记录 vchart 对象。在第一次执行 afterInitializeChart 后赋值, 在 afterVRenderDraw 中使用
// 不临时记录的话,第一次 afterVRenderDraw 时,graphic 对象还未执行完初始化,当前对象的 _graphic 为 null
// 临时记录 vchart 对象。在第一次执行 afterInitializeChart 后赋值, 在 beforeVRenderDraw 中使用
// 不临时记录的话,第一次 beforeVRenderDraw 时,graphic 对象还未执行完初始化,当前对象的 _graphic 为 null
protected _vchart: IVChart;

protected _ticker: ITicker;
Expand Down Expand Up @@ -207,9 +207,9 @@ export class CharacterChart<T extends IChartGraphicAttribute>
this._vchart = vchart;
this._runtime.forEach(r => r.afterInitialize?.(this, vchart));
},

afterVRenderDraw: () => {
this._runtime.forEach(r => r.afterVRenderDraw?.(this, this._graphic?.vchart ?? this._vchart));
// @ts-ignore
beforeDoRender: () => {
this._runtime.forEach(r => r.beforeVRenderDraw?.(this, this._graphic?.vchart ?? this._vchart));
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export class VChartRender extends DefaultCanvasRectRender implements IGraphicRen
const vchartCtx = vchartStage.window.getContext();
vchartCtx.baseGlobalAlpha *= baseOpacity;
// @ts-ignore
vchartStage._editor_needRender = true;
vchartStage._story_needRender = true;
const matrix = chart.globalTransMatrix.clone();
// auto 模式下,需要将vchart.stage的viewBoxTransform 设置到包含偏移量的位置
matrix.translate(chart.vchartAutoTranslate.x, chart.vchartAutoTranslate.y);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,15 +119,15 @@ export class VChartGraphic extends Rect {
// 只有vstory触发的render才会真的render
beforeRender: stage => {
const chartStage = this._vchart.getStage();
if (!(chartStage as any)._editor_needRender) {
if (!(chartStage as any)._story_needRender) {
chartStage.pauseRender();
stage.dirtyBounds?.union(this.globalAABBBounds);
stage.renderNextFrame();
}
},
afterRender: stage => {
// @ts-ignore
stage._editor_needRender = false;
stage._story_needRender = false;
stage.resumeRender();
}
},
Expand Down
8 changes: 4 additions & 4 deletions packages/vstory-core/src/character/chart/interface/runtime.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import type { IVChart } from '@visactor/vchart';
import type { ICharacterConfig } from '../../../interface/dsl/dsl';
import type { ICharacterChartRuntimeConfig } from './character-chart';
import type { ICharacterChart } from './character-chart';
export interface IChartCharacterRuntime {
readonly type: string;
// 应用config到attribute
applyConfigToAttribute?: (character: ICharacterChartRuntimeConfig) => void;
applyConfigToAttribute?: (character: ICharacterChart) => void;

// 图表初始化完成
afterInitialize?: (character: ICharacterChartRuntimeConfig, vchart: IVChart) => void;
afterInitialize?: (character: ICharacterChart, vchart: IVChart) => void;

// 图表绘制完成
afterVRenderDraw?: (character: ICharacterChartRuntimeConfig, vchart: IVChart) => void;
beforeVRenderDraw?: (character: ICharacterChart, vchart: IVChart) => void;
}

export interface IChartCharacterRuntimeConstructor {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ export class LabelStyleRuntime implements IChartCharacterRuntime {
* @param vchart
* @returns
*/
afterVRenderDraw(character: ICharacterChart, vchart: IVChart) {
beforeVRenderDraw(character: ICharacterChart, vchart: IVChart) {
const config = character.getRuntimeConfig().config;
const dataGroupStyle = config.options?.dataGroupStyle;
const labelStyle = config.options?.labelStyle;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { merge } from '@visactor/vutils';
import type { IChartCharacterRuntime } from '../interface/runtime';
import type { IChartCharacterRuntime } from '../../chart/interface/runtime';
import { getLayoutFromWidget } from '../../../utils/layout';
import type { ICharacterChart } from '../interface/character-chart';
import type { ICharacterChart } from '../../chart/interface/character-chart';
export class CommonLayoutRuntime implements IChartCharacterRuntime {
type = 'CommonLayout';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
// const vChart = (chart as Chart).vchart;
// const chartStage = vChart.getStage();
// // @ts-ignore
// chartStage._editor_needRender = true;
// chartStage._story_needRender = true;
// const matrix = chart.globalTransMatrix.clone();
// const stageMatrix = chart.stage.window.getViewBoxTransform();
// matrix.multiply(stageMatrix.a, stageMatrix.b, stageMatrix.c, stageMatrix.d, stageMatrix.e, stageMatrix.f);
Expand Down
Loading
Loading