UNPKG

zz-chart

Version:

Alauda Chart components by Alauda Frontend Team

155 lines (154 loc) 4.59 kB
/// <reference types="react" resolution-mode="require"/> /// <reference types="web" /> import { Annotation } from '../components/annotation.js'; import { BaseComponent } from '../components/base.js'; import { Coordinate } from '../components/coordinate.js'; import { Legend } from '../components/legend.js'; import { Scale } from '../components/scale.js'; import { PolarShape, Shape, ShapeCtor } from '../components/shape/index.js'; import Interaction from '../interaction/interaction.js'; import { Reactive } from '../reactivity/index.js'; import { ViewStrategyManager } from '../strategy/index.js'; import { AxisOption, CoordinateOption, Data, InteractionSteps, LegendOption, Options, ScaleOption, Size, Theme, ThemeOptions, TitleOption, TooltipOption, ViewOption } from '../types/index.js'; import EventEmitter from './event-emitter.js'; export declare class View extends EventEmitter { /** 所有的组件 */ components: Map<string, BaseComponent>; /** 图形组件 */ shapeComponents: Map<string, Shape | PolarShape>; protected options: Options; readonly reactivity: Reactive; interactions: Map<string, Interaction>; container: HTMLElement; chartContainer: HTMLElement; coordinateInstance: Coordinate; /** 主题配置,存储当前主题配置。 */ protected themeObject: ThemeOptions; strategyManage: ViewStrategyManager; private strategy; private mediaQuery; systemThemeType: 'light' | 'dark'; size: Size; defaultInteractions: string[]; get isElementAction(): boolean; get hideTooltip(): boolean; fixedSize: { width: number; height: number; }; shapeCache: Map<string, (Shape<unknown> | PolarShape<unknown>)[]>; constructor(props: ViewOption); init(): void; reactive(): object; render(size?: Size): void; interaction(name: string, steps?: InteractionSteps): void; private initDefaultInteractions; /** * 基于注册组件初始化 */ private initComponent; /** * 初始化策略 uPlot internal */ private initViewStrategy; /** * * @param theme 主题 * 不设置默认根据系统切换 light dark */ private initTheme; private bindThemeListener; private unbindThemeListener; private readonly systemChangeTheme; /** * 设置主题。 * @param theme 主题名或者主题配置 * @returns View */ theme(theme?: string | Theme): View; /** * 获取主题配置。 * @returns themeObject */ getTheme(): ThemeOptions; /** * 获取 view options 配置 */ getOption(): Options; /** * 装载数据源。 * * ```ts * chart.data(); * ``` * * @param data 数据源。 * @returns View */ data(data: Data): View; getData(): Data; title(titleOption: TitleOption): View; legend(legendOption: boolean | LegendOption): Legend; /** * 对特定的某条坐标轴进行配置。 * * ```ts * view.axis('x', false); // 不展示 'x' 坐标轴 * // 将 'x' 字段对应的坐标轴的标题隐藏 * view.axis('x', { * //... * }); * ``` * @param field 坐标轴 x y * @param axisOption 坐标轴配置 */ axis(field: string, axisOption: AxisOption): View; /** * 对x y 度量进行配置。 * ``` * @param field 度量 x y * @param scaleOption 度量配置 */ scale(field: string, axisOption: ScaleOption): Scale; setScale(field: 'x' | 'y', limits: { min?: number; max?: number; }): void; /** * 创建坐标系 * @private */ private createCoordinate; /** * 坐标系配置。 * * ```ts * // 直角坐标系,并进行转置变换 * chart.coordinate().transpose(); * ``` * @returns */ coordinate(option?: CoordinateOption): Coordinate; getCoordinate(): Coordinate; tooltip(tooltipOption: TooltipOption): View; /** * 辅助标记配置 */ annotation(): Annotation; setOption(name: string | string[], option: unknown): this; redraw(): void; setShape(name: string, shape: any): void; getShapeList(): (Shape<unknown> | PolarShape<unknown>)[]; getShapeDataName(): any[]; /** * 生命周期:销毁,完全无法使用。 */ destroy(): void; } /** * 注册 geometry 组件 * @param name * @param Ctor * @returns Geometry */ export declare function registerShape(name: string, Ctor: ShapeCtor): void;