diff --git a/packages/vstory/src/edit/edit-component/index.ts b/packages/vstory/src/edit/edit-component/index.ts index 4bacb7a..ed30aa5 100644 --- a/packages/vstory/src/edit/edit-component/index.ts +++ b/packages/vstory/src/edit/edit-component/index.ts @@ -1,8 +1,6 @@ // import { CommonEditComponent } from './common'; import { BoxSelection } from './box-selection'; import { ImageSelection } from './image-selection'; -import { TextSelection } from './text-selection'; -import { RichTextSelection } from './richtext-selection'; import { RectSelection } from './rect-selection'; import { ChartSelection } from './chart-selection'; import { Edit } from '../edit'; diff --git a/packages/vstory/src/player/processor/chart/rankingBar/rankingBar.ts b/packages/vstory/src/player/processor/chart/rankingBar/rankingBar.ts index d2b7065..9be0f9d 100644 --- a/packages/vstory/src/player/processor/chart/rankingBar/rankingBar.ts +++ b/packages/vstory/src/player/processor/chart/rankingBar/rankingBar.ts @@ -8,7 +8,8 @@ import { isValid } from '@visactor/vutils'; import type { IAction, IActionPayload } from '../../interface/common-action'; // TODO: move to interface folder -export type IRankingBarPlayPayload = Omit; +// export type IRankingBarPlayPayload = Omit; +export type IRankingBarPlayPayload = IActionPayload; export interface IRankingBarPlayAction extends IAction { action: 'play'; @@ -54,6 +55,7 @@ export class RankingBarPlayActionProcessor extends ActionProcessorItem { getStartTimeAndDuration(action: IActionSpec, character?: ICharacter): { startTime: number; duration: number } { const { startTime: globalStartTime = 0 } = action; + // @ts-ignore const { startTime = 0 } = action.payload?.animation ?? ({} as any); const instance = (character.graphic as any)._vchart as IVChart; const interval = instance?.getSpec()?.interval ?? 0; diff --git a/packages/vstory/src/story/character/chart/graphic/vchart-graphic.ts b/packages/vstory/src/story/character/chart/graphic/vchart-graphic.ts index 8d613af..a75404c 100644 --- a/packages/vstory/src/story/character/chart/graphic/vchart-graphic.ts +++ b/packages/vstory/src/story/character/chart/graphic/vchart-graphic.ts @@ -1,5 +1,5 @@ import type { IVisactorGraphic } from '../../visactor/interface'; -import { Bounds, type AABBBounds, type IBoundsLike } from '@visactor/vutils'; +import { Bounds, type AABBBounds, type IAABBBounds, type IBoundsLike } from '@visactor/vutils'; import type { ISpec, IVChart } from '@visactor/vchart'; import type { GraphicType, IGroupGraphicAttribute, ITicker } from '@visactor/vrender'; import { genNumberType, Group } from '@visactor/vrender'; @@ -55,7 +55,7 @@ export class Chart extends Group implements IVisactorGraphic { return stage.defaultLayer.getChildByName('root').AABBBounds.clone(); } - doUpdateAABBBounds(full?: boolean): AABBBounds { + doUpdateAABBBounds(full?: boolean): IAABBBounds { if (!this._vchart) { return super.doUpdateAABBBounds(); } diff --git a/packages/vstory/src/story/character/chart/temp/templates/bar.ts b/packages/vstory/src/story/character/chart/temp/templates/bar.ts index a2b6627..f61addf 100644 --- a/packages/vstory/src/story/character/chart/temp/templates/bar.ts +++ b/packages/vstory/src/story/character/chart/temp/templates/bar.ts @@ -1,10 +1,16 @@ -import { ICharacter } from './../../../runtime-interface'; import { TemplateChartType } from '../constant'; -import { CartesianSingleSeriesTemp } from './cartesian-single'; import type { CharacterChart } from '../../character'; +import { BaseTemp } from './base-temp'; +import type { StandardData, DataInfo } from '../../data/interface'; -export class BarTemp extends CartesianSingleSeriesTemp { - static type: string = TemplateChartType.bar; +export class BarTemp extends BaseTemp { + getSpec(data: StandardData, ctx: { character: CharacterChart }, opt?: any) { + throw new Error('Method not implemented.'); + } + checkDataEnable(data: StandardData, info: DataInfo, opt?: any): boolean { + throw new Error('Method not implemented.'); + } + static type: string = TemplateChartType.vchart; type: string = BarTemp.type; // 唯一系列类型 seriesType = 'bar'; @@ -14,8 +20,7 @@ export class BarTemp extends CartesianSingleSeriesTemp { protected _getSeriesSpec() { return { type: 'bar', - stack: true, - direction: this.direction + stack: true }; } diff --git a/packages/vstory/src/story/character/component/character.ts b/packages/vstory/src/story/character/component/character.ts index 871caa7..698a7b9 100644 --- a/packages/vstory/src/story/character/component/character.ts +++ b/packages/vstory/src/story/character/component/character.ts @@ -1,5 +1,5 @@ +import type { IBoundsLike } from '@visactor/vutils'; import type { IGroup } from '@visactor/vrender'; -import { createGroup } from '@visactor/vrender'; import { GraphicBaseText } from './graphic/graphic-base-text'; import type { IComponentCharacterSpec } from '../dsl-interface'; import { CharacterBase } from '../base/base'; @@ -99,7 +99,7 @@ export abstract class CharacterComponent extends CharacterBase { } getLayoutBounds() { - return this._group.AABBBounds; + return this._group.AABBBounds as IBoundsLike; } checkEvent(event: StoryEvent): false | ICharacterPickInfo { diff --git a/packages/vstory/src/story/character/runtime-interface.ts b/packages/vstory/src/story/character/runtime-interface.ts index 25eb7e9..7c046ab 100644 --- a/packages/vstory/src/story/character/runtime-interface.ts +++ b/packages/vstory/src/story/character/runtime-interface.ts @@ -6,9 +6,9 @@ import type { Graphic } from './component/graphic/graphic'; export interface ICharacterPickInfo { part: string; - graphic: IGraphic; - graphicType: string; - modelInfo: any; + graphic?: IGraphic; + graphicType?: string; + modelInfo?: any; } export interface ICharacter { id: string; diff --git a/packages/vstory/src/story/story.ts b/packages/vstory/src/story/story.ts index 611fe12..bf49fad 100644 --- a/packages/vstory/src/story/story.ts +++ b/packages/vstory/src/story/story.ts @@ -43,11 +43,11 @@ export class Story implements IStory { this._player = new Player(this, option.playerOption); this._characterTree = new CharacterTree(this); - this._spec = spec; - this._spec && this.load(this._spec); + spec && this.load(this._spec); } load(spec: IStorySpec) { + this._spec = spec; this._characterTree.initCharacters(spec.characters); this._player.initActs(spec.acts); } diff --git a/packages/vstory/src/story/utils/layout.ts b/packages/vstory/src/story/utils/layout.ts index 210a998..ec4e573 100644 --- a/packages/vstory/src/story/utils/layout.ts +++ b/packages/vstory/src/story/utils/layout.ts @@ -1,9 +1,10 @@ +import type { IRect } from '../../type/space'; import type { ILayoutAttribute, IWidgetData } from '../character'; -export function getLayoutFromWidget(w: Partial): Partial { +export function getLayoutFromWidget(w: Partial | IRect): Partial { return { - x: w.x ?? w.left, - y: w.y ?? w.top, + x: 'x' in w ? w.x : w.left, + y: 'y' in w ? w.y : w.top, width: 'width' in w ? w.width : (w as any).right - w.left, height: 'height' in w ? w.height : (w as any).bottom - w.top }; diff --git a/packages/vstory/src/story/utils/vchart-pick.ts b/packages/vstory/src/story/utils/vchart-pick.ts index 0adaa6e..fc96f16 100644 --- a/packages/vstory/src/story/utils/vchart-pick.ts +++ b/packages/vstory/src/story/utils/vchart-pick.ts @@ -1,7 +1,16 @@ import type { IGraphic, IGraphicAttribute } from '@visactor/vrender'; -import type { VChart } from '@visactor/vchart'; +import type { IVChart } from '@visactor/vchart'; import type { StoryEvent } from '../interface/runtime-interface'; +export interface IPickModelInfo { + type: string; + model: any; + specKey: string; + specIndex: number; + datum?: any; + mark?: any; +} + function commonModelInfo(model: any) { return { type: model.type, @@ -15,7 +24,7 @@ export const seriesMarkPick = { check: (graphic: IGraphic, graphicPath: IGraphic[]) => { return graphic.name?.startsWith('seriesGroup_'); }, - modelInfo: (chart: VChart, graphic: IGraphic, graphicPath: IGraphic[], index: number) => { + modelInfo: (chart: IVChart, graphic: IGraphic, graphicPath: IGraphic[], index: number) => { const nameInfo = graphic.name.split('_'); const seriesId = +nameInfo[2]; const markGraphic = graphicPath[index + 1]; @@ -37,7 +46,7 @@ export const axisMarkPick = { check: (graphic: IGraphic, graphicPath: IGraphic[]) => { return graphic.name === 'axis' || graphic.name === 'axis-grid'; }, - modelInfo: (chart: VChart, graphic: IGraphic, graphicPath: IGraphic[], index: number) => { + modelInfo: (chart: IVChart, graphic: IGraphic, graphicPath: IGraphic[], index: number) => { const axisGroup = graphicPath[index - 1]; const axisId = +axisGroup.name.split('_')[1]; const axis = chart @@ -60,8 +69,8 @@ export const markerMarkPick = { check: (graphic: IGraphic, graphicPath: IGraphic[]) => { return !!MarkerClassName[graphic.constructor.name]; }, - modelInfo: (chart: VChart, graphic: IGraphic, graphicPath: IGraphic[]) => { - const markerId = +graphic.id.split('-')[1]; + modelInfo: (chart: IVChart, graphic: IGraphic, graphicPath: IGraphic[]) => { + const markerId = +(graphic.id).split('-')[1]; const model = chart .getChart() .getAllComponents() @@ -75,7 +84,7 @@ export const labelMarkPick = { check: (graphic: IGraphic, graphicPath: IGraphic[]) => { return graphic.name === 'data-label'; }, - modelInfo: (chart: VChart, graphic: IGraphic, graphicPath: IGraphic[], index: number) => { + modelInfo: (chart: IVChart, graphic: IGraphic, graphicPath: IGraphic[], index: number) => { const id = +graphicPath[index - 1].name.split('_')[1]; const model = chart .getChart() @@ -97,7 +106,7 @@ function commonModePick(vrenderGraphicClassName: string, modelName: string) { check: (graphic: IGraphic, graphicPath: IGraphic[]) => { return graphic.constructor.name === vrenderGraphicClassName; }, - modelInfo: (chart: VChart, graphic: IGraphic, graphicPath: IGraphic[], index: number) => { + modelInfo: (chart: IVChart, graphic: IGraphic, graphicPath: IGraphic[], index: number) => { return commonModelInfo( chart .getChart() @@ -119,7 +128,7 @@ export const discretePlayerMarkPick = commonModePick('DiscretePlayer', 'player') const modelCheck: { check: (graphic: IGraphic, graphicPath: IGraphic[]) => boolean; - modelInfo: (chart: VChart, graphic: IGraphic, graphicPath: IGraphic[], index: number) => any; + modelInfo: (chart: IVChart, graphic: IGraphic, graphicPath: IGraphic[], index: number) => any; }[] = [ seriesMarkPick, axisMarkPick, @@ -138,7 +147,7 @@ const modelCheck: { * 从event属性上,读取当前pick到的图表模块内容 * @param event */ -export function getChartModelWithEvent(chart: VChart, event: StoryEvent) { +export function getChartModelWithEvent(chart: IVChart, event: StoryEvent) { const graphicPath = event.detailPath[event.detailPath.length - 1] as unknown as IGraphic< Partial >[]; @@ -152,7 +161,12 @@ export function getChartModelWithEvent(chart: VChart, event: StoryEvent) { return getGraphicModelMark(chart, pickGraphic, graphicPath, 0); } -export function getGraphicModelMark(chart: VChart, graphic: IGraphic, graphicPath: IGraphic[], index: number) { +export function getGraphicModelMark( + chart: IVChart, + graphic: IGraphic, + graphicPath: IGraphic[], + index: number +): IPickModelInfo { const modelPick = modelCheck.find(mc => mc.check(graphic, graphicPath)); if (modelPick) { return modelPick.modelInfo(chart, graphic, graphicPath, index);