1 | import { IGroup } from '../dependents';
|
2 | import { AxisCfg, Condition, Datum, FacetCfg, FacetData, FacetDataFilter, Region } from '../interface';
|
3 | import View from '../chart/view';
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 | export declare abstract class Facet<C extends FacetCfg<FacetData> = FacetCfg<FacetData>, F extends FacetData = FacetData> {
|
29 |
|
30 | view: View;
|
31 |
|
32 | container: IGroup;
|
33 |
|
34 | destroyed: boolean;
|
35 |
|
36 | protected cfg: C;
|
37 |
|
38 | protected facets: F[];
|
39 | constructor(view: View, cfg: C);
|
40 | /**
|
41 | * 初始化过程
|
42 | */
|
43 | init(): void;
|
44 | /**
|
45 | * 渲染分面,由上层 view 调用。包括:
|
46 | * - 分面 view
|
47 | * - 轴
|
48 | * - title
|
49 | *
|
50 | * 子类可以复写,添加一些其他组件,比如滚动条等
|
51 | */
|
52 | render(): void;
|
53 | /**
|
54 | * 更新 facet
|
55 | */
|
56 | update(): void;
|
57 | /**
|
58 | * 清空,clear 之后如果还需要使用,需要重新调用 init 初始化过程
|
59 | * 一般在数据有变更的时候调用,重新进行数据的分面逻辑
|
60 | */
|
61 | clear(): void;
|
62 | /**
|
63 | * 销毁
|
64 | */
|
65 | destroy(): void;
|
66 | /**
|
67 | * 根据 facet 生成 view,可以给上层自定义使用
|
68 | * @param facet
|
69 | */
|
70 | protected facetToView(facet: F): View;
|
71 | private createContainer;
|
72 | /**
|
73 | * 初始化 view
|
74 | */
|
75 | private renderViews;
|
76 | /**
|
77 | * 创建 分面 view
|
78 | */
|
79 | private createFacetViews;
|
80 | /**
|
81 | * 从 view 中清除 facetView
|
82 | */
|
83 | private clearFacetViews;
|
84 | /**
|
85 | * 解析 spacing
|
86 | */
|
87 | private parseSpacing;
|
88 | /**
|
89 | * 获取这个字段对应的所有值,数组
|
90 | * @protected
|
91 | * @param data 数据
|
92 | * @param field 字段名
|
93 | * @return 字段对应的值
|
94 | */
|
95 | protected getFieldValues(data: Datum[], field: string): string[];
|
96 | /**
|
97 | * 获得每个分面的 region,平分区域
|
98 | * @param rows row 总数
|
99 | * @param cols col 总数
|
100 | * @param xIndex x 方向 index
|
101 | * @param yIndex y 方向 index
|
102 | */
|
103 | protected getRegion(rows: number, cols: number, xIndex: number, yIndex: number): Region;
|
104 | protected getDefaultCfg(): {
|
105 | eachView: any;
|
106 | showTitle: boolean;
|
107 | spacing: number[];
|
108 | padding: number;
|
109 | fields: any[];
|
110 | };
|
111 | |
112 |
|
113 |
|
114 | protected getDefaultTitleCfg(): {
|
115 | style: {
|
116 | fontSize: number;
|
117 | fill: string;
|
118 | fontFamily: any;
|
119 | };
|
120 | };
|
121 | |
122 |
|
123 |
|
124 |
|
125 |
|
126 | protected processAxis(view: View, facet: F): void;
|
127 | |
128 |
|
129 |
|
130 |
|
131 | protected getFacetDataFilter(conditions: Condition[]): FacetDataFilter;
|
132 | |
133 |
|
134 |
|
135 |
|
136 |
|
137 | protected abstract beforeEachView(view: View, facet: F): any;
|
138 | |
139 |
|
140 |
|
141 |
|
142 |
|
143 | protected abstract afterEachView(view: View, facet: F): any;
|
144 | |
145 |
|
146 |
|
147 |
|
148 | protected abstract generateFacets(data: Datum[]): F[];
|
149 | |
150 |
|
151 |
|
152 |
|
153 |
|
154 |
|
155 |
|
156 | protected abstract getXAxisOption(x: string, axes: any, option: AxisCfg, facet: F): object;
|
157 | |
158 |
|
159 |
|
160 |
|
161 |
|
162 |
|
163 |
|
164 | protected abstract getYAxisOption(y: string, axes: any, option: AxisCfg, facet: F): object;
|
165 | }
|