UNPKG

@antv/g2plot

Version:

G2 Plot, a market of plots built with the Grammar of Graphics'

105 lines (104 loc) 3.66 kB
import { BBox } from '@antv/g'; import * as G2 from '@antv/g2'; import TextDescription from '../components/description'; import { Axis, IDescription, IInteractions, ITitle, Label, Legend, StateConfig, Tooltip, DataItem } from '../interface/config'; import { G2Config } from '../interface/config'; import PaddingController from './controller/padding'; import StateController from './controller/state'; import ThemeController from './controller/theme'; import Layer, { LayerConfig } from './layer'; import { LooseMap } from '../interface/types'; export interface ViewConfig { data?: DataItem[]; meta?: LooseMap; padding?: number | number[] | string; xField?: string; yField?: string; color?: string | string[] | {}; size?: number | number[] | {}; shape?: string | string[] | {}; xAxis?: Axis; yAxis?: Axis; label?: Label; tooltip?: Tooltip; legend?: Legend; animation?: any | boolean; theme?: LooseMap | string; responsiveTheme?: {} | string; interactions?: IInteractions[]; responsive?: boolean; title?: ITitle; description?: IDescription; guideLine?: any; events?: { [k: string]: ((...args: any[]) => any) | boolean; }; defaultState?: { active?: StateConfig; inActive?: StateConfig; selected?: StateConfig; disabled?: StateConfig; }; name?: string; } export interface ViewLayerConfig extends ViewConfig, LayerConfig { } export default abstract class ViewLayer<T extends ViewLayerConfig = ViewLayerConfig> extends Layer<T> { static getDefaultOptions(props?: Partial<ViewConfig>): Partial<ViewConfig>; type: string; view: G2.View; theme: any; initialOptions: T; title: TextDescription; description: TextDescription; viewRange: BBox; protected paddingController: PaddingController; protected stateController: StateController; protected themeController: ThemeController; config: G2Config; private interactions; constructor(props: T); getOptions(props: T): T; beforeInit(): void; init(): void; afterInit(): void; afterRender(): void; /** 完整生命周期渲染 */ render(): void; /** 销毁 */ destroy(): void; /** 更新配置项 */ updateConfig(cfg: Partial<T>): void; changeData(data: DataItem[]): void; getPlot(): G2.View; getTheme(): any; getResponsiveTheme(): any; getPlotTheme(): any; bindStateManager(stateManager: any, cfg: any): void; setActive(condition: any, style: any): void; setSelected(condition: any, style: any): void; setDisable(condition: any, style: any): void; setNormal(condition: any): void; getData(start?: number, end?: number): object[]; protected processData(data?: DataItem[]): DataItem[] | undefined; protected abstract coord(): void; protected scale(): void; protected axis(): void; protected tooltip(): void; protected legend(): void; protected annotation(): void; protected abstract addGeometry(): void; protected abstract geometryParser(dim: string, type: string): string; protected animation(): void; protected applyInteractions(): void; /** 设置G2 config,带有类型推导 */ protected setConfig<K extends keyof G2Config>(key: K, config: G2Config[K] | boolean): void; protected parseEvents(eventParser?: any): void; protected drawTitle(): void; protected drawDescription(): void; /** 抽取destroy和updateConfig共有代码为_destroy方法 */ private doDestroy; private doDestroyInteractions; protected getViewRange(): BBox; private addGeomCliper; }