UNPKG

3.35 kBTypeScriptView Raw
1import EventEmitter from 'wolfy87-eventemitter';
2import { DataSet } from './data-set';
3import { StatisticsApi } from './api/statistics';
4import { PartitionApi } from './api/partition';
5import { HierarchyApi } from './api/hierarchy';
6import { GeoApi } from './api/geo';
7import { TransformsParams } from './transform-params';
8import { ConnectorParams } from './connector-params';
9export interface ViewOptions {
10 watchingStates?: string[];
11}
12declare type TransformOptions<T extends keyof TransformsParams = any> = {
13 type: T;
14} & TransformsParams[T];
15declare type ConnectorOptions<T extends keyof ConnectorParams = any> = {
16 type: T;
17} & ConnectorParams[T][1];
18interface CustomSource {
19 source: any;
20 options: any;
21}
22/**
23 * 数据视图
24 * @public
25 */
26export declare class View extends EventEmitter {
27 static DataSet: typeof DataSet;
28 /**
29 * 关联的数据集
30 */
31 dataSet: DataSet | null;
32 /**
33 * 是否关联了数据集
34 */
35 loose: boolean;
36 /**
37 * 是否是View
38 */
39 isView: boolean;
40 /**
41 * 是否是View
42 */
43 isDataView: boolean;
44 /**
45 *
46 */
47 private watchingStates;
48 /**
49 * 数据视图类型
50 */
51 dataType: string;
52 /**
53 * 已应用的 transform
54 */
55 transforms: TransformOptions[];
56 /**
57 * 原始数据
58 */
59 origin: any[];
60 /**
61 * 存储处理后的数据
62 */
63 rows: any[];
64 _source: CustomSource;
65 _tagCloud: any;
66 graph: {
67 nodes: any[];
68 edges: any[];
69 };
70 nodes: any[];
71 edges: any[];
72 _projectedAs: string[];
73 _gridRows: any;
74 _HexJSON: any;
75 _GridHexJSON: any;
76 constructor(options?: ViewOptions);
77 constructor(dataSet?: DataSet, options?: ViewOptions);
78 private _parseStateExpression;
79 private _preparseOptions;
80 private _prepareSource;
81 /**
82 * 载入数据
83 *
84 * @remarks
85 * data 是原始数据,可能是字符串,也可能是数组、对象,或者另一个数据视图实例。options 里指定了载入数据使用的 connector 和载入时使用的配置项。
86 *
87 * @param source - 数据
88 * @param options- 数据解析配置
89 */
90 source(source: string): View;
91 source(source: any[]): View;
92 source(source: View): View;
93 source<T extends keyof ConnectorParams>(source: ConnectorParams[T][0], options: ConnectorOptions<T>): View;
94 /**
95 * 执行数据处理数据。执行完这个函数后,transform 会被存储
96 * @param options - 某种类型的transform
97 */
98 transform<T extends keyof TransformsParams>(options?: TransformOptions<T>): View;
99 private _executeTransform;
100 private _reExecuteTransforms;
101 addRow(row: any): void;
102 removeRow(index: number): void;
103 updateRow(index: number, newRow: any): void;
104 findRows(query: any): any[];
105 findRow(query: any): any;
106 getColumnNames(): string[];
107 getColumnName(index: number): string;
108 getColumnIndex(columnName: string): number;
109 getColumn(columnName: string): any[];
110 getColumnData(columnName: string): any[];
111 getSubset(startRowIndex: number, endRowIndex: number, columnNames: string[]): any[];
112 toString(prettyPrint?: boolean): string;
113 private _reExecute;
114}
115export interface View extends StatisticsApi, PartitionApi, HierarchyApi, GeoApi {
116}
117export {};