@antv/l7-layers 2.23.1 → 2.23.3-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/{citybuliding → citybuilding}/models/build.js +4 -2
- package/es/core/BaseLayer.js +3 -3
- package/es/core/LayerPickService.js +3 -1
- package/es/core/shape/Path.d.ts +2 -1
- package/es/core/shape/Path.js +10 -4
- package/es/core/triangulation.js +51 -1
- package/es/earth/index.js +2 -3
- package/es/geometry/index.js +2 -3
- package/es/heatmap/index.js +6 -6
- package/es/heatmap/models/heatmap.js +2 -3
- package/es/index.d.ts +1 -1
- package/es/index.js +1 -1
- package/es/line/index.js +2 -3
- package/es/plugins/DataMappingPlugin.js +30 -10
- package/es/plugins/FeatureScalePlugin.js +21 -20
- package/es/plugins/ShaderUniformPlugin.js +62 -29
- package/es/polygon/index.js +2 -3
- package/es/polygon/models/extrude.js +22 -7
- package/es/polygon/models/ocean.js +17 -6
- package/es/polygon/models/water.js +17 -6
- package/es/tile/core/BaseLayer.d.ts +4 -1
- package/es/tile/core/BaseLayer.js +19 -11
- package/es/tile/service/TileLayerService.d.ts +26 -1
- package/es/tile/service/TileLayerService.js +88 -16
- package/es/tile/service/TilePickService.js +15 -9
- package/es/utils/scale.d.ts +87 -0
- package/es/utils/scale.js +588 -0
- package/lib/{citybuliding → citybuilding}/models/build.js +4 -2
- package/lib/core/BaseLayer.js +3 -3
- package/lib/core/LayerPickService.js +3 -1
- package/lib/core/shape/Path.d.ts +2 -1
- package/lib/core/shape/Path.js +10 -4
- package/lib/core/triangulation.js +50 -1
- package/lib/earth/index.js +2 -3
- package/lib/geometry/index.js +2 -3
- package/lib/heatmap/index.js +6 -6
- package/lib/heatmap/models/heatmap.js +2 -3
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/lib/line/index.js +2 -3
- package/lib/plugins/DataMappingPlugin.js +30 -10
- package/lib/plugins/FeatureScalePlugin.js +22 -23
- package/lib/plugins/ShaderUniformPlugin.js +62 -29
- package/lib/polygon/index.js +2 -3
- package/lib/polygon/models/extrude.js +22 -7
- package/lib/polygon/models/ocean.js +17 -6
- package/lib/polygon/models/water.js +17 -6
- package/lib/tile/core/BaseLayer.d.ts +4 -1
- package/lib/tile/core/BaseLayer.js +19 -11
- package/lib/tile/service/TileLayerService.d.ts +26 -1
- package/lib/tile/service/TileLayerService.js +88 -16
- package/lib/tile/service/TilePickService.js +15 -9
- package/lib/utils/scale.d.ts +87 -0
- package/lib/utils/scale.js +603 -0
- package/package.json +6 -17
- /package/es/{citybuliding → citybuilding}/building.d.ts +0 -0
- /package/es/{citybuliding → citybuilding}/building.js +0 -0
- /package/es/{citybuliding → citybuilding}/models/build.d.ts +0 -0
- /package/es/{citybuliding → citybuilding}/shaders/build_frag.glsl +0 -0
- /package/es/{citybuliding → citybuilding}/shaders/build_vert.glsl +0 -0
- /package/lib/{citybuliding → citybuilding}/building.d.ts +0 -0
- /package/lib/{citybuliding → citybuilding}/building.js +0 -0
- /package/lib/{citybuliding → citybuilding}/models/build.d.ts +0 -0
- /package/lib/{citybuliding → citybuilding}/shaders/build_frag.glsl +0 -0
- /package/lib/{citybuliding → citybuilding}/shaders/build_vert.glsl +0 -0
|
@@ -78,10 +78,6 @@ export default class WaterModel extends BaseModel {
|
|
|
78
78
|
(_this$texture = this.texture) === null || _this$texture === void 0 || _this$texture.destroy();
|
|
79
79
|
}
|
|
80
80
|
registerBuiltinAttributes() {
|
|
81
|
-
const bbox = this.layer.getSource().extent;
|
|
82
|
-
const [minLng, minLat, maxLng, maxLat] = bbox;
|
|
83
|
-
const lngLen = maxLng - minLng;
|
|
84
|
-
const latLen = maxLat - minLat;
|
|
85
81
|
this.styleAttributeService.registerStyleAttribute({
|
|
86
82
|
name: 'waterUv',
|
|
87
83
|
type: AttributeType.Attribute,
|
|
@@ -89,14 +85,29 @@ export default class WaterModel extends BaseModel {
|
|
|
89
85
|
name: 'a_uv',
|
|
90
86
|
shaderLocation: this.attributeLocation.UV,
|
|
91
87
|
buffer: {
|
|
92
|
-
// give the WebGL driver a hint that this buffer may change
|
|
93
88
|
usage: gl.STATIC_DRAW,
|
|
94
89
|
data: [],
|
|
95
90
|
type: gl.FLOAT
|
|
96
91
|
},
|
|
97
92
|
size: 2,
|
|
98
93
|
update: (feature, featureIdx, vertex) => {
|
|
99
|
-
|
|
94
|
+
// 当启用 enableRelativeCoordinates 时:需要将相对坐标转换回绝对坐标
|
|
95
|
+
const originalExtent = this.layer.getOriginalExtent();
|
|
96
|
+
const relativeOrigin = this.layer.getRelativeOrigin();
|
|
97
|
+
const isRelativeCoordinates = originalExtent[0] !== 0 || originalExtent[2] !== 0;
|
|
98
|
+
let lng, lat;
|
|
99
|
+
let minLng, minLat, maxLng, maxLat;
|
|
100
|
+
if (isRelativeCoordinates && relativeOrigin) {
|
|
101
|
+
lng = vertex[0] + relativeOrigin[0];
|
|
102
|
+
lat = vertex[1] + relativeOrigin[1];
|
|
103
|
+
[minLng, minLat, maxLng, maxLat] = originalExtent;
|
|
104
|
+
} else {
|
|
105
|
+
lng = vertex[0];
|
|
106
|
+
lat = vertex[1];
|
|
107
|
+
[minLng, minLat, maxLng, maxLat] = this.layer.getSource().extent;
|
|
108
|
+
}
|
|
109
|
+
const lngLen = maxLng - minLng;
|
|
110
|
+
const latLen = maxLat - minLat;
|
|
100
111
|
return [(lng - minLng) / lngLen, (lat - minLat) / latLen];
|
|
101
112
|
}
|
|
102
113
|
}
|
|
@@ -14,7 +14,10 @@ export default class BaseTileLayer {
|
|
|
14
14
|
initedTileset: boolean;
|
|
15
15
|
protected lastViewStates: {
|
|
16
16
|
zoom: number;
|
|
17
|
-
|
|
17
|
+
minLng: number;
|
|
18
|
+
minLat: number;
|
|
19
|
+
maxLng: number;
|
|
20
|
+
maxLat: number;
|
|
18
21
|
};
|
|
19
22
|
constructor(parent: ILayer);
|
|
20
23
|
protected initTileSetManager(): void;
|
|
@@ -32,12 +32,17 @@ export default class BaseTileLayer {
|
|
|
32
32
|
latLonBounds,
|
|
33
33
|
zoom
|
|
34
34
|
} = this.getCurrentView();
|
|
35
|
-
|
|
35
|
+
|
|
36
|
+
// 使用数值比较替代字符串比较,更高效
|
|
37
|
+
if (this.lastViewStates && this.lastViewStates.zoom === zoom && this.lastViewStates.minLng === latLonBounds[0] && this.lastViewStates.minLat === latLonBounds[1] && this.lastViewStates.maxLng === latLonBounds[2] && this.lastViewStates.maxLat === latLonBounds[3]) {
|
|
36
38
|
return;
|
|
37
39
|
}
|
|
38
40
|
this.lastViewStates = {
|
|
39
41
|
zoom,
|
|
40
|
-
latLonBounds
|
|
42
|
+
minLng: latLonBounds[0],
|
|
43
|
+
minLat: latLonBounds[1],
|
|
44
|
+
maxLng: latLonBounds[2],
|
|
45
|
+
maxLat: latLonBounds[3]
|
|
41
46
|
};
|
|
42
47
|
(_this$tilesetManager = this.tilesetManager) === null || _this$tilesetManager === void 0 || _this$tilesetManager.throttleUpdate(zoom, latLonBounds);
|
|
43
48
|
});
|
|
@@ -98,7 +103,7 @@ export default class BaseTileLayer {
|
|
|
98
103
|
}
|
|
99
104
|
bindTilesetEvent() {
|
|
100
105
|
// 瓦片数据加载成功
|
|
101
|
-
|
|
106
|
+
|
|
102
107
|
this.tilesetManager.on('tile-loaded', tile => {
|
|
103
108
|
// 将事件抛出,图层上可以监听使用
|
|
104
109
|
});
|
|
@@ -110,7 +115,7 @@ export default class BaseTileLayer {
|
|
|
110
115
|
});
|
|
111
116
|
|
|
112
117
|
// 瓦片数据加载失败
|
|
113
|
-
|
|
118
|
+
|
|
114
119
|
this.tilesetManager.on('tile-error', (error, tile) => {
|
|
115
120
|
// 将事件抛出,图层上可以监听使用
|
|
116
121
|
this.tileError(error);
|
|
@@ -137,7 +142,6 @@ export default class BaseTileLayer {
|
|
|
137
142
|
getTile(key) {
|
|
138
143
|
return this.tileLayerService.getTile(key);
|
|
139
144
|
}
|
|
140
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
141
145
|
tileLoaded(tile) {
|
|
142
146
|
//
|
|
143
147
|
}
|
|
@@ -173,10 +177,16 @@ export default class BaseTileLayer {
|
|
|
173
177
|
}
|
|
174
178
|
const minZoom = _this.parent.getMinZoom();
|
|
175
179
|
const maxZoom = _this.parent.getMaxZoom();
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
.filter(tile => tile.
|
|
179
|
-
|
|
180
|
+
|
|
181
|
+
// 合并 filter 操作,减少中间数组创建
|
|
182
|
+
const tiles = _this.tilesetManager.tiles.filter(tile => tile.isLoaded &&
|
|
183
|
+
// 过滤未加载完成的
|
|
184
|
+
tile.isVisibleChange &&
|
|
185
|
+
// 过滤未发生变化的
|
|
186
|
+
tile.data &&
|
|
187
|
+
//
|
|
188
|
+
tile.z >= minZoom && tile.z < maxZoom // 过滤不可见层级
|
|
189
|
+
);
|
|
180
190
|
yield Promise.all(tiles.map( /*#__PURE__*/function () {
|
|
181
191
|
var _ref = _asyncToGenerator(function* (tile) {
|
|
182
192
|
// 未加载瓦片
|
|
@@ -207,8 +217,6 @@ export default class BaseTileLayer {
|
|
|
207
217
|
}
|
|
208
218
|
})();
|
|
209
219
|
}
|
|
210
|
-
|
|
211
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
212
220
|
setPickState(layers) {
|
|
213
221
|
return;
|
|
214
222
|
}
|
|
@@ -13,14 +13,39 @@ export declare class TileLayerService {
|
|
|
13
13
|
private rendererService;
|
|
14
14
|
private layerService;
|
|
15
15
|
private parent;
|
|
16
|
-
|
|
16
|
+
/**
|
|
17
|
+
* 使用 Map 存储瓦片实例,查找复杂度从 O(n) 降为 O(1)
|
|
18
|
+
*/
|
|
19
|
+
private layerTilesMap;
|
|
20
|
+
/**
|
|
21
|
+
* 待销毁瓦片队列,用于分帧销毁
|
|
22
|
+
*/
|
|
23
|
+
private pendingDestroyQueue;
|
|
24
|
+
private maxDestroyPerFrame;
|
|
25
|
+
/**
|
|
26
|
+
* 渲染图层缓存
|
|
27
|
+
*/
|
|
28
|
+
private renderLayersCache;
|
|
29
|
+
private renderCacheDirty;
|
|
17
30
|
constructor({ rendererService, layerService, parent }: ITileLayerServiceOptions);
|
|
18
31
|
get tiles(): ITile[];
|
|
32
|
+
/**
|
|
33
|
+
* 获取待销毁瓦片数量
|
|
34
|
+
*/
|
|
35
|
+
get pendingDestroyCount(): number;
|
|
19
36
|
hasTile(tileKey: string): boolean;
|
|
20
37
|
addTile(tile: ITile): void;
|
|
21
38
|
getTile(tileKey: string): ITile | undefined;
|
|
22
39
|
getVisibleTileBylngLat(lngLat: ILngLat): ITile | undefined;
|
|
23
40
|
removeTile(tileKey: string): void;
|
|
41
|
+
/**
|
|
42
|
+
* 分帧销毁待销毁队列中的瓦片
|
|
43
|
+
*/
|
|
44
|
+
processPendingDestroys(): void;
|
|
45
|
+
/**
|
|
46
|
+
* 标记渲染缓存为脏
|
|
47
|
+
*/
|
|
48
|
+
markRenderCacheDirty(): void;
|
|
24
49
|
updateTileVisible(sourceTile: SourceTile): void;
|
|
25
50
|
isParentLoaded(sourceTile: SourceTile): boolean;
|
|
26
51
|
isChildrenLoaded(sourceTile: SourceTile): boolean;
|
|
@@ -13,34 +13,82 @@ export class TileLayerService {
|
|
|
13
13
|
_defineProperty(this, "rendererService", void 0);
|
|
14
14
|
_defineProperty(this, "layerService", void 0);
|
|
15
15
|
_defineProperty(this, "parent", void 0);
|
|
16
|
-
|
|
16
|
+
/**
|
|
17
|
+
* 使用 Map 存储瓦片实例,查找复杂度从 O(n) 降为 O(1)
|
|
18
|
+
*/
|
|
19
|
+
_defineProperty(this, "layerTilesMap", new Map());
|
|
20
|
+
/**
|
|
21
|
+
* 待销毁瓦片队列,用于分帧销毁
|
|
22
|
+
*/
|
|
23
|
+
_defineProperty(this, "pendingDestroyQueue", []);
|
|
24
|
+
_defineProperty(this, "maxDestroyPerFrame", 3);
|
|
25
|
+
/**
|
|
26
|
+
* 渲染图层缓存
|
|
27
|
+
*/
|
|
28
|
+
_defineProperty(this, "renderLayersCache", null);
|
|
29
|
+
_defineProperty(this, "renderCacheDirty", true);
|
|
17
30
|
this.rendererService = rendererService;
|
|
18
31
|
this.layerService = layerService;
|
|
19
32
|
this.parent = parent;
|
|
20
33
|
}
|
|
21
34
|
get tiles() {
|
|
22
|
-
return this.
|
|
35
|
+
return Array.from(this.layerTilesMap.values());
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* 获取待销毁瓦片数量
|
|
40
|
+
*/
|
|
41
|
+
get pendingDestroyCount() {
|
|
42
|
+
return this.pendingDestroyQueue.length;
|
|
23
43
|
}
|
|
24
44
|
hasTile(tileKey) {
|
|
25
|
-
return this.
|
|
45
|
+
return this.layerTilesMap.has(tileKey);
|
|
26
46
|
}
|
|
27
47
|
addTile(tile) {
|
|
28
|
-
this.
|
|
48
|
+
this.layerTilesMap.set(tile.key, tile);
|
|
49
|
+
this.markRenderCacheDirty();
|
|
29
50
|
}
|
|
30
51
|
getTile(tileKey) {
|
|
31
|
-
return this.
|
|
52
|
+
return this.layerTilesMap.get(tileKey);
|
|
32
53
|
}
|
|
33
54
|
getVisibleTileBylngLat(lngLat) {
|
|
34
55
|
// 加载完成 & 可见 & 鼠标选中
|
|
35
|
-
|
|
56
|
+
for (const tile of this.layerTilesMap.values()) {
|
|
57
|
+
if (tile.isLoaded && tile.visible && tile.lnglatInBounds(lngLat)) {
|
|
58
|
+
return tile;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return undefined;
|
|
36
62
|
}
|
|
37
63
|
removeTile(tileKey) {
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
64
|
+
const tile = this.layerTilesMap.get(tileKey);
|
|
65
|
+
if (tile) {
|
|
66
|
+
this.layerTilesMap.delete(tileKey);
|
|
67
|
+
// 放入待销毁队列,分帧销毁
|
|
68
|
+
this.pendingDestroyQueue.push(tile);
|
|
69
|
+
this.markRenderCacheDirty();
|
|
42
70
|
}
|
|
43
71
|
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* 分帧销毁待销毁队列中的瓦片
|
|
75
|
+
*/
|
|
76
|
+
processPendingDestroys() {
|
|
77
|
+
const count = Math.min(this.pendingDestroyQueue.length, this.maxDestroyPerFrame);
|
|
78
|
+
for (let i = 0; i < count; i++) {
|
|
79
|
+
const tile = this.pendingDestroyQueue.shift();
|
|
80
|
+
if (tile) {
|
|
81
|
+
tile.destroy();
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* 标记渲染缓存为脏
|
|
88
|
+
*/
|
|
89
|
+
markRenderCacheDirty() {
|
|
90
|
+
this.renderCacheDirty = true;
|
|
91
|
+
}
|
|
44
92
|
updateTileVisible(sourceTile) {
|
|
45
93
|
const tile = this.getTile(sourceTile.key);
|
|
46
94
|
if (sourceTile.isVisible) {
|
|
@@ -60,6 +108,7 @@ export class TileLayerService {
|
|
|
60
108
|
tile === null || tile === void 0 || tile.updateVisible(false);
|
|
61
109
|
}
|
|
62
110
|
}
|
|
111
|
+
this.markRenderCacheDirty();
|
|
63
112
|
}
|
|
64
113
|
isParentLoaded(sourceTile) {
|
|
65
114
|
const parentTile = sourceTile.parent;
|
|
@@ -89,6 +138,8 @@ export class TileLayerService {
|
|
|
89
138
|
render() {
|
|
90
139
|
var _this = this;
|
|
91
140
|
return _asyncToGenerator(function* () {
|
|
141
|
+
// 每帧处理部分待销毁瓦片
|
|
142
|
+
_this.processPendingDestroys();
|
|
92
143
|
const layers = _this.getRenderLayers();
|
|
93
144
|
const renders = layers.map( /*#__PURE__*/function () {
|
|
94
145
|
var _ref = _asyncToGenerator(function* (layer) {
|
|
@@ -102,22 +153,43 @@ export class TileLayerService {
|
|
|
102
153
|
})();
|
|
103
154
|
}
|
|
104
155
|
getRenderLayers() {
|
|
105
|
-
|
|
156
|
+
// 使用缓存避免每帧重建
|
|
157
|
+
if (!this.renderCacheDirty && this.renderLayersCache) {
|
|
158
|
+
return this.renderLayersCache;
|
|
159
|
+
}
|
|
106
160
|
const layers = [];
|
|
107
|
-
|
|
161
|
+
this.layerTilesMap.forEach(tile => {
|
|
162
|
+
if (tile.visible && tile.isLoaded) {
|
|
163
|
+
layers.push(...tile.getLayers());
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
this.renderLayersCache = layers;
|
|
167
|
+
this.renderCacheDirty = false;
|
|
108
168
|
return layers;
|
|
109
169
|
}
|
|
110
170
|
getLayers() {
|
|
111
|
-
const tileList = this.layerTiles.filter(t => t.isLoaded);
|
|
112
171
|
const layers = [];
|
|
113
|
-
|
|
172
|
+
this.layerTilesMap.forEach(tile => {
|
|
173
|
+
if (tile.isLoaded) {
|
|
174
|
+
layers.push(...tile.getLayers());
|
|
175
|
+
}
|
|
176
|
+
});
|
|
114
177
|
return layers;
|
|
115
178
|
}
|
|
116
179
|
getTiles() {
|
|
117
|
-
return this.
|
|
180
|
+
return Array.from(this.layerTilesMap.values());
|
|
118
181
|
}
|
|
119
182
|
destroy() {
|
|
120
|
-
|
|
183
|
+
// 先处理待销毁队列中的残留瓦片
|
|
184
|
+
while (this.pendingDestroyQueue.length > 0) {
|
|
185
|
+
const tile = this.pendingDestroyQueue.shift();
|
|
186
|
+
tile === null || tile === void 0 || tile.destroy();
|
|
187
|
+
}
|
|
188
|
+
// 销毁所有已加载的瓦片
|
|
189
|
+
this.layerTilesMap.forEach(t => t.destroy());
|
|
190
|
+
this.layerTilesMap.clear();
|
|
191
|
+
// 清理缓存
|
|
192
|
+
this.renderLayersCache = null;
|
|
121
193
|
this.tileResource.clear();
|
|
122
194
|
}
|
|
123
195
|
}
|
|
@@ -61,7 +61,9 @@ export class TilePickService {
|
|
|
61
61
|
this.updateHighLight(r, g, b, ACTIVE);
|
|
62
62
|
}
|
|
63
63
|
updateHighLight(r, g, b, type) {
|
|
64
|
-
|
|
64
|
+
// 只遍历已加载的瓦片,跳过不可见的
|
|
65
|
+
for (const tile of this.tileLayerService.tiles) {
|
|
66
|
+
if (!tile.isLoaded) continue;
|
|
65
67
|
const layer = tile.getMainLayer();
|
|
66
68
|
switch (type) {
|
|
67
69
|
case SELECT:
|
|
@@ -71,7 +73,7 @@ export class TilePickService {
|
|
|
71
73
|
layer === null || layer === void 0 || layer.hooks.beforeHighlight.call([r, g, b]);
|
|
72
74
|
break;
|
|
73
75
|
}
|
|
74
|
-
}
|
|
76
|
+
}
|
|
75
77
|
}
|
|
76
78
|
setPickState() {
|
|
77
79
|
const selectColor = this.tilePickID.get(SELECT);
|
|
@@ -96,13 +98,17 @@ export class TilePickService {
|
|
|
96
98
|
|
|
97
99
|
/** 从瓦片中根据数据 */
|
|
98
100
|
getFeatureById(pickedFeatureIdx) {
|
|
99
|
-
//
|
|
100
|
-
const tiles = this.tileLayerService.getTiles().filter(tile => tile.visible);
|
|
101
|
-
// 提取当前可见瓦片中匹配 ID 的 feature 列表
|
|
101
|
+
// 提取当前可见瓦片并合并 features
|
|
102
102
|
const features = [];
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
103
|
+
for (const tile of this.tileLayerService.tiles) {
|
|
104
|
+
if (tile.visible && tile.isLoaded) {
|
|
105
|
+
const tileFeatures = tile.getFeatureById(pickedFeatureIdx);
|
|
106
|
+
// 直接 push 而非使用扩展操作符
|
|
107
|
+
for (let i = 0; i < tileFeatures.length; i++) {
|
|
108
|
+
features.push(tileFeatures[i]);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
106
112
|
|
|
107
113
|
// 将 feature 列表合并后返回
|
|
108
114
|
// 统一返回成 polygon 的格式 点、线、面可以通用
|
|
@@ -113,7 +119,7 @@ export class TilePickService {
|
|
|
113
119
|
}
|
|
114
120
|
|
|
115
121
|
// Tip: for interface define
|
|
116
|
-
|
|
122
|
+
|
|
117
123
|
pickRasterLayer() {
|
|
118
124
|
return false;
|
|
119
125
|
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 比例尺工具
|
|
3
|
+
* 用于替代 d3-scale 的功能
|
|
4
|
+
*/
|
|
5
|
+
export interface ScaleLinear {
|
|
6
|
+
(x: number): number;
|
|
7
|
+
domain(): number[];
|
|
8
|
+
domain(domain: number[]): ScaleLinear;
|
|
9
|
+
range(): number[];
|
|
10
|
+
range(range: number[]): ScaleLinear;
|
|
11
|
+
invert(y: number): number;
|
|
12
|
+
ticks(count?: number): number[];
|
|
13
|
+
nice(count?: number): ScaleLinear;
|
|
14
|
+
clamp(): boolean;
|
|
15
|
+
clamp(clamp: boolean): ScaleLinear;
|
|
16
|
+
}
|
|
17
|
+
export declare function scaleLinear(): ScaleLinear;
|
|
18
|
+
export interface ScalePow extends ScaleLinear {
|
|
19
|
+
exponent(): number;
|
|
20
|
+
exponent(k: number): ScalePow;
|
|
21
|
+
}
|
|
22
|
+
export declare function scalePow(): ScalePow;
|
|
23
|
+
export interface ScaleLog extends ScaleLinear {
|
|
24
|
+
base(): number;
|
|
25
|
+
base(b: number): ScaleLog;
|
|
26
|
+
}
|
|
27
|
+
export declare function scaleLog(): ScaleLog;
|
|
28
|
+
export interface ScaleOrdinal<T = any> {
|
|
29
|
+
(x: any): T;
|
|
30
|
+
domain(): any[];
|
|
31
|
+
domain(domain: any[]): ScaleOrdinal<T>;
|
|
32
|
+
range(): T[];
|
|
33
|
+
range(range: T[]): ScaleOrdinal<T>;
|
|
34
|
+
unknown(value: T): ScaleOrdinal<T>;
|
|
35
|
+
}
|
|
36
|
+
export declare function scaleOrdinal<T = any>(range?: T[]): ScaleOrdinal<T>;
|
|
37
|
+
export interface ScaleQuantize {
|
|
38
|
+
(x: number): any;
|
|
39
|
+
domain(): number[];
|
|
40
|
+
domain(domain: number[]): ScaleQuantize;
|
|
41
|
+
range(): any[];
|
|
42
|
+
range(range: any[]): ScaleQuantize;
|
|
43
|
+
invertExtent(y: any): [number, number];
|
|
44
|
+
}
|
|
45
|
+
export declare function scaleQuantize(): ScaleQuantize;
|
|
46
|
+
export interface ScaleQuantile {
|
|
47
|
+
(x: number): any;
|
|
48
|
+
domain(): number[];
|
|
49
|
+
domain(domain: number[]): ScaleQuantile;
|
|
50
|
+
range(): any[];
|
|
51
|
+
range(range: any[]): ScaleQuantile;
|
|
52
|
+
invertExtent(y: any): [number, number];
|
|
53
|
+
quantiles(): number[];
|
|
54
|
+
}
|
|
55
|
+
export declare function scaleQuantile(): ScaleQuantile;
|
|
56
|
+
export interface ScaleThreshold {
|
|
57
|
+
(x: number): any;
|
|
58
|
+
domain(): number[];
|
|
59
|
+
domain(domain: number[]): ScaleThreshold;
|
|
60
|
+
range(): any[];
|
|
61
|
+
range(range: any[]): ScaleThreshold;
|
|
62
|
+
invertExtent(y: any): [number | undefined, number | undefined];
|
|
63
|
+
}
|
|
64
|
+
export declare function scaleThreshold(): ScaleThreshold;
|
|
65
|
+
export interface ScaleSequential {
|
|
66
|
+
(x: number): any;
|
|
67
|
+
domain(): number[];
|
|
68
|
+
domain(domain: number[]): ScaleSequential;
|
|
69
|
+
interpolator(): (t: number) => any;
|
|
70
|
+
interpolator(interpolator: (t: number) => any): ScaleSequential;
|
|
71
|
+
clamp(): boolean;
|
|
72
|
+
clamp(clamp: boolean): ScaleSequential;
|
|
73
|
+
}
|
|
74
|
+
export declare function scaleSequential(): ScaleSequential;
|
|
75
|
+
export interface ScaleDiverging {
|
|
76
|
+
(x: number): any;
|
|
77
|
+
domain(): number[];
|
|
78
|
+
domain(domain: number[]): ScaleDiverging;
|
|
79
|
+
interpolator(): (t: number) => any;
|
|
80
|
+
interpolator(interpolator: (t: number) => any): ScaleDiverging;
|
|
81
|
+
clamp(): boolean;
|
|
82
|
+
clamp(clamp: boolean): ScaleDiverging;
|
|
83
|
+
}
|
|
84
|
+
export declare function scaleDiverging(): ScaleDiverging;
|
|
85
|
+
export interface ScaleTime extends ScaleLinear {
|
|
86
|
+
}
|
|
87
|
+
export declare function scaleTime(): ScaleTime;
|