import type { IGlobalScale } from '../../scale/interface'; import type { ICommonSpec, VisualType, ValueType, FunctionType } from '../../typings/visual'; import type { IModel } from '../../model/interface'; import type { IBaseScale } from '@visactor/vscale'; import type { MarkType, MarkTypeEnum } from './type'; import type { ICompilableMark, ICompilableMarkOption, IMarkConfig, IModelMarkAttributeContext, StateValueType } from '../../compile/mark/interface'; import type { Datum, StringOrNumber } from '../../typings'; import type { IGraphic } from '@visactor/vrender-core'; import type { IGroupMark } from './mark'; import type { IAnimationConfig } from '../../animation/interface'; import type { ICompiler } from '../../compile/interface'; export interface VisualScaleType { scale: IBaseScale; field: StringOrNumber; changeDomain?: 'none' | 'replace' | 'expand'; } export type MarkInputStyle = StyleConvert | VisualType; export type StyleConvert = ValueType | FunctionType | VisualScaleType; export interface IAttrConfig { level: number; style: StyleConvert; referer?: IMarkRaw; postProcess?: (result: A, ...args: Parameters>) => A; } export type IAttrs = { [K in keyof T]: IAttrConfig; }; export type IMarkProgressiveConfig = { large?: boolean; largeThreshold?: number; progressiveStep?: number; progressiveThreshold?: number; }; export type IMarkStateStyle = Record>>; export type IMarkStyle = { [key in keyof T]: MarkInputStyle; }; export type DiffStateValues = 'update' | 'enter' | 'exit'; export type AnimationStateValues = 'appear' | 'enter' | 'update' | 'exit' | 'disappear' | 'none' | 'state'; export interface IGraphicContext { compiler: ICompiler; markType: MarkTypeEnum; markId: number; modelId: number; markUserId?: number | string; modelUserId?: number | string; diffState?: DiffStateValues; reusing?: boolean; lastAttrs?: Record; indexKey?: string; diffAttrs?: Record; finalAttrs?: Record; fieldX?: string[]; originalFieldX?: string[]; fieldY?: string[]; originalFieldY?: string[]; animationState?: AnimationStateValues; data?: Datum[]; uniqueKey?: string; key?: string; groupKey?: string; states?: string[]; graphicCount?: number; graphicIndex?: number; stateAnimateConfig?: IAnimationConfig | IAnimationConfig[]; } export interface IMarkGraphic extends IGraphic { runtimeStateCache?: Record; context?: IGraphicContext; isExiting?: boolean; } export interface IMarkRaw extends ICompilableMark { readonly stateStyle: IMarkStateStyle; getAttributesOfState: (datum: Datum, state?: StateValueType) => Partial; getAttribute: (key: U, datum: any, state?: StateValueType) => unknown; setAttribute: (attr: U, style: StyleConvert, state?: StateValueType, level?: number) => void; setStyle: (style: Partial>, state?: StateValueType, level?: number) => void; setSimpleStyle: (s: T) => void; getSimpleStyle: () => T; setReferer: (mark: IMarkRaw, styleKey?: string, state?: StateValueType) => void; initStyleWithSpec: (spec: any) => void; created: () => void; setPostProcess: (key: U, postProcessFunc: IAttrConfig['postProcess'], state?: StateValueType) => void; updateMarkState: (key: string) => void; render: () => void; renderInner: () => void; getGraphics: () => IMarkGraphic[]; reuse: (mark: IMark) => void; prepareMorph: (mark: IMark) => void; clearExitGraphics: () => void; isProgressive: () => boolean; isDoingProgressive: () => boolean; clearProgressive: () => void; restartProgressive: () => void; renderProgressive: () => void; canAnimateAfterProgressive: () => boolean; runAnimation: () => void; getAnimationState: () => AnimationStateValues; needClear?: boolean; disableAnimationByState: (state: string | string[]) => void; enableAnimationByState: (state: string | string[]) => void; clearBeforeReInit: () => void; } export type IMark = IMarkRaw; export interface ICompileMarkConfig extends IMarkConfig { morph?: boolean; morphElementKey?: string; support3d?: boolean; clip?: boolean; skipTheme?: boolean; } export interface IMarkOption extends ICompilableMarkOption { model: IModel; map: Map; globalScale: IGlobalScale; seriesId?: number; componentType?: string; attributeContext?: IModelMarkAttributeContext; parent?: IGroupMark | false; } export interface IMarkConstructor { type: MarkType; constructorType?: MarkType; new (name: string, options: IMarkOption): IMark; } export interface IComponentMarkConstructor { type: MarkType; constructorType?: MarkType; new (componentType: string, name: string, options: IMarkOption): IMark; } export type MarkConstructor = IMarkConstructor | IComponentMarkConstructor; export interface IMarkDataInitOption extends IMarkOption { mark: IMark; } export type ISamplingMethod = 'lttb' | 'min' | 'max' | 'sum' | 'average'; export interface IDataSamping { activePoint?: boolean; sampling?: ISamplingMethod; samplingFactor?: number; } export interface IMarkOverlap { pointDis?: number; pointDisMul?: number; markOverlap?: boolean; } export type GroupedData = { keys: string[]; data: Map; }; export interface IProgressiveTransformResult { unfinished: () => boolean; output: () => Output; progressiveOutput: () => Output; progressiveRun: () => void; release: () => void; canAnimate?: () => boolean; } export type IMarkDataTransform = (options: Options, data: Input) => Output | IProgressiveTransformResult; export interface ProgressiveContext { currentIndex: number; totalStep: number; step: number; data: any[]; groupKeys?: string[]; groupedData?: Map; }