@antv/l7-layers 2.11.6 → 2.12.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/plugins/FeatureScalePlugin.js +10 -5
- package/es/point/models/text.js +1 -1
- package/es/utils/identityScale.d.ts +8 -0
- package/es/utils/identityScale.js +34 -0
- package/lib/plugins/FeatureScalePlugin.js +11 -5
- package/lib/point/models/text.js +1 -1
- package/lib/utils/identityScale.js +41 -0
- package/package.json +6 -6
|
@@ -14,8 +14,9 @@ import * as d3 from 'd3-scale';
|
|
|
14
14
|
import { injectable } from 'inversify';
|
|
15
15
|
import { isNil, isString, uniq } from 'lodash';
|
|
16
16
|
import 'reflect-metadata';
|
|
17
|
+
import identity from "../utils/identityScale";
|
|
17
18
|
var dateRegex = /^(?:(?!0000)[0-9]{4}([-/.]+)(?:(?:0?[1-9]|1[0-2])\1(?:0?[1-9]|1[0-9]|2[0-8])|(?:0?[13-9]|1[0-2])\1(?:29|30)|(?:0?[13578]|1[02])\1(?:31))|(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:0[48]|[2468][048]|[13579][26])00)([-/.]?)0?2\2(?:29))(\s+([01]|([01][0-9]|2[0-3])):([0-9]|[0-5][0-9]):([0-9]|[0-5][0-9]))?$/;
|
|
18
|
-
var scaleMap = (_scaleMap = {}, _defineProperty(_scaleMap, ScaleTypes.LINEAR, d3.scaleLinear), _defineProperty(_scaleMap, ScaleTypes.POWER, d3.scalePow), _defineProperty(_scaleMap, ScaleTypes.LOG, d3.scaleLog), _defineProperty(_scaleMap, ScaleTypes.IDENTITY,
|
|
19
|
+
var scaleMap = (_scaleMap = {}, _defineProperty(_scaleMap, ScaleTypes.LINEAR, d3.scaleLinear), _defineProperty(_scaleMap, ScaleTypes.POWER, d3.scalePow), _defineProperty(_scaleMap, ScaleTypes.LOG, d3.scaleLog), _defineProperty(_scaleMap, ScaleTypes.IDENTITY, identity), _defineProperty(_scaleMap, ScaleTypes.SEQUENTIAL, d3.scaleSequential), _defineProperty(_scaleMap, ScaleTypes.TIME, d3.scaleTime), _defineProperty(_scaleMap, ScaleTypes.QUANTILE, d3.scaleQuantile), _defineProperty(_scaleMap, ScaleTypes.QUANTIZE, d3.scaleQuantize), _defineProperty(_scaleMap, ScaleTypes.THRESHOLD, d3.scaleThreshold), _defineProperty(_scaleMap, ScaleTypes.CAT, d3.scaleOrdinal), _defineProperty(_scaleMap, ScaleTypes.DIVERGING, d3.scaleDiverging), _scaleMap);
|
|
19
20
|
/**
|
|
20
21
|
* 根据 Source 原始数据为指定字段创建 Scale,保存在 StyleAttribute 上,供下游插件使用
|
|
21
22
|
*/
|
|
@@ -183,6 +184,10 @@ var FeatureScalePlugin = (_dec = injectable(), _dec(_class = /*#__PURE__*/functi
|
|
|
183
184
|
|
|
184
185
|
break;
|
|
185
186
|
|
|
187
|
+
case ScaleTypes.IDENTITY:
|
|
188
|
+
// 不做处理xe
|
|
189
|
+
break;
|
|
190
|
+
|
|
186
191
|
case ScaleTypes.CAT:
|
|
187
192
|
attributeScale.values ? scale.scale.range(attributeScale.values) : scale.scale.range(scale.option.domain);
|
|
188
193
|
break;
|
|
@@ -313,10 +318,7 @@ var FeatureScalePlugin = (_dec = injectable(), _dec(_class = /*#__PURE__*/functi
|
|
|
313
318
|
|
|
314
319
|
if (scaleOption !== null && scaleOption !== void 0 && scaleOption.domain) {
|
|
315
320
|
cfg.domain = scaleOption === null || scaleOption === void 0 ? void 0 : scaleOption.domain;
|
|
316
|
-
} else if (type
|
|
317
|
-
// linear/
|
|
318
|
-
cfg.domain = extent(values);
|
|
319
|
-
} else if (type === ScaleTypes.CAT) {
|
|
321
|
+
} else if (type === ScaleTypes.CAT || type === ScaleTypes.IDENTITY) {
|
|
320
322
|
cfg.domain = uniq(values);
|
|
321
323
|
} else if (type === ScaleTypes.QUANTILE) {
|
|
322
324
|
cfg.domain = values;
|
|
@@ -324,6 +326,9 @@ var FeatureScalePlugin = (_dec = injectable(), _dec(_class = /*#__PURE__*/functi
|
|
|
324
326
|
var minMax = extent(values);
|
|
325
327
|
var neutral = (scaleOption === null || scaleOption === void 0 ? void 0 : scaleOption.neutral) !== undefined ? scaleOption === null || scaleOption === void 0 ? void 0 : scaleOption.neutral : (minMax[0] + minMax[1]) / 2;
|
|
326
328
|
cfg.domain = [minMax[0], neutral, minMax[1]];
|
|
329
|
+
} else {
|
|
330
|
+
// linear/Power/log
|
|
331
|
+
cfg.domain = extent(values);
|
|
327
332
|
}
|
|
328
333
|
|
|
329
334
|
return _objectSpread(_objectSpread({}, cfg), scaleOption);
|
package/es/point/models/text.js
CHANGED
|
@@ -585,7 +585,7 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
585
585
|
|
|
586
586
|
var _ref9 = this.layer.getLayerConfig(),
|
|
587
587
|
_ref9$padding = _ref9.padding,
|
|
588
|
-
padding = _ref9$padding === void 0 ? [
|
|
588
|
+
padding = _ref9$padding === void 0 ? [0, 0] : _ref9$padding,
|
|
589
589
|
_ref9$textAllowOverla = _ref9.textAllowOverlap,
|
|
590
590
|
textAllowOverlap = _ref9$textAllowOverla === void 0 ? false : _ref9$textAllowOverla;
|
|
591
591
|
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export default function identity(d) {
|
|
2
|
+
var unknown;
|
|
3
|
+
var domain = [];
|
|
4
|
+
|
|
5
|
+
function scale(x) {
|
|
6
|
+
return x == null ? unknown : x;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
scale.invert = scale;
|
|
10
|
+
|
|
11
|
+
scale.domain = scale.range = function (v) {
|
|
12
|
+
if (v) {
|
|
13
|
+
domain = v;
|
|
14
|
+
return v;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return domain;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
scale.unknown = function (v) {
|
|
21
|
+
if (v) {
|
|
22
|
+
unknown = v;
|
|
23
|
+
return v;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return unknown;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
scale.copy = function () {
|
|
30
|
+
return identity(d).unknown(unknown);
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
return scale;
|
|
34
|
+
}
|
|
@@ -35,6 +35,8 @@ var _lodash = require("lodash");
|
|
|
35
35
|
|
|
36
36
|
require("reflect-metadata");
|
|
37
37
|
|
|
38
|
+
var _identityScale = _interopRequireDefault(require("../utils/identityScale"));
|
|
39
|
+
|
|
38
40
|
var _scaleMap, _dec, _class;
|
|
39
41
|
|
|
40
42
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
@@ -42,7 +44,7 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
42
44
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
43
45
|
|
|
44
46
|
var dateRegex = /^(?:(?!0000)[0-9]{4}([-/.]+)(?:(?:0?[1-9]|1[0-2])\1(?:0?[1-9]|1[0-9]|2[0-8])|(?:0?[13-9]|1[0-2])\1(?:29|30)|(?:0?[13578]|1[02])\1(?:31))|(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:0[48]|[2468][048]|[13579][26])00)([-/.]?)0?2\2(?:29))(\s+([01]|([01][0-9]|2[0-3])):([0-9]|[0-5][0-9]):([0-9]|[0-5][0-9]))?$/;
|
|
45
|
-
var scaleMap = (_scaleMap = {}, (0, _defineProperty2.default)(_scaleMap, _l7Core.ScaleTypes.LINEAR, d3.scaleLinear), (0, _defineProperty2.default)(_scaleMap, _l7Core.ScaleTypes.POWER, d3.scalePow), (0, _defineProperty2.default)(_scaleMap, _l7Core.ScaleTypes.LOG, d3.scaleLog), (0, _defineProperty2.default)(_scaleMap, _l7Core.ScaleTypes.IDENTITY,
|
|
47
|
+
var scaleMap = (_scaleMap = {}, (0, _defineProperty2.default)(_scaleMap, _l7Core.ScaleTypes.LINEAR, d3.scaleLinear), (0, _defineProperty2.default)(_scaleMap, _l7Core.ScaleTypes.POWER, d3.scalePow), (0, _defineProperty2.default)(_scaleMap, _l7Core.ScaleTypes.LOG, d3.scaleLog), (0, _defineProperty2.default)(_scaleMap, _l7Core.ScaleTypes.IDENTITY, _identityScale.default), (0, _defineProperty2.default)(_scaleMap, _l7Core.ScaleTypes.SEQUENTIAL, d3.scaleSequential), (0, _defineProperty2.default)(_scaleMap, _l7Core.ScaleTypes.TIME, d3.scaleTime), (0, _defineProperty2.default)(_scaleMap, _l7Core.ScaleTypes.QUANTILE, d3.scaleQuantile), (0, _defineProperty2.default)(_scaleMap, _l7Core.ScaleTypes.QUANTIZE, d3.scaleQuantize), (0, _defineProperty2.default)(_scaleMap, _l7Core.ScaleTypes.THRESHOLD, d3.scaleThreshold), (0, _defineProperty2.default)(_scaleMap, _l7Core.ScaleTypes.CAT, d3.scaleOrdinal), (0, _defineProperty2.default)(_scaleMap, _l7Core.ScaleTypes.DIVERGING, d3.scaleDiverging), _scaleMap);
|
|
46
48
|
/**
|
|
47
49
|
* 根据 Source 原始数据为指定字段创建 Scale,保存在 StyleAttribute 上,供下游插件使用
|
|
48
50
|
*/
|
|
@@ -209,6 +211,10 @@ var FeatureScalePlugin = (_dec = (0, _inversify.injectable)(), _dec(_class = /*#
|
|
|
209
211
|
|
|
210
212
|
break;
|
|
211
213
|
|
|
214
|
+
case _l7Core.ScaleTypes.IDENTITY:
|
|
215
|
+
// 不做处理xe
|
|
216
|
+
break;
|
|
217
|
+
|
|
212
218
|
case _l7Core.ScaleTypes.CAT:
|
|
213
219
|
attributeScale.values ? scale.scale.range(attributeScale.values) : scale.scale.range(scale.option.domain);
|
|
214
220
|
break;
|
|
@@ -339,10 +345,7 @@ var FeatureScalePlugin = (_dec = (0, _inversify.injectable)(), _dec(_class = /*#
|
|
|
339
345
|
|
|
340
346
|
if (scaleOption !== null && scaleOption !== void 0 && scaleOption.domain) {
|
|
341
347
|
cfg.domain = scaleOption === null || scaleOption === void 0 ? void 0 : scaleOption.domain;
|
|
342
|
-
} else if (type
|
|
343
|
-
// linear/
|
|
344
|
-
cfg.domain = (0, _d3Array.extent)(values);
|
|
345
|
-
} else if (type === _l7Core.ScaleTypes.CAT) {
|
|
348
|
+
} else if (type === _l7Core.ScaleTypes.CAT || type === _l7Core.ScaleTypes.IDENTITY) {
|
|
346
349
|
cfg.domain = (0, _lodash.uniq)(values);
|
|
347
350
|
} else if (type === _l7Core.ScaleTypes.QUANTILE) {
|
|
348
351
|
cfg.domain = values;
|
|
@@ -350,6 +353,9 @@ var FeatureScalePlugin = (_dec = (0, _inversify.injectable)(), _dec(_class = /*#
|
|
|
350
353
|
var minMax = (0, _d3Array.extent)(values);
|
|
351
354
|
var neutral = (scaleOption === null || scaleOption === void 0 ? void 0 : scaleOption.neutral) !== undefined ? scaleOption === null || scaleOption === void 0 ? void 0 : scaleOption.neutral : (minMax[0] + minMax[1]) / 2;
|
|
352
355
|
cfg.domain = [minMax[0], neutral, minMax[1]];
|
|
356
|
+
} else {
|
|
357
|
+
// linear/Power/log
|
|
358
|
+
cfg.domain = (0, _d3Array.extent)(values);
|
|
353
359
|
}
|
|
354
360
|
|
|
355
361
|
return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, cfg), scaleOption);
|
package/lib/point/models/text.js
CHANGED
|
@@ -602,7 +602,7 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
602
602
|
|
|
603
603
|
var _ref9 = this.layer.getLayerConfig(),
|
|
604
604
|
_ref9$padding = _ref9.padding,
|
|
605
|
-
padding = _ref9$padding === void 0 ? [
|
|
605
|
+
padding = _ref9$padding === void 0 ? [0, 0] : _ref9$padding,
|
|
606
606
|
_ref9$textAllowOverla = _ref9.textAllowOverlap,
|
|
607
607
|
textAllowOverlap = _ref9$textAllowOverla === void 0 ? false : _ref9$textAllowOverla;
|
|
608
608
|
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = identity;
|
|
7
|
+
|
|
8
|
+
function identity(d) {
|
|
9
|
+
var unknown;
|
|
10
|
+
var domain = [];
|
|
11
|
+
|
|
12
|
+
function scale(x) {
|
|
13
|
+
return x == null ? unknown : x;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
scale.invert = scale;
|
|
17
|
+
|
|
18
|
+
scale.domain = scale.range = function (v) {
|
|
19
|
+
if (v) {
|
|
20
|
+
domain = v;
|
|
21
|
+
return v;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return domain;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
scale.unknown = function (v) {
|
|
28
|
+
if (v) {
|
|
29
|
+
unknown = v;
|
|
30
|
+
return v;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return unknown;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
scale.copy = function () {
|
|
37
|
+
return identity(d).unknown(unknown);
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
return scale;
|
|
41
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antv/l7-layers",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.12.0",
|
|
4
4
|
"description": "L7's collection of built-in layers",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "es/index.js",
|
|
@@ -27,10 +27,10 @@
|
|
|
27
27
|
"license": "ISC",
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@antv/async-hook": "^2.2.9",
|
|
30
|
-
"@antv/l7-core": "2.
|
|
31
|
-
"@antv/l7-maps": "2.
|
|
32
|
-
"@antv/l7-source": "2.
|
|
33
|
-
"@antv/l7-utils": "2.
|
|
30
|
+
"@antv/l7-core": "2.12.0",
|
|
31
|
+
"@antv/l7-maps": "2.12.0",
|
|
32
|
+
"@antv/l7-source": "2.12.0",
|
|
33
|
+
"@antv/l7-utils": "2.12.0",
|
|
34
34
|
"@babel/runtime": "^7.7.7",
|
|
35
35
|
"@mapbox/martini": "^0.2.0",
|
|
36
36
|
"@turf/clone": "^6.5.0",
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"@types/gl-matrix": "^2.4.5",
|
|
62
62
|
"@types/lodash": "^4.14.138"
|
|
63
63
|
},
|
|
64
|
-
"gitHead": "
|
|
64
|
+
"gitHead": "2c0d52810384b8ccfd6b62884c569cad2a5fb116",
|
|
65
65
|
"publishConfig": {
|
|
66
66
|
"access": "public"
|
|
67
67
|
}
|