UNPKG

2.81 kBTypeScriptView Raw
1import EventEmitter from 'wolfy87-eventemitter';
2import { View, ViewOptions } from './view';
3export interface DataSetOptions {
4 state: Record<string, any>;
5}
6/**
7 * 数据集
8 * @public
9 */
10export declare class DataSet extends EventEmitter {
11 /**
12 * 常量,譬如 DataSet.CONSTANTS.HIERARCHY 是树形结构的名称
13 */
14 static CONSTANTS: {
15 HIERARCHY: string;
16 GEO: string;
17 HEX: string;
18 GRAPH: string;
19 TABLE: string;
20 GEO_GRATICULE: string;
21 STATISTICS_METHODS: string[];
22 };
23 /**
24 * 注册的 Connector(key-value 对)
25 */
26 static connectors: Record<string, any>;
27 /**
28 * 已注册的 Transform(key-value 对)
29 */
30 static transforms: Record<string, any>;
31 /**
32 * 注册一个数据连接函数,注册后所有数据视图都可以使用 name 来引用这个数据连接函数,从而接入某种数据源。
33 * @param name - 类型
34 * @param connector - 解析逻辑
35 */
36 static registerConnector(name: string, connector: (data: any, options: any, view: View) => any): void;
37 static getConnector(name: string): Function;
38 /**
39 * 注册一个数据处理函数,注册后所有数据视图都可以使用 name 来引用这个数据处理函数,从而进行某种数据处理
40 * @param name - transform 类型
41 * @param transform - transform逻辑
42 */
43 static registerTransform(name: string, transform: any): void;
44 static getTransform(name?: string): Function;
45 static DataSet: typeof DataSet;
46 static DataView: typeof View;
47 static View: typeof View;
48 static version: string;
49 /**
50 * 否是 DataSet
51 */
52 isDataSet: boolean;
53 private _onChangeTimer;
54 /**
55 * 所有挂在数据集上的数据视图(key-value 对)
56 */
57 views: Record<string, View>;
58 /**
59 * 存储数据集上的状态量(key-value 对)
60 */
61 state: Record<string, any>;
62 /**
63 * @param initialProps - 初始状态
64 */
65 constructor(initialProps?: DataSetOptions);
66 private _getUniqueViewName;
67 /**
68 * 创建并返回一个数据视图实例
69 * @param name - 数据视图名称
70 * @param options - 视图配置
71 */
72 createView(name: ViewOptions): View;
73 createView(name?: string, options?: ViewOptions): View;
74 /**
75 * 返回 name 对应的数据视图实例
76 * @param name - name
77 */
78 getView(name: string): View;
79 /**
80 * 设置 name 对应的数据视图实例为 dv
81 * @param name - 名称
82 * @param view - data view
83 */
84 setView(name: string, view: View): void;
85 /**
86 * 设置状态量 name 的值为 value
87 * @param name - 状态名
88 * @param value - 值
89 */
90 setState(name: string, value: any): void;
91}