@d3plus/core 3.0.13 → 3.0.15
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 +78 -51
- package/es/src/charts/Sankey.js +37 -1
- package/es/src/components/Axis.js +21 -5
- package/package.json +8 -8
- package/umd/d3plus-core.full.js +49 -8
- package/umd/d3plus-core.full.js.map +1 -1
- package/umd/d3plus-core.full.min.js +27 -7
- package/umd/d3plus-core.js +49 -8
- package/umd/d3plus-core.js.map +1 -1
- package/umd/d3plus-core.min.js +58 -38
|
@@ -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,7 +293,6 @@ var fixFloat = function(d) {
|
|
|
276
293
|
ticks.push(domain[1]);
|
|
277
294
|
}
|
|
278
295
|
}
|
|
279
|
-
if (this._scale === "time" && this._data.length) ticks = this._data;
|
|
280
296
|
return ticks;
|
|
281
297
|
}
|
|
282
298
|
var Axis = /*#__PURE__*/ function(BaseClass) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@d3plus/core",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.15",
|
|
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.15",
|
|
38
|
+
"@d3plus/data": "3.0.15",
|
|
39
|
+
"@d3plus/dom": "3.0.15",
|
|
40
|
+
"@d3plus/format": "3.0.15",
|
|
41
|
+
"@d3plus/locales": "3.0.15",
|
|
42
|
+
"@d3plus/math": "3.0.15",
|
|
43
|
+
"@d3plus/text": "3.0.15",
|
|
44
44
|
"@popperjs/core": "^2.11.8",
|
|
45
45
|
"d3-array": "^3.2.4",
|
|
46
46
|
"d3-brush": "^3.0.0",
|
package/umd/d3plus-core.full.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*
|
|
2
|
-
@d3plus/core v3.0.
|
|
2
|
+
@d3plus/core v3.0.15
|
|
3
3
|
Data visualization made easy. A javascript library that extends the popular D3.js to enable fast and beautiful visualizations.
|
|
4
|
-
Copyright (c)
|
|
4
|
+
Copyright (c) 2026 D3plus - https://d3plus.org
|
|
5
5
|
@license MIT
|
|
6
6
|
*/
|
|
7
7
|
|
|
@@ -26286,6 +26286,7 @@
|
|
|
26286
26286
|
if (zeroMatch) return +`${zeroMatch[1]}${+zeroMatch[2]}`;
|
|
26287
26287
|
return d;
|
|
26288
26288
|
};
|
|
26289
|
+
const maxTimezoneOffset = 1000 * 60 * 60 * 26;
|
|
26289
26290
|
/**
|
|
26290
26291
|
* Calculates ticks from a given scale (negative and/or positive)
|
|
26291
26292
|
* @param {scale} scale A d3-scale object
|
|
@@ -26328,9 +26329,15 @@
|
|
|
26328
26329
|
* @private
|
|
26329
26330
|
*/ function calculateTicks(scale, minorTicks = false) {
|
|
26330
26331
|
let ticks = [];
|
|
26331
|
-
const
|
|
26332
|
-
|
|
26332
|
+
const scaleClone = scale.copy();
|
|
26333
|
+
if (this._scale === "time" && this._data.length) {
|
|
26334
|
+
const newDomain = extent$1(this._data);
|
|
26335
|
+
const range = newDomain.map(scale);
|
|
26336
|
+
scaleClone.domain(newDomain).range(range);
|
|
26337
|
+
}
|
|
26338
|
+
const domain = scaleClone.domain();
|
|
26333
26339
|
const inverted = domain[1] < domain[0];
|
|
26340
|
+
const step = calculateStep.bind(this)(scaleClone, minorTicks);
|
|
26334
26341
|
if (!minorTicks && this._scale === "log") {
|
|
26335
26342
|
const roundDomain = domain.map((d)=>Math.log10(d) % 1 === 0 ? d : (inverted ? ceilPow : floorPow)(d));
|
|
26336
26343
|
const invertedRound = roundDomain[1] < roundDomain[0];
|
|
@@ -26339,11 +26346,11 @@
|
|
|
26339
26346
|
1
|
|
26340
26347
|
].includes(d) || Math.abs(d) < 1 ? 1 : Math.log10(Math.abs(d))));
|
|
26341
26348
|
const powMod = Math.ceil((Math.abs(powers[1] - powers[0]) + 1) / (step * 0.65));
|
|
26342
|
-
ticks = powMod <= 1 && powers[0] === powers[1] || invertedRound !== inverted ?
|
|
26349
|
+
ticks = powMod <= 1 && powers[0] === powers[1] || invertedRound !== inverted ? scaleClone.ticks(step).filter((d)=>+`${d}`.replace("0.", "") % 2 === 0) : range$1(powers[0], powers[1], powers[1] < powers[0] ? -1 : 1).concat([
|
|
26343
26350
|
powers[1]
|
|
26344
26351
|
]).filter((d)=>Math.abs(d) % powMod === 0).map((d)=>+`${(isNegative(d) ? -1 : 1) * (d ? Math.pow(10, Math.abs(d)) : Math.sign(1 / d) > 0 ? 1 : -1)}`.replace(/9+/g, "1"));
|
|
26345
26352
|
} else {
|
|
26346
|
-
ticks =
|
|
26353
|
+
ticks = scaleClone.ticks(step);
|
|
26347
26354
|
if (!minorTicks && ![
|
|
26348
26355
|
"log",
|
|
26349
26356
|
"time"
|
|
@@ -26359,6 +26366,14 @@
|
|
|
26359
26366
|
});
|
|
26360
26367
|
}
|
|
26361
26368
|
}
|
|
26369
|
+
// for time scale, if data array has been provided, filter out ticks that are not in the array
|
|
26370
|
+
if (this._scale === "time" && this._data.length) {
|
|
26371
|
+
const dataNumbers = this._data.map(Number);
|
|
26372
|
+
ticks = ticks.filter((t)=>{
|
|
26373
|
+
const tn = +t;
|
|
26374
|
+
return dataNumbers.find((n)=>n >= tn - maxTimezoneOffset && n <= tn + maxTimezoneOffset);
|
|
26375
|
+
});
|
|
26376
|
+
}
|
|
26362
26377
|
// forces min/max into ticks, if not present
|
|
26363
26378
|
if (!this._d3ScaleNegative || isNegative(domain[inverted ? 1 : 0]) === ticks.some((d)=>isNegative(d))) {
|
|
26364
26379
|
if (!ticks.map(Number).includes(+domain[0])) {
|
|
@@ -26370,7 +26385,6 @@
|
|
|
26370
26385
|
ticks.push(domain[1]);
|
|
26371
26386
|
}
|
|
26372
26387
|
}
|
|
26373
|
-
if (this._scale === "time" && this._data.length) ticks = this._data;
|
|
26374
26388
|
return ticks;
|
|
26375
26389
|
}
|
|
26376
26390
|
class Axis extends BaseClass {
|
|
@@ -56291,7 +56305,7 @@
|
|
|
56291
56305
|
return obj;
|
|
56292
56306
|
}, {});
|
|
56293
56307
|
const transform = `translate(${this._margin.left}, ${this._margin.top})`;
|
|
56294
|
-
this._sankey.nodeAlign(this._nodeAlign).nodePadding(this._nodePadding).nodeWidth(this._nodeWidth).nodes(nodes).links(links).size([
|
|
56308
|
+
this._sankey.nodeAlign(this._nodeAlign).nodePadding(this._nodePadding).nodeWidth(this._nodeWidth).nodes(nodes).nodeSort(this._nodeSort).links(links).linkSort(this._linkSort).iterations(this._iterations).size([
|
|
56295
56309
|
width,
|
|
56296
56310
|
height
|
|
56297
56311
|
])();
|
|
@@ -56328,6 +56342,14 @@
|
|
|
56328
56342
|
if (this._legend) this._legendClass.hover(_);
|
|
56329
56343
|
return this;
|
|
56330
56344
|
}
|
|
56345
|
+
/**
|
|
56346
|
+
@memberof Sankey
|
|
56347
|
+
@desc A pass-through for the d3-sankey [iterations](https://github.com/d3/d3-sankey?tab=readme-ov-file#sankey_iterations) function.
|
|
56348
|
+
@param {Number} [*value* = 6]
|
|
56349
|
+
@chainable
|
|
56350
|
+
*/ iterations(_) {
|
|
56351
|
+
return arguments.length ? (this._iterations = _, this) : this._iterations;
|
|
56352
|
+
}
|
|
56331
56353
|
/**
|
|
56332
56354
|
@memberof Sankey
|
|
56333
56355
|
@desc A predefined *Array* of edges that connect each object passed to the [node](#Sankey.node) method. The `source` and `target` keys in each link need to map to the nodes in one of one way:
|
|
@@ -56343,6 +56365,14 @@
|
|
|
56343
56365
|
}
|
|
56344
56366
|
return this._links;
|
|
56345
56367
|
}
|
|
56368
|
+
/**
|
|
56369
|
+
@memberof Sankey
|
|
56370
|
+
@desc A pass-through for the d3-sankey [linkSort](https://github.com/d3/d3-sankey?tab=readme-ov-file#sankey_linkSort) function.
|
|
56371
|
+
@param {Function|undefined} [*value* = undefined]
|
|
56372
|
+
@chainable
|
|
56373
|
+
*/ linkSort(_) {
|
|
56374
|
+
return arguments.length ? (this._linkSort = _, this) : this._linkSort;
|
|
56375
|
+
}
|
|
56346
56376
|
/**
|
|
56347
56377
|
@memberof Sankey
|
|
56348
56378
|
@desc The key inside of each link Object that references the source node.
|
|
@@ -56397,6 +56427,14 @@
|
|
|
56397
56427
|
*/ nodePadding(_) {
|
|
56398
56428
|
return arguments.length ? (this._nodePadding = _, this) : this._nodePadding;
|
|
56399
56429
|
}
|
|
56430
|
+
/**
|
|
56431
|
+
@memberof Sankey
|
|
56432
|
+
@desc A pass-through for the d3-sankey [nodeSort](https://github.com/d3/d3-sankey?tab=readme-ov-file#sankey_nodeSort) function.
|
|
56433
|
+
@param {Function|undefined} [*value* = undefined]
|
|
56434
|
+
@chainable
|
|
56435
|
+
*/ nodeSort(_) {
|
|
56436
|
+
return arguments.length ? (this._nodeSort = _, this) : this._nodeSort;
|
|
56437
|
+
}
|
|
56400
56438
|
/**
|
|
56401
56439
|
@memberof Sankey
|
|
56402
56440
|
@desc If *value* is specified, sets the width of the node and returns the current class instance. If *value* is not specified, returns the current nodeWidth. By default, the nodeWidth size is 30.
|
|
@@ -56422,8 +56460,11 @@
|
|
|
56422
56460
|
@private
|
|
56423
56461
|
*/ constructor(){
|
|
56424
56462
|
super();
|
|
56463
|
+
this._iterations = 6;
|
|
56425
56464
|
this._nodeId = accessor("id");
|
|
56465
|
+
this._nodeSort = undefined;
|
|
56426
56466
|
this._links = accessor("links");
|
|
56467
|
+
this._linkSort = undefined;
|
|
56427
56468
|
this._linksSource = "source";
|
|
56428
56469
|
this._linksTarget = "target";
|
|
56429
56470
|
this._noDataMessage = false;
|