NuclearDispersionSystem/ant-design-vue-jeecg/node_modules/@antv/g2/esm/chart/view.d.ts

681 lines
19 KiB
TypeScript
Raw Normal View History

2023-09-14 14:47:11 +08:00
import { Attribute, Coordinate, ICanvas, IGroup, Scale } from '../dependents';
import { AxisOption, ComponentOption, CoordinateCfg, CoordinateOption, Data, Datum, FacetCfgMap, FilterCondition, LegendOption, LooseObject, Options, Point, Region, ScaleOption, TooltipOption, ViewCfg, ViewPadding } from '../interface';
import { LAYER } from '../constant';
import Base from '../base';
import { Facet } from '../facet';
import Geometry from '../geometry/base';
import { Interaction } from '../interaction';
import { BBox } from '../util/bbox';
import Annotation from './controller/annotation';
import { Controller } from './controller/base';
import CoordinateController from './controller/coordinate';
import { Layout } from './layout';
/**
* G2 View
*/
export declare class View extends Base {
/** view id全局唯一。 */
id: string;
/** 父级 view如果没有父级则为空。 */
parent: View;
/** 所有的子 view。 */
views: View[];
/** 所有的 geometry 实例。 */
geometries: Geometry[];
/** 所有的组件 controllers。 */
controllers: Controller[];
/** 所有的 Interaction 实例。 */
interactions: Record<string, Interaction>;
/** view 区域空间。 */
viewBBox: BBox;
/** 坐标系的位置大小ViewBBox - padding = coordinateBBox。 */
coordinateBBox: BBox;
/** view 的 padding 大小,传入的配置(不是解析之后的值)。 */
padding: ViewPadding;
/** G.Canvas 实例。 */
canvas: ICanvas;
/** 存储自动计算的 padding 值 */
autoPadding: number[];
/** 三层 Group 图形中的背景层。 */
backgroundGroup: IGroup;
/** 三层 Group 图形中的中间层。 */
middleGroup: IGroup;
/** 三层 Group 图形中的前景层。 */
foregroundGroup: IGroup;
/** 是否对超出坐标系范围的 Geometry 进行剪切 */
limitInPlot: boolean;
/**
* view 0 ~ 1 便使
*/
protected region: Region;
/** 主题配置,存储当前主题配置。 */
protected themeObject: LooseObject;
protected options: Options;
/** 过滤之后的数据 */
protected filteredData: Data;
/** 配置开启的组件插件,默认为全局配置的组件。 */
private usedControllers;
/** 所有的 scales */
private scalePool;
/** 布局函数 */
protected layoutFunc: Layout;
/** 生成的坐标系实例,{@link https://github.com/antvis/coord/blob/master/src/coord/base.ts|Coordinate} */
protected coordinateInstance: Coordinate;
/** Coordinate 相关的控制器类,负责坐标系实例的创建、更新、变换等 */
protected coordinateController: CoordinateController;
/** 分面类实例 */
protected facetInstance: Facet;
/** 当前鼠标是否在 plot 内CoordinateBBox */
private isPreMouseInPlot;
/** 默认标识位,用于判定数据是否更新 */
private isDataChanged;
/** 用于判断坐标系范围是否发生变化的标志位 */
private isCoordinateChanged;
/** 从当前这个 view 创建的 scale key */
private createdScaleKeys;
constructor(props: ViewCfg);
/**
* layout
* @param layout
* @returns void
*/
setLayout(layout: Layout): void;
/**
*
* @returns voids
*/
init(): void;
/**
*
* render view view
* @param isUpdate
*/
render(isUpdate?: boolean): void;
/**
* chart 使
* @returns void
*/
clear(): void;
/**
* 使
* @returns void
*/
destroy(): void;
/**
* view
* @param visible
* @returns View
*/
changeVisible(visible: boolean): View;
/**
*
*
* ```ts
* view.data([{ city: '杭州', sale: 100 }, { city: '上海', sale: 110 } ]);
* ```
*
* @param data json
* @returns View
*/
data(data: Data): View;
/**
* @deprecated
* This method will be removed at G2 V4.1. Replaced by {@link #data(data)}
*/
source(data: Data): View;
/**
*
*
* ```ts
* view.filter('city', (value: any, datum: Datum) => value !== '杭州');
*
* // 删除 'city' 字段对应的筛选规则。
* view.filter('city', null);
* ```
*
* @param field
* @param condition
* @returns View
*/
filter(field: string, condition: FilterCondition | null): View;
/**
*
*
* ```ts
* view.axis(false); // 不展示坐标轴
* ```
* @param field
*/
axis(field: boolean): View;
/**
*
*
* @example
* ```ts
* view.axis('city', false); // 不展示 'city' 字段对应的坐标轴
*
* // 将 'city' 字段对应的坐标轴的标题隐藏
* view.axis('city', {
* title: null,
* });
* ```
*
* @param field
* @param axisOption https://github.com/antvis/component#axis
*/
axis(field: string, axisOption: AxisOption): View;
/**
*
*
* ```ts
* view.legend(false); // 关闭图例
*
* view.legend({
* position: 'right',
* }); // 图例进行整体配置
* ```
* @param field
* @returns View
*/
legend(field: LegendOption): View;
/**
*
*
* @example
* ```ts
* view.legend('city', false); // 关闭某个图例,通过数据字段名进行关联
*
* // 对特定的图例进行配置
* view.legend('city', {
* position: 'right',
* });
* ```
*
* @param field
* @param legendOption https://github.com/antvis/component#axis
* @returns View
*/
legend(field: string, legendOption: LegendOption): View;
/**
* scale
*
* ```ts
* view.scale({
* sale: {
* min: 0,
* max: 100,
* }
* });
* ```
* Scale https://github.com/antvis/scale#api
* @returns View
*/
scale(field: Record<string, ScaleOption>): View;
/**
* scale
*
* ```ts
* view.scale('sale', {
* min: 0,
* max: 100,
* });
* ```
*
* @returns View
*/
scale(field: string, scaleOption: ScaleOption): View;
/**
* tooltip
*
* ```ts
* view.tooltip(false); // 关闭 tooltip
*
* view.tooltip({
* shared: true
* });
* ```
*
* @param cfg Tooltip https://github.com/antvis/component#tooltip
* @returns View
*/
tooltip(cfg: boolean | TooltipOption): View;
/**
*
*
* ```ts
* view.annotation().line({
* start: ['min', 85],
* end: ['max', 85],
* style: {
* stroke: '#595959',
* lineWidth: 1,
* lineDash: [3, 3],
* },
* });
* ```
* https://github.com/antvis/component#annotation
* @returns [[Annotation]]
*/
annotation(): Annotation;
/**
* @deprecated
* This method will be removed at G2 V4.1. Replaced by {@link #guide()}
*/
guide(): Annotation;
/**
*
*
* @example
* ```ts
* view.coordinate({
* type: 'polar',
* cfg: {
* radius: 0.85,
* },
* actions: [
* [ 'transpose' ],
* ],
* });
* ```
*
* @param option
* @returns
*/
coordinate(option?: CoordinateOption): CoordinateController;
/**
*
*
* ```ts
* // 直角坐标系,并进行转置变换
* view.coordinate('rect').transpose();
*
* // 默认创建直角坐标系
* view.coordinate();
* ```
*
* @param type
* @param [coordinateCfg]
* @returns
*/
coordinate(type: string, coordinateCfg?: CoordinateCfg): CoordinateController;
/**
* @deprecated
* This method will be removed at G2 V4.1. Replaced by {@link #coordinate()}
*/
coord(type: string | CoordinateOption, coordinateCfg?: CoordinateCfg): CoordinateController;
/**
* view
*
* ```ts
* view.facet('rect', {
* rowField: 'province',
* columnField: 'category',
* eachView: (innerView: View, facet?: FacetData) => {
* innerView.line().position('city*sale');
* },
* });
* ```
*
* @param type
* @param cfg [[FacetCfgMap]]
* @returns View
*/
facet<T extends keyof FacetCfgMap>(type: T, cfg: FacetCfgMap[T]): View;
animate(status: boolean): View;
/**
*
* @param options
*/
updateOptions(options: Options): this;
/**
* `view.options`
* @param name
* @param opt
* @returns view
*/
option(name: string, opt: any): View;
/**
*
*
* ```ts
* view.theme('dark'); // 'dark' 需要事先通过 `registerTheme()` 接口注册完成
*
* view.theme({ defaultColor: 'red' });
* ```
*
* @param theme
* @returns View
*/
theme(theme: string | LooseObject): View;
/**
* Call the interaction based on the interaction name
*
* ```ts
* view.interaction('my-interaction', { extra: 'hello world' });
* ```
* https://g2.antv.vision/zh/docs/manual/tutorial/interaction
* @param name interaction name
* @param cfg interaction config
* @returns
*/
interaction(name: string, cfg?: LooseObject): View;
/**
* View interaction
* ```ts
* view.removeInteraction('my-interaction');
* ```
* @param name interaction name
*/
removeInteraction(name: string): void;
/**
* view
*
* ```ts
* view.changeData([{ city: '北京', sale: '200' }]);
* ```
*
* @param data
* @returns void
*/
changeData(data: Data): void;
/**
* view
*
* ```ts
* const innerView = view.createView({
* start: { x: 0, y: 0 },
* end: { x: 0.5, y: 0.5 },
* padding: 8,
* });
* ```
*
* @param cfg
* @returns View
*/
createView(cfg?: Partial<ViewCfg>): View;
/**
* @deprecated
* This method will be removed at G2 V4.1. Replaced by {@link #createView()}
*/
view(cfg?: Partial<ViewCfg>): View;
/**
* view
* @param view
* @return removedView
*/
removeView(view: View): View;
/**
*
* @returns [[Coordinate]]
*/
getCoordinate(): Coordinate;
/**
* view
* @returns themeObject
*/
getTheme(): LooseObject;
/**
* x scale
* @returns view Geometry x scale
*/
getXScale(): Scale;
/**
* y scales
* @returns view Geometry y scale
*/
getYScales(): Scale[];
/**
* x y scale
* @param dimType x | y
* @returns x y scale
*/
getScalesByDim(dimType: 'x' | 'y'): Record<string, Scale>;
/**
* scale
* @param field
* @param key id
*/
getScaleByField(field: string, key?: string): Scale;
/**
*
* @returns view API
*/
getOptions(): Options;
/**
* view
* @returns
*/
getData(): Data;
/**
* group
* @param layer
* @returns Group
*/
getLayer(layer: LAYER): IGroup;
/**
*
* @param point
*/
isPointInPlot(point: Point): boolean;
/**
* legend attribute
* @returns Attribute
*/
getLegendAttributes(): Attribute[];
/**
* scale
* @returns scale
*/
getGroupScales(): Scale[];
/**
* G.Canvas
* @returns G.Canvas
*/
getCanvas(): ICanvas;
/**
* view
*/
getRootView(): View;
/**
*
* @param data
* @returns
*/
getXY(data: Datum): Point;
/**
* name controller
* @param name
*/
getController(name: string): Controller;
/**
* point tooltip
* @param point
* @returns View
*/
showTooltip(point: Point): View;
/**
* tooltip
* @returns View
*/
hideTooltip(): View;
/**
* tooltip
* @returns View
*/
lockTooltip(): View;
/**
* tooltip
* @returns View
*/
unlockTooltip(): View;
/**
* tooltip
* @returns
*/
isTooltipLocked(): boolean;
/**
* point tooltip
* @param point
* @returns tooltip
*/
getTooltipItems(point: Point): any[];
/**
*
* @param point
* @returns
*/
getSnapRecords(point: Point): any[];
/**
* pure component
*/
getComponents(): ComponentOption[];
/**
* data
* @param data
* @returns
*/
filterData(data: Data): Data;
/**
*
* @param field
* @param data
*/
filterFieldData(field: string, data: Data): Data;
/**
* coordinate
*/
adjustCoordinate(): void;
protected paint(isUpdate: boolean): void;
/**
* view view coordinateBBox coordinateInstance
* @param isUpdate
*/
protected renderLayoutRecursive(isUpdate: boolean): void;
/**
*
* @param isUpdate
*/
protected renderPaintRecursive(isUpdate: boolean): void;
/**
* scale view scale
* @param field
* @param data
* @param scaleDef
* @param key
*/
protected createScale(field: string, data: Data, scaleDef: ScaleOption, key: string): Scale;
/**
*
* @param isUpdate
*/
private renderDataRecursive;
/**
* region
* @private
*/
private calculateViewBBox;
/**
* G 4.0 name:event name
*
* G2 view
* view view Component Geometry
* @private
*/
private initEvents;
private onCanvasEvent;
/**
*
*/
private initComponentController;
private createViewEvent;
/**
*
* @param evt
*/
private onDelegateEvents;
/**
* PLOT_EVENTS
* plot event emit
* mouseentermouseleave
* @param e
*/
private doPlotEvent;
/**
*
* @private
*/
private doFilterData;
/**
* Geometries
* @private
*/
private initGeometries;
/**
* Geometry scales
*
*/
private createOrUpdateScales;
/**
* scale
*/
private syncScale;
/**
* Geometry scale
*/
private getGeometryScales;
private getScaleFields;
private getGroupedFields;
/**
* scale
* @private
*/
private adjustScales;
/**
* scale range
* @private
*/
private adjustCategoryScaleRange;
/**
* options Geometry components
* @param isUpdate
* @private
*/
private initComponents;
private doLayout;
/**
*
* @private
*/
private createCoordinate;
/**
* options geometry
* @private
*/
private paintGeometries;
/**
*
* @param isUpdate
*/
private renderComponents;
/**
* view
* @param isUpdate
*/
private renderFacet;
private initOptions;
private createGeometry;
/**
* scale key
* @param field
*/
private getScaleKey;
}
/**
* geometry
* @param name
* @param Ctor
* @returns Geometry
*/
export declare function registerGeometry(name: string, Ctor: any): void;
export default View;