Skip to content

Commit

Permalink
fix: fix the bugs of lint
Browse files Browse the repository at this point in the history
  • Loading branch information
xuefei1313 committed Aug 28, 2024
1 parent c6a3852 commit 4455171
Show file tree
Hide file tree
Showing 9 changed files with 51 additions and 31 deletions.
2 changes: 0 additions & 2 deletions packages/vstory/src/edit/edit-component/index.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<IActionPayload, 'animation'>;
// export type IRankingBarPlayPayload = Omit<IActionPayload, 'animation'>;
export type IRankingBarPlayPayload = IActionPayload;

export interface IRankingBarPlayAction extends IAction<IRankingBarPlayPayload> {
action: 'play';
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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();
}
Expand Down
17 changes: 11 additions & 6 deletions packages/vstory/src/story/character/chart/temp/templates/bar.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -14,8 +20,7 @@ export class BarTemp extends CartesianSingleSeriesTemp {
protected _getSeriesSpec() {
return {
type: 'bar',
stack: true,
direction: this.direction
stack: true
};
}

Expand Down
4 changes: 2 additions & 2 deletions packages/vstory/src/story/character/component/character.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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 {
Expand Down
6 changes: 3 additions & 3 deletions packages/vstory/src/story/character/runtime-interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions packages/vstory/src/story/story.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
7 changes: 4 additions & 3 deletions packages/vstory/src/story/utils/layout.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import type { IRect } from '../../type/space';
import type { ILayoutAttribute, IWidgetData } from '../character';

export function getLayoutFromWidget(w: Partial<IWidgetData>): Partial<ILayoutAttribute> {
export function getLayoutFromWidget(w: Partial<IWidgetData> | IRect): Partial<ILayoutAttribute> {
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 : <number>(w as any).right - <number>w.left,
height: 'height' in w ? w.height : <number>(w as any).bottom - <number>w.top
};
Expand Down
34 changes: 24 additions & 10 deletions packages/vstory/src/story/utils/vchart-pick.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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];
Expand All @@ -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
Expand All @@ -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 = +(<string>graphic.id).split('-')[1];
const model = chart
.getChart()
.getAllComponents()
Expand All @@ -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()
Expand All @@ -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()
Expand All @@ -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,
Expand All @@ -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<IGraphicAttribute>
>[];
Expand All @@ -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);
Expand Down

0 comments on commit 4455171

Please sign in to comment.