@d3plus/core 3.0.12 → 3.0.14
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/README.md +60 -60
- package/es/src/charts/Geomap.js +5 -33
- package/es/src/components/Axis.js +24 -14
- package/package.json +8 -8
- package/umd/d3plus-core.full.js +132 -356
- package/umd/d3plus-core.full.js.map +1 -1
- package/umd/d3plus-core.full.min.js +701 -719
- package/umd/d3plus-core.js +26 -40
- package/umd/d3plus-core.js.map +1 -1
- package/umd/d3plus-core.min.js +8 -7
|
@@ -147,7 +147,7 @@ import { timeFormat, timeFormatDefaultLocale } from "d3-time-format";
|
|
|
147
147
|
import * as scales from "d3-scale";
|
|
148
148
|
import { select } from "d3-selection";
|
|
149
149
|
import { transition } from "d3-transition";
|
|
150
|
-
import pkg from
|
|
150
|
+
import pkg from "open-color/open-color.js";
|
|
151
151
|
var openColor = pkg.theme;
|
|
152
152
|
import { colorDefaults } from "@d3plus/color";
|
|
153
153
|
import { assign, attrize, date, elem, rtl as detectRTL } from "@d3plus/dom";
|
|
@@ -176,6 +176,7 @@ var fixFloat = function(d) {
|
|
|
176
176
|
if (zeroMatch) return +"".concat(zeroMatch[1]).concat(+zeroMatch[2]);
|
|
177
177
|
return d;
|
|
178
178
|
};
|
|
179
|
+
var maxTimezoneOffset = 1000 * 60 * 60 * 26;
|
|
179
180
|
/**
|
|
180
181
|
* Calculates ticks from a given scale (negative and/or positive)
|
|
181
182
|
* @param {scale} scale A d3-scale object
|
|
@@ -220,9 +221,15 @@ var fixFloat = function(d) {
|
|
|
220
221
|
*/ function calculateTicks(scale) {
|
|
221
222
|
var minorTicks = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false;
|
|
222
223
|
var ticks = [];
|
|
223
|
-
var
|
|
224
|
-
|
|
224
|
+
var scaleClone = scale.copy();
|
|
225
|
+
if (this._scale === "time" && this._data.length) {
|
|
226
|
+
var newDomain = extent(this._data);
|
|
227
|
+
var range = newDomain.map(scale);
|
|
228
|
+
scaleClone.domain(newDomain).range(range);
|
|
229
|
+
}
|
|
230
|
+
var domain = scaleClone.domain();
|
|
225
231
|
var inverted = domain[1] < domain[0];
|
|
232
|
+
var step = calculateStep.bind(this)(scaleClone, minorTicks);
|
|
226
233
|
if (!minorTicks && this._scale === "log") {
|
|
227
234
|
var roundDomain = domain.map(function(d) {
|
|
228
235
|
return Math.log10(d) % 1 === 0 ? d : (inverted ? ceilPow : floorPow)(d);
|
|
@@ -235,7 +242,7 @@ var fixFloat = function(d) {
|
|
|
235
242
|
].includes(d) || Math.abs(d) < 1 ? 1 : Math.log10(Math.abs(d)));
|
|
236
243
|
});
|
|
237
244
|
var powMod = Math.ceil((Math.abs(powers[1] - powers[0]) + 1) / (step * 0.65));
|
|
238
|
-
ticks = powMod <= 1 && powers[0] === powers[1] || invertedRound !== inverted ?
|
|
245
|
+
ticks = powMod <= 1 && powers[0] === powers[1] || invertedRound !== inverted ? scaleClone.ticks(step).filter(function(d) {
|
|
239
246
|
return +"".concat(d).replace("0.", "") % 2 === 0;
|
|
240
247
|
}) : d3Range(powers[0], powers[1], powers[1] < powers[0] ? -1 : 1).concat([
|
|
241
248
|
powers[1]
|
|
@@ -245,7 +252,7 @@ var fixFloat = function(d) {
|
|
|
245
252
|
return +"".concat((isNegative(d) ? -1 : 1) * (d ? Math.pow(10, Math.abs(d)) : Math.sign(1 / d) > 0 ? 1 : -1)).replace(/9+/g, "1");
|
|
246
253
|
});
|
|
247
254
|
} else {
|
|
248
|
-
ticks =
|
|
255
|
+
ticks = scaleClone.ticks(step);
|
|
249
256
|
if (!minorTicks && ![
|
|
250
257
|
"log",
|
|
251
258
|
"time"
|
|
@@ -261,6 +268,16 @@ var fixFloat = function(d) {
|
|
|
261
268
|
});
|
|
262
269
|
}
|
|
263
270
|
}
|
|
271
|
+
// for time scale, if data array has been provided, filter out ticks that are not in the array
|
|
272
|
+
if (this._scale === "time" && this._data.length) {
|
|
273
|
+
var dataNumbers = this._data.map(Number);
|
|
274
|
+
ticks = ticks.filter(function(t) {
|
|
275
|
+
var tn = +t;
|
|
276
|
+
return dataNumbers.find(function(n) {
|
|
277
|
+
return n >= tn - maxTimezoneOffset && n <= tn + maxTimezoneOffset;
|
|
278
|
+
});
|
|
279
|
+
});
|
|
280
|
+
}
|
|
264
281
|
// forces min/max into ticks, if not present
|
|
265
282
|
if (!this._d3ScaleNegative || isNegative(domain[inverted ? 1 : 0]) === ticks.some(function(d) {
|
|
266
283
|
return isNegative(d);
|
|
@@ -276,13 +293,6 @@ var fixFloat = function(d) {
|
|
|
276
293
|
ticks.push(domain[1]);
|
|
277
294
|
}
|
|
278
295
|
}
|
|
279
|
-
// for time scale, if data array has been provided, filter out ticks that are not in the array
|
|
280
|
-
if (this._scale === "time" && this._data.length) {
|
|
281
|
-
var dataNumbers = this._data.map(Number);
|
|
282
|
-
ticks = ticks.filter(function(t) {
|
|
283
|
-
return dataNumbers.includes(+t);
|
|
284
|
-
});
|
|
285
|
-
}
|
|
286
296
|
return ticks;
|
|
287
297
|
}
|
|
288
298
|
var Axis = /*#__PURE__*/ function(BaseClass) {
|
|
@@ -294,7 +304,7 @@ var Axis = /*#__PURE__*/ function(BaseClass) {
|
|
|
294
304
|
_this = _call_super(this, Axis);
|
|
295
305
|
_this._align = "middle";
|
|
296
306
|
_this._barConfig = {
|
|
297
|
-
|
|
307
|
+
stroke: openColor.colors.gray[600],
|
|
298
308
|
"stroke-width": 1
|
|
299
309
|
};
|
|
300
310
|
_this._data = [];
|
|
@@ -304,7 +314,7 @@ var Axis = /*#__PURE__*/ function(BaseClass) {
|
|
|
304
314
|
];
|
|
305
315
|
_this._duration = 600;
|
|
306
316
|
_this._gridConfig = {
|
|
307
|
-
|
|
317
|
+
stroke: colorDefaults.light,
|
|
308
318
|
"stroke-width": 1
|
|
309
319
|
};
|
|
310
320
|
_this._gridLog = false;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@d3plus/core",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.14",
|
|
4
4
|
"description": "Data visualization made easy. A javascript library that extends the popular D3.js to enable fast and beautiful visualizations.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -34,13 +34,13 @@
|
|
|
34
34
|
"test": "eslint index.js src/**/*.js && eslint --global=it test && mocha 'test/**/*-test.js'"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@d3plus/color": "3.0.
|
|
38
|
-
"@d3plus/data": "3.0.
|
|
39
|
-
"@d3plus/dom": "3.0.
|
|
40
|
-
"@d3plus/format": "3.0.
|
|
41
|
-
"@d3plus/locales": "3.0.
|
|
42
|
-
"@d3plus/math": "3.0.
|
|
43
|
-
"@d3plus/text": "3.0.
|
|
37
|
+
"@d3plus/color": "3.0.14",
|
|
38
|
+
"@d3plus/data": "3.0.14",
|
|
39
|
+
"@d3plus/dom": "3.0.14",
|
|
40
|
+
"@d3plus/format": "3.0.14",
|
|
41
|
+
"@d3plus/locales": "3.0.14",
|
|
42
|
+
"@d3plus/math": "3.0.14",
|
|
43
|
+
"@d3plus/text": "3.0.14",
|
|
44
44
|
"@popperjs/core": "^2.11.8",
|
|
45
45
|
"d3-array": "^3.2.4",
|
|
46
46
|
"d3-brush": "^3.0.0",
|