@antv/l7-layers 2.25.3 → 2.25.5
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/utils/scale.js +13 -6
- package/lib/utils/scale.js +13 -6
- package/package.json +6 -6
package/es/utils/scale.js
CHANGED
|
@@ -55,9 +55,9 @@ export function scaleLinear() {
|
|
|
55
55
|
const r0 = range[0];
|
|
56
56
|
const r1 = range[range.length - 1];
|
|
57
57
|
|
|
58
|
-
// 处理相等的 domain
|
|
58
|
+
// 处理相等的 domain - 返回 range 中值,避免所有值映射到最小值
|
|
59
59
|
if (d0 === d1) {
|
|
60
|
-
return r0;
|
|
60
|
+
return (r0 + r1) / 2;
|
|
61
61
|
}
|
|
62
62
|
let t = (x - d0) / (d1 - d0);
|
|
63
63
|
if (_clamp) t = Math.max(0, Math.min(1, t));
|
|
@@ -124,8 +124,10 @@ export function scalePow() {
|
|
|
124
124
|
const d1 = domain[domain.length - 1];
|
|
125
125
|
const r0 = range[0];
|
|
126
126
|
const r1 = range[range.length - 1];
|
|
127
|
+
|
|
128
|
+
// 处理相等的 domain - 返回 range 中值,避免所有值映射到最小值
|
|
127
129
|
if (d0 === d1) {
|
|
128
|
-
return r0;
|
|
130
|
+
return (r0 + r1) / 2;
|
|
129
131
|
}
|
|
130
132
|
let t = (x - d0) / (d1 - d0);
|
|
131
133
|
if (_clamp) t = Math.max(0, Math.min(1, t));
|
|
@@ -206,8 +208,10 @@ export function scaleLog() {
|
|
|
206
208
|
const d1 = domain[domain.length - 1];
|
|
207
209
|
const r0 = range[0];
|
|
208
210
|
const r1 = range[range.length - 1];
|
|
211
|
+
|
|
212
|
+
// 处理相等的 domain - 返回 range 中值,避免所有值映射到最小值
|
|
209
213
|
if (d0 === d1) {
|
|
210
|
-
return r0;
|
|
214
|
+
return (r0 + r1) / 2;
|
|
211
215
|
}
|
|
212
216
|
const absD0 = Math.abs(d0) || 1;
|
|
213
217
|
const absD1 = Math.abs(d1) || 1;
|
|
@@ -316,8 +320,9 @@ export function scaleQuantize() {
|
|
|
316
320
|
function scale(x) {
|
|
317
321
|
const d0 = domain[0];
|
|
318
322
|
const d1 = domain[domain.length - 1];
|
|
323
|
+
// 处理相等的 domain - 返回 range 中值,避免所有值映射到最小值
|
|
319
324
|
if (d0 === d1) {
|
|
320
|
-
return _range[
|
|
325
|
+
return _range[Math.floor(_range.length / 2)];
|
|
321
326
|
}
|
|
322
327
|
const t = (x - d0) / (d1 - d0);
|
|
323
328
|
const i = Math.max(0, Math.min(n - 1, Math.floor(t * n)));
|
|
@@ -531,8 +536,10 @@ export function scaleTime() {
|
|
|
531
536
|
const d1 = domain[domain.length - 1];
|
|
532
537
|
const r0 = range[0];
|
|
533
538
|
const r1 = range[range.length - 1];
|
|
539
|
+
|
|
540
|
+
// 处理相等的 domain - 返回 range 中值,避免所有值映射到最小值
|
|
534
541
|
if (d0 === d1) {
|
|
535
|
-
return r0;
|
|
542
|
+
return (r0 + r1) / 2;
|
|
536
543
|
}
|
|
537
544
|
let t = (x - d0) / (d1 - d0);
|
|
538
545
|
if (_clamp) t = Math.max(0, Math.min(1, t));
|
package/lib/utils/scale.js
CHANGED
|
@@ -70,9 +70,9 @@ function scaleLinear() {
|
|
|
70
70
|
const r0 = range[0];
|
|
71
71
|
const r1 = range[range.length - 1];
|
|
72
72
|
|
|
73
|
-
// 处理相等的 domain
|
|
73
|
+
// 处理相等的 domain - 返回 range 中值,避免所有值映射到最小值
|
|
74
74
|
if (d0 === d1) {
|
|
75
|
-
return r0;
|
|
75
|
+
return (r0 + r1) / 2;
|
|
76
76
|
}
|
|
77
77
|
let t = (x - d0) / (d1 - d0);
|
|
78
78
|
if (_clamp) t = Math.max(0, Math.min(1, t));
|
|
@@ -139,8 +139,10 @@ function scalePow() {
|
|
|
139
139
|
const d1 = domain[domain.length - 1];
|
|
140
140
|
const r0 = range[0];
|
|
141
141
|
const r1 = range[range.length - 1];
|
|
142
|
+
|
|
143
|
+
// 处理相等的 domain - 返回 range 中值,避免所有值映射到最小值
|
|
142
144
|
if (d0 === d1) {
|
|
143
|
-
return r0;
|
|
145
|
+
return (r0 + r1) / 2;
|
|
144
146
|
}
|
|
145
147
|
let t = (x - d0) / (d1 - d0);
|
|
146
148
|
if (_clamp) t = Math.max(0, Math.min(1, t));
|
|
@@ -221,8 +223,10 @@ function scaleLog() {
|
|
|
221
223
|
const d1 = domain[domain.length - 1];
|
|
222
224
|
const r0 = range[0];
|
|
223
225
|
const r1 = range[range.length - 1];
|
|
226
|
+
|
|
227
|
+
// 处理相等的 domain - 返回 range 中值,避免所有值映射到最小值
|
|
224
228
|
if (d0 === d1) {
|
|
225
|
-
return r0;
|
|
229
|
+
return (r0 + r1) / 2;
|
|
226
230
|
}
|
|
227
231
|
const absD0 = Math.abs(d0) || 1;
|
|
228
232
|
const absD1 = Math.abs(d1) || 1;
|
|
@@ -331,8 +335,9 @@ function scaleQuantize() {
|
|
|
331
335
|
function scale(x) {
|
|
332
336
|
const d0 = domain[0];
|
|
333
337
|
const d1 = domain[domain.length - 1];
|
|
338
|
+
// 处理相等的 domain - 返回 range 中值,避免所有值映射到最小值
|
|
334
339
|
if (d0 === d1) {
|
|
335
|
-
return _range[
|
|
340
|
+
return _range[Math.floor(_range.length / 2)];
|
|
336
341
|
}
|
|
337
342
|
const t = (x - d0) / (d1 - d0);
|
|
338
343
|
const i = Math.max(0, Math.min(n - 1, Math.floor(t * n)));
|
|
@@ -546,8 +551,10 @@ function scaleTime() {
|
|
|
546
551
|
const d1 = domain[domain.length - 1];
|
|
547
552
|
const r0 = range[0];
|
|
548
553
|
const r1 = range[range.length - 1];
|
|
554
|
+
|
|
555
|
+
// 处理相等的 domain - 返回 range 中值,避免所有值映射到最小值
|
|
549
556
|
if (d0 === d1) {
|
|
550
|
-
return r0;
|
|
557
|
+
return (r0 + r1) / 2;
|
|
551
558
|
}
|
|
552
559
|
let t = (x - d0) / (d1 - d0);
|
|
553
560
|
if (_clamp) t = Math.max(0, Math.min(1, t));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antv/l7-layers",
|
|
3
|
-
"version": "2.25.
|
|
3
|
+
"version": "2.25.5",
|
|
4
4
|
"description": "L7's collection of built-in layers",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "https://github.com/orgs/antvis/people",
|
|
@@ -26,15 +26,15 @@
|
|
|
26
26
|
"earcut": "^2.2.1",
|
|
27
27
|
"eventemitter3": "^4.0.0",
|
|
28
28
|
"gl-matrix": "^3.1.0",
|
|
29
|
-
"@antv/l7-core": "2.25.
|
|
30
|
-
"@antv/l7-maps": "2.25.
|
|
31
|
-
"@antv/l7-source": "2.25.
|
|
32
|
-
"@antv/l7-utils": "2.25.
|
|
29
|
+
"@antv/l7-core": "2.25.5",
|
|
30
|
+
"@antv/l7-maps": "2.25.5",
|
|
31
|
+
"@antv/l7-source": "2.25.5",
|
|
32
|
+
"@antv/l7-utils": "2.25.5"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@types/earcut": "^2.1.0",
|
|
36
36
|
"@types/gl-matrix": "^2.4.5",
|
|
37
|
-
"@antv/l7-test-utils": "^2.25.
|
|
37
|
+
"@antv/l7-test-utils": "^2.25.5"
|
|
38
38
|
},
|
|
39
39
|
"publishConfig": {
|
|
40
40
|
"access": "public",
|