@d3plus/core 3.0.16 → 3.1.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/LICENSE +21 -0
- package/README.md +88482 -2998
- package/es/index.js +1 -1
- package/es/src/charts/AreaPlot.js +1 -3
- package/es/src/charts/BarChart.js +1 -3
- package/es/src/charts/BoxWhisker.js +2 -4
- package/es/src/charts/BumpChart.js +4 -5
- package/es/src/charts/Donut.js +1 -3
- package/es/src/charts/Geomap.js +47 -88
- package/es/src/charts/LinePlot.js +1 -3
- package/es/src/charts/Matrix.js +27 -46
- package/es/src/charts/Network.js +87 -81
- package/es/src/charts/Pack.js +21 -34
- package/es/src/charts/Pie.js +12 -24
- package/es/src/charts/Plot.js +226 -321
- package/es/src/charts/Priestley.js +18 -36
- package/es/src/charts/Radar.js +100 -47
- package/es/src/charts/RadialMatrix.js +35 -47
- package/es/src/charts/Rings.js +99 -90
- package/es/src/charts/Sankey.js +85 -75
- package/es/src/charts/StackedArea.js +1 -3
- package/es/src/charts/Tree.js +27 -28
- package/es/src/charts/Treemap.js +117 -71
- package/es/src/charts/Viz.js +296 -492
- package/es/src/charts/drawSteps/drawAttribution.js +1 -1
- package/es/src/charts/drawSteps/drawBack.js +1 -2
- package/es/src/charts/drawSteps/drawColorScale.js +1 -2
- package/es/src/charts/drawSteps/drawLegend.js +8 -10
- package/es/src/charts/drawSteps/drawSubtitle.js +1 -3
- package/es/src/charts/drawSteps/drawTimeline.js +12 -9
- package/es/src/charts/drawSteps/drawTitle.js +1 -3
- package/es/src/charts/drawSteps/drawTotal.js +1 -3
- package/es/src/charts/drawSteps/zoomControls.js +19 -21
- package/es/src/charts/events/click.legend.js +2 -3
- package/es/src/charts/events/click.shape.js +2 -4
- package/es/src/charts/events/mouseenter.js +7 -8
- package/es/src/charts/events/mouseleave.js +1 -3
- package/es/src/charts/events/mousemove.legend.js +3 -4
- package/es/src/charts/events/mousemove.shape.js +2 -4
- package/es/src/charts/events/touchstart.body.js +1 -1
- package/es/src/charts/helpers/matrixData.js +11 -4
- package/es/src/charts/helpers/tileAttributions.js +2 -1
- package/es/src/charts/plotBuffers/Bar.js +55 -12
- package/es/src/charts/plotBuffers/Box.js +55 -12
- package/es/src/charts/plotBuffers/Circle.js +9 -11
- package/es/src/charts/plotBuffers/Line.js +4 -6
- package/es/src/charts/plotBuffers/Rect.js +10 -12
- package/es/src/charts/plotBuffers/discreteBuffer.js +4 -2
- package/es/src/charts/plotBuffers/numericBuffer.js +7 -6
- package/es/src/components/Axis.js +298 -426
- package/es/src/components/AxisBottom.js +1 -3
- package/es/src/components/AxisLeft.js +1 -3
- package/es/src/components/AxisRight.js +1 -3
- package/es/src/components/AxisTop.js +1 -3
- package/es/src/components/ColorScale.js +80 -197
- package/es/src/components/Legend.js +82 -135
- package/es/src/components/Message.js +27 -19
- package/es/src/components/TextBox.js +106 -262
- package/es/src/components/Timeline.js +88 -155
- package/es/src/components/Tooltip.js +301 -330
- package/es/src/shapes/Area.js +95 -74
- package/es/src/shapes/Bar.js +46 -86
- package/es/src/shapes/Box.js +104 -118
- package/es/src/shapes/Circle.js +29 -30
- package/es/src/shapes/Image.js +44 -102
- package/es/src/shapes/Line.js +74 -40
- package/es/src/shapes/Path.js +23 -25
- package/es/src/shapes/Rect.js +29 -41
- package/es/src/shapes/Shape.js +146 -363
- package/es/src/shapes/Whisker.js +89 -90
- package/es/src/utils/AccessorFn.js +4 -0
- package/es/src/utils/BaseClass.js +53 -82
- package/es/src/utils/D3plusConfig.js +1 -0
- package/es/src/utils/RESET.js +2 -4
- package/es/src/utils/accessor.js +4 -5
- package/es/src/utils/configPrep.js +13 -12
- package/es/src/utils/constant.js +2 -3
- package/es/src/utils/getProp.js +4 -4
- package/es/src/utils/index.js +0 -1
- package/package.json +29 -22
- package/types/index.d.ts +5 -0
- package/types/src/charts/AreaPlot.d.ts +16 -0
- package/types/src/charts/BarChart.d.ts +16 -0
- package/types/src/charts/BoxWhisker.d.ts +11 -0
- package/types/src/charts/BumpChart.d.ts +36 -0
- package/types/src/charts/Donut.d.ts +11 -0
- package/types/src/charts/Geomap.d.ts +120 -0
- package/types/src/charts/LinePlot.d.ts +15 -0
- package/types/src/charts/Matrix.d.ts +74 -0
- package/types/src/charts/Network.d.ts +78 -0
- package/types/src/charts/Pack.d.ts +47 -0
- package/types/src/charts/Pie.d.ts +44 -0
- package/types/src/charts/Plot.d.ts +199 -0
- package/types/src/charts/Priestley.d.ts +37 -0
- package/types/src/charts/Radar.d.ts +38 -0
- package/types/src/charts/RadialMatrix.d.ts +78 -0
- package/types/src/charts/Rings.d.ts +74 -0
- package/types/src/charts/Sankey.d.ts +81 -0
- package/types/src/charts/StackedArea.d.ts +14 -0
- package/types/src/charts/Tree.d.ts +33 -0
- package/types/src/charts/Treemap.d.ts +51 -0
- package/types/src/charts/Viz.d.ts +402 -0
- package/types/src/charts/drawSteps/drawAttribution.d.ts +7 -0
- package/types/src/charts/drawSteps/drawBack.d.ts +6 -0
- package/types/src/charts/drawSteps/drawColorScale.d.ts +6 -0
- package/types/src/charts/drawSteps/drawLegend.d.ts +12 -0
- package/types/src/charts/drawSteps/drawSubtitle.d.ts +7 -0
- package/types/src/charts/drawSteps/drawTimeline.d.ts +7 -0
- package/types/src/charts/drawSteps/drawTitle.d.ts +7 -0
- package/types/src/charts/drawSteps/drawTotal.d.ts +7 -0
- package/types/src/charts/drawSteps/zoomControls.d.ts +7 -0
- package/types/src/charts/events/click.legend.d.ts +8 -0
- package/types/src/charts/events/click.shape.d.ts +8 -0
- package/types/src/charts/events/mouseenter.d.ts +8 -0
- package/types/src/charts/events/mouseleave.d.ts +8 -0
- package/types/src/charts/events/mousemove.legend.d.ts +9 -0
- package/types/src/charts/events/mousemove.shape.d.ts +9 -0
- package/types/src/charts/events/touchstart.body.d.ts +7 -0
- package/types/src/charts/helpers/matrixData.d.ts +11 -0
- package/types/src/charts/helpers/tileAttributions.d.ts +6 -0
- package/types/src/charts/index.d.ts +21 -0
- package/types/src/charts/plotBuffers/Bar.d.ts +16 -0
- package/types/src/charts/plotBuffers/Box.d.ts +16 -0
- package/types/src/charts/plotBuffers/Circle.d.ts +20 -0
- package/types/src/charts/plotBuffers/Line.d.ts +16 -0
- package/types/src/charts/plotBuffers/Rect.d.ts +19 -0
- package/types/src/charts/plotBuffers/discreteBuffer.d.ts +7 -0
- package/types/src/charts/plotBuffers/numericBuffer.d.ts +5 -0
- package/types/src/components/Axis.d.ts +309 -0
- package/types/src/components/AxisBottom.d.ts +11 -0
- package/types/src/components/AxisLeft.d.ts +11 -0
- package/types/src/components/AxisRight.d.ts +11 -0
- package/types/src/components/AxisTop.d.ts +11 -0
- package/types/src/components/ColorScale.d.ts +208 -0
- package/types/src/components/Legend.d.ts +157 -0
- package/types/src/components/Message.d.ts +40 -0
- package/types/src/components/TextBox.d.ts +278 -0
- package/types/src/components/Timeline.d.ts +157 -0
- package/types/src/components/Tooltip.d.ts +297 -0
- package/types/src/components/index.d.ts +11 -0
- package/types/src/shapes/Area.d.ts +81 -0
- package/types/src/shapes/Bar.d.ts +104 -0
- package/types/src/shapes/Box.d.ts +121 -0
- package/types/src/shapes/Circle.d.ts +44 -0
- package/types/src/shapes/Image.d.ts +124 -0
- package/types/src/shapes/Line.d.ts +48 -0
- package/types/src/shapes/Path.d.ts +38 -0
- package/types/src/shapes/Rect.d.ts +54 -0
- package/types/src/shapes/Shape.d.ts +378 -0
- package/types/src/shapes/Whisker.d.ts +96 -0
- package/types/src/shapes/index.d.ts +10 -0
- package/types/src/utils/AccessorFn.d.ts +6 -0
- package/types/src/utils/BaseClass.d.ts +76 -0
- package/types/src/utils/D3plusConfig.d.ts +164 -0
- package/types/src/utils/RESET.d.ts +3 -0
- package/types/src/utils/accessor.d.ts +13 -0
- package/types/src/utils/configPrep.d.ts +28 -0
- package/types/src/utils/constant.d.ts +11 -0
- package/types/src/utils/getProp.d.ts +9 -0
- package/types/src/utils/index.d.ts +8 -0
- package/umd/d3plus-core.full.js +20126 -18700
- package/umd/d3plus-core.full.js.map +1 -1
- package/umd/d3plus-core.full.min.js +2919 -5393
- package/umd/d3plus-core.js +1919 -4073
- package/umd/d3plus-core.js.map +1 -1
- package/umd/d3plus-core.min.js +1604 -3936
- package/es/src/utils/uuid.js +0 -13
package/es/src/charts/Sankey.js
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
function _array_like_to_array(arr, len) {
|
|
2
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
3
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
4
|
+
return arr2;
|
|
5
|
+
}
|
|
6
|
+
function _array_with_holes(arr) {
|
|
7
|
+
if (Array.isArray(arr)) return arr;
|
|
8
|
+
}
|
|
1
9
|
function _assert_this_initialized(self) {
|
|
2
10
|
if (self === void 0) {
|
|
3
11
|
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
@@ -62,6 +70,33 @@ function _inherits(subClass, superClass) {
|
|
|
62
70
|
});
|
|
63
71
|
if (superClass) _set_prototype_of(subClass, superClass);
|
|
64
72
|
}
|
|
73
|
+
function _iterable_to_array_limit(arr, i) {
|
|
74
|
+
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
75
|
+
if (_i == null) return;
|
|
76
|
+
var _arr = [];
|
|
77
|
+
var _n = true;
|
|
78
|
+
var _d = false;
|
|
79
|
+
var _s, _e;
|
|
80
|
+
try {
|
|
81
|
+
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
|
|
82
|
+
_arr.push(_s.value);
|
|
83
|
+
if (i && _arr.length === i) break;
|
|
84
|
+
}
|
|
85
|
+
} catch (err) {
|
|
86
|
+
_d = true;
|
|
87
|
+
_e = err;
|
|
88
|
+
} finally{
|
|
89
|
+
try {
|
|
90
|
+
if (!_n && _i["return"] != null) _i["return"]();
|
|
91
|
+
} finally{
|
|
92
|
+
if (_d) throw _e;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return _arr;
|
|
96
|
+
}
|
|
97
|
+
function _non_iterable_rest() {
|
|
98
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
99
|
+
}
|
|
65
100
|
function _possible_constructor_return(self, call) {
|
|
66
101
|
if (call && (_type_of(call) === "object" || typeof call === "function")) {
|
|
67
102
|
return call;
|
|
@@ -75,6 +110,9 @@ function _set_prototype_of(o, p) {
|
|
|
75
110
|
};
|
|
76
111
|
return _set_prototype_of(o, p);
|
|
77
112
|
}
|
|
113
|
+
function _sliced_to_array(arr, i) {
|
|
114
|
+
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
115
|
+
}
|
|
78
116
|
function _super_prop_base(object, property) {
|
|
79
117
|
while(!Object.prototype.hasOwnProperty.call(object, property)){
|
|
80
118
|
object = _get_prototype_of(object);
|
|
@@ -86,6 +124,14 @@ function _type_of(obj) {
|
|
|
86
124
|
"@swc/helpers - typeof";
|
|
87
125
|
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
88
126
|
}
|
|
127
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
128
|
+
if (!o) return;
|
|
129
|
+
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
130
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
131
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
132
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
133
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
134
|
+
}
|
|
89
135
|
function _is_native_reflect_construct() {
|
|
90
136
|
try {
|
|
91
137
|
var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
|
|
@@ -94,7 +140,7 @@ function _is_native_reflect_construct() {
|
|
|
94
140
|
return !!result;
|
|
95
141
|
})();
|
|
96
142
|
}
|
|
97
|
-
import {
|
|
143
|
+
import { groups } from "d3-array";
|
|
98
144
|
import { sankey, sankeyCenter, sankeyJustify, sankeyLeft, sankeyLinkHorizontal, sankeyRight } from "d3-sankey";
|
|
99
145
|
var sankeyAligns = {
|
|
100
146
|
center: sankeyCenter,
|
|
@@ -173,7 +219,7 @@ var Sankey = /*#__PURE__*/ function(Viz) {
|
|
|
173
219
|
label: false,
|
|
174
220
|
stroke: "#DBDBDB",
|
|
175
221
|
strokeOpacity: 0.5,
|
|
176
|
-
strokeWidth: function(d) {
|
|
222
|
+
strokeWidth: function strokeWidth(d) {
|
|
177
223
|
return Math.max(1, Math.abs(d.source.y1 - d.source.y0) * (d.value / d.source.value) - 2);
|
|
178
224
|
}
|
|
179
225
|
},
|
|
@@ -187,7 +233,7 @@ var Sankey = /*#__PURE__*/ function(Viz) {
|
|
|
187
233
|
/**
|
|
188
234
|
Extends the draw behavior of the abstract Viz class.
|
|
189
235
|
@private
|
|
190
|
-
|
|
236
|
+
*/ key: "_draw",
|
|
191
237
|
value: function _draw(callback) {
|
|
192
238
|
var _this = this;
|
|
193
239
|
_get(_get_prototype_of(Sankey.prototype), "_draw", this).call(this, callback);
|
|
@@ -251,10 +297,11 @@ var Sankey = /*#__PURE__*/ function(Viz) {
|
|
|
251
297
|
transform: transform
|
|
252
298
|
}
|
|
253
299
|
}).node()).render());
|
|
254
|
-
|
|
300
|
+
groups(nodes, function(d) {
|
|
255
301
|
return d.shape;
|
|
256
|
-
}).
|
|
257
|
-
|
|
302
|
+
}).forEach(function(param) {
|
|
303
|
+
var _param = _sliced_to_array(param, 2), key = _param[0], values = _param[1];
|
|
304
|
+
_this._shapes.push(new shapes[key]().data(values).height(function(d) {
|
|
258
305
|
return d.y1 - d.y0;
|
|
259
306
|
}).width(function(d) {
|
|
260
307
|
return d.x1 - d.x0;
|
|
@@ -270,18 +317,15 @@ var Sankey = /*#__PURE__*/ function(Viz) {
|
|
|
270
317
|
update: {
|
|
271
318
|
transform: transform
|
|
272
319
|
}
|
|
273
|
-
}).node()).config(configPrep.bind(_this)(_this._shapeConfig, "shape",
|
|
320
|
+
}).node()).config(configPrep.bind(_this)(_this._shapeConfig, "shape", key)).render());
|
|
274
321
|
});
|
|
275
322
|
return this;
|
|
276
323
|
}
|
|
277
324
|
},
|
|
278
325
|
{
|
|
279
326
|
/**
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
@param {Function} [*value*]
|
|
283
|
-
@chainable
|
|
284
|
-
*/ key: "hover",
|
|
327
|
+
The hover callback function for highlighting shapes on mouseover.
|
|
328
|
+
*/ key: "hover",
|
|
285
329
|
value: function hover(_) {
|
|
286
330
|
this._hover = _;
|
|
287
331
|
this._shapes.forEach(function(s) {
|
|
@@ -293,25 +337,20 @@ var Sankey = /*#__PURE__*/ function(Viz) {
|
|
|
293
337
|
},
|
|
294
338
|
{
|
|
295
339
|
/**
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
@param {Number} [*value* = 6]
|
|
299
|
-
@chainable
|
|
300
|
-
*/ key: "iterations",
|
|
340
|
+
A pass-through for the d3-sankey [iterations](https://github.com/d3/d3-sankey?tab=readme-ov-file#sankey_iterations) function.
|
|
341
|
+
*/ key: "iterations",
|
|
301
342
|
value: function iterations(_) {
|
|
302
343
|
return arguments.length ? (this._iterations = _, this) : this._iterations;
|
|
303
344
|
}
|
|
304
345
|
},
|
|
305
346
|
{
|
|
306
347
|
/**
|
|
307
|
-
|
|
308
|
-
@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:
|
|
348
|
+
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:
|
|
309
349
|
1. A *String* value matching the `id` of the node.
|
|
310
350
|
|
|
311
351
|
The value passed should be an *Array* of data. An optional formatting function can be passed as a second argument to this method. This custom function will be passed the data that has been loaded, as long as there are no errors. This function should return the final links *Array*.
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
*/ key: "links",
|
|
352
|
+
@param f Array of link objects or a URL to load links from.
|
|
353
|
+
*/ key: "links",
|
|
315
354
|
value: function links(_, f) {
|
|
316
355
|
if (arguments.length) {
|
|
317
356
|
addToQueue.bind(this)(_, f, "links");
|
|
@@ -322,68 +361,51 @@ The value passed should be an *Array* of data. An optional formatting function c
|
|
|
322
361
|
},
|
|
323
362
|
{
|
|
324
363
|
/**
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
@param {Function|undefined} [*value* = undefined]
|
|
328
|
-
@chainable
|
|
329
|
-
*/ key: "linkSort",
|
|
364
|
+
A pass-through for the d3-sankey [linkSort](https://github.com/d3/d3-sankey?tab=readme-ov-file#sankey_linkSort) function.
|
|
365
|
+
*/ key: "linkSort",
|
|
330
366
|
value: function linkSort(_) {
|
|
331
367
|
return arguments.length ? (this._linkSort = _, this) : this._linkSort;
|
|
332
368
|
}
|
|
333
369
|
},
|
|
334
370
|
{
|
|
335
371
|
/**
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
@param {String} [*value* = "source"]
|
|
339
|
-
@chainable
|
|
340
|
-
*/ key: "linksSource",
|
|
372
|
+
The key inside of each link Object that references the source node.
|
|
373
|
+
*/ key: "linksSource",
|
|
341
374
|
value: function linksSource(_) {
|
|
342
375
|
return arguments.length ? (this._linksSource = _, this) : this._linksSource;
|
|
343
376
|
}
|
|
344
377
|
},
|
|
345
378
|
{
|
|
346
379
|
/**
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
@param {String} [*value* = "target"]
|
|
350
|
-
@chainable
|
|
351
|
-
*/ key: "linksTarget",
|
|
380
|
+
The key inside of each link Object that references the target node.
|
|
381
|
+
*/ key: "linksTarget",
|
|
352
382
|
value: function linksTarget(_) {
|
|
353
383
|
return arguments.length ? (this._linksTarget = _, this) : this._linksTarget;
|
|
354
384
|
}
|
|
355
385
|
},
|
|
356
386
|
{
|
|
357
387
|
/**
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
@param {Function|String} [*value* = "justify"]
|
|
361
|
-
@chainable
|
|
362
|
-
*/ key: "nodeAlign",
|
|
388
|
+
The nodeAlign property of the sankey layout, which can be "left", "right", "center", or "justify".
|
|
389
|
+
*/ key: "nodeAlign",
|
|
363
390
|
value: function nodeAlign(_) {
|
|
364
391
|
return arguments.length ? (this._nodeAlign = typeof _ === "function" ? _ : sankeyAligns[_], this) : this._nodeAlign;
|
|
365
392
|
}
|
|
366
393
|
},
|
|
367
394
|
{
|
|
368
395
|
/**
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
@param {String} [*value* = "id"]
|
|
372
|
-
@chainable
|
|
373
|
-
*/ key: "nodeId",
|
|
396
|
+
The node id accessor(s).
|
|
397
|
+
*/ key: "nodeId",
|
|
374
398
|
value: function nodeId(_) {
|
|
375
399
|
return arguments.length ? (this._nodeId = typeof _ === "function" ? _ : accessor(_), this) : this._nodeId;
|
|
376
400
|
}
|
|
377
401
|
},
|
|
378
402
|
{
|
|
379
403
|
/**
|
|
380
|
-
|
|
381
|
-
@desc The list of nodes to be used for drawing the network. The value passed must be an *Array* of data.
|
|
404
|
+
The list of nodes to be used for drawing the network. The value passed must be an *Array* of data.
|
|
382
405
|
|
|
383
406
|
Additionally, a custom formatting function can be passed as a second argument to this method. This custom function will be passed the data that has been loaded, as long as there are no errors. This function should return the final node *Array*.
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
*/ key: "nodes",
|
|
407
|
+
@param f Array of node objects or a URL to load nodes from.
|
|
408
|
+
*/ key: "nodes",
|
|
387
409
|
value: function nodes(_, f) {
|
|
388
410
|
if (arguments.length) {
|
|
389
411
|
addToQueue.bind(this)(_, f, "nodes");
|
|
@@ -394,47 +416,37 @@ Additionally, a custom formatting function can be passed as a second argument to
|
|
|
394
416
|
},
|
|
395
417
|
{
|
|
396
418
|
/**
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
@param {Number} [*value* = 8]
|
|
400
|
-
@chainable
|
|
401
|
-
*/ key: "nodePadding",
|
|
419
|
+
Padding of the node. By default, the nodePadding size is 8.
|
|
420
|
+
*/ key: "nodePadding",
|
|
402
421
|
value: function nodePadding(_) {
|
|
403
422
|
return arguments.length ? (this._nodePadding = _, this) : this._nodePadding;
|
|
404
423
|
}
|
|
405
424
|
},
|
|
406
425
|
{
|
|
407
426
|
/**
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
@param {Function|undefined} [*value* = undefined]
|
|
411
|
-
@chainable
|
|
412
|
-
*/ key: "nodeSort",
|
|
427
|
+
A pass-through for the d3-sankey [nodeSort](https://github.com/d3/d3-sankey?tab=readme-ov-file#sankey_nodeSort) function.
|
|
428
|
+
*/ key: "nodeSort",
|
|
413
429
|
value: function nodeSort(_) {
|
|
414
430
|
return arguments.length ? (this._nodeSort = _, this) : this._nodeSort;
|
|
415
431
|
}
|
|
416
432
|
},
|
|
417
433
|
{
|
|
418
434
|
/**
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
@param {Number} [*value* = 30]
|
|
422
|
-
@chainable
|
|
423
|
-
*/ key: "nodeWidth",
|
|
435
|
+
Width of the node. By default, the nodeWidth size is 30.
|
|
436
|
+
*/ key: "nodeWidth",
|
|
424
437
|
value: function nodeWidth(_) {
|
|
425
438
|
return arguments.length ? (this._nodeWidth = _, this) : this._nodeWidth;
|
|
426
439
|
}
|
|
427
440
|
},
|
|
428
441
|
{
|
|
429
442
|
/**
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
@example
|
|
443
|
+
Width of the links.
|
|
444
|
+
|
|
445
|
+
@example
|
|
434
446
|
function value(d) {
|
|
435
447
|
return d.value;
|
|
436
448
|
}
|
|
437
|
-
|
|
449
|
+
*/ key: "value",
|
|
438
450
|
value: function value(_) {
|
|
439
451
|
return arguments.length ? (this._value = typeof _ === "function" ? _ : accessor(_), this) : this._value;
|
|
440
452
|
}
|
|
@@ -443,7 +455,5 @@ function value(d) {
|
|
|
443
455
|
return Sankey;
|
|
444
456
|
}(Viz);
|
|
445
457
|
/**
|
|
446
|
-
|
|
447
|
-
@extends Viz
|
|
448
|
-
@desc Creates a sankey visualization based on a defined set of nodes and links. [Click here](http://d3plus.org/examples/d3plus-network/sankey-diagram/) for help getting started using the Sankey class.
|
|
458
|
+
Creates a sankey visualization based on a defined set of nodes and links. [Click here](http://d3plus.org/examples/d3plus-network/sankey-diagram/) for help getting started using the Sankey class.
|
|
449
459
|
*/ export { Sankey as default };
|
|
@@ -71,9 +71,7 @@ var StackedArea = /*#__PURE__*/ function(AreaPlot) {
|
|
|
71
71
|
return StackedArea;
|
|
72
72
|
}(AreaPlot);
|
|
73
73
|
/**
|
|
74
|
-
|
|
75
|
-
@extends Area
|
|
76
|
-
@desc Creates a stacked area plot based on an array of data.
|
|
74
|
+
Creates a stacked area plot based on an array of data.
|
|
77
75
|
@example <caption>the equivalent of calling:</caption>
|
|
78
76
|
new d3plus.AreaPlot()
|
|
79
77
|
.stacked(true)
|
package/es/src/charts/Tree.js
CHANGED
|
@@ -110,8 +110,8 @@ function _is_native_reflect_construct() {
|
|
|
110
110
|
import { extent, min, max } from "d3-array";
|
|
111
111
|
import { hierarchy, tree } from "d3-hierarchy";
|
|
112
112
|
import { scaleLinear } from "d3-scale";
|
|
113
|
-
import { colorDefaults } from "@d3plus/color";
|
|
114
|
-
import { assign, elem } from "@d3plus/dom";
|
|
113
|
+
import { colorContrast, colorDefaults } from "@d3plus/color";
|
|
114
|
+
import { assign, backgroundColor, elem } from "@d3plus/dom";
|
|
115
115
|
import { merge, nest } from "@d3plus/data";
|
|
116
116
|
import { configPrep, constant } from "../utils/index.js";
|
|
117
117
|
import * as shapes from "../shapes/index.js";
|
|
@@ -134,11 +134,14 @@ var Tree = /*#__PURE__*/ function(Viz) {
|
|
|
134
134
|
_this._previousShapes = [];
|
|
135
135
|
_this._shape = constant("Circle");
|
|
136
136
|
_this._shapeConfig = assign(_this._shapeConfig, {
|
|
137
|
-
ariaLabel: function(d, i) {
|
|
137
|
+
ariaLabel: function ariaLabel(d, i) {
|
|
138
138
|
return _this._treeData ? "".concat(_this._treeData[i].depth, ". ").concat(_this._drawLabel(d, i), ".") : "";
|
|
139
139
|
},
|
|
140
140
|
labelConfig: {
|
|
141
|
-
fontColor:
|
|
141
|
+
fontColor: function fontColor() {
|
|
142
|
+
var bg = _this._select ? backgroundColor(_this._select.node()) : "rgb(255, 255, 255)";
|
|
143
|
+
return colorContrast(bg);
|
|
144
|
+
}
|
|
142
145
|
},
|
|
143
146
|
Path: {
|
|
144
147
|
fill: "none",
|
|
@@ -150,7 +153,7 @@ var Tree = /*#__PURE__*/ function(Viz) {
|
|
|
150
153
|
height: constant(12)
|
|
151
154
|
});
|
|
152
155
|
_this._tooltipConfig = assign(_this._tooltipConfig, {
|
|
153
|
-
title: function(d, i, x) {
|
|
156
|
+
title: function title(d, i, x) {
|
|
154
157
|
return _this._drawLabel(d, i, x.depth - 1);
|
|
155
158
|
}
|
|
156
159
|
});
|
|
@@ -162,7 +165,7 @@ var Tree = /*#__PURE__*/ function(Viz) {
|
|
|
162
165
|
/**
|
|
163
166
|
Extends the draw behavior of the abstract Viz class.
|
|
164
167
|
@private
|
|
165
|
-
|
|
168
|
+
*/ key: "_draw",
|
|
166
169
|
value: function _draw(callback) {
|
|
167
170
|
var _this = this;
|
|
168
171
|
_get(_get_prototype_of(Tree.prototype), "_draw", this).call(this, callback);
|
|
@@ -183,7 +186,7 @@ var Tree = /*#__PURE__*/ function(Viz) {
|
|
|
183
186
|
/**
|
|
184
187
|
Merges the values of a given nest branch.
|
|
185
188
|
@private
|
|
186
|
-
|
|
189
|
+
*/ function flattenBranchData(branch) {
|
|
187
190
|
return merge(branch.values.map(function(l) {
|
|
188
191
|
return l.key && l.values ? flattenBranchData(l) : l;
|
|
189
192
|
}), that._aggs);
|
|
@@ -212,7 +215,8 @@ var Tree = /*#__PURE__*/ function(Viz) {
|
|
|
212
215
|
return d.depth;
|
|
213
216
|
}).map(function(d) {
|
|
214
217
|
return d.values.reduce(function(num, v, i) {
|
|
215
|
-
var
|
|
218
|
+
var vals = d.values;
|
|
219
|
+
var next = i < vals.length - 1 ? vals[i + 1].x : width + _this._margin[left], prev = i ? vals[i - 1].x : _this._margin[left];
|
|
216
220
|
return min([
|
|
217
221
|
num,
|
|
218
222
|
next - v.x,
|
|
@@ -245,34 +249,34 @@ var Tree = /*#__PURE__*/ function(Viz) {
|
|
|
245
249
|
}).map(function(d) {
|
|
246
250
|
return assign({}, d);
|
|
247
251
|
})).select(elem("g.d3plus-Tree-Links", elemObject).node()).config(configPrep.bind(this)(this._shapeConfig, "shape", "Path")).config({
|
|
248
|
-
d: function(d) {
|
|
252
|
+
d: function d(d) {
|
|
249
253
|
var r = _this._shapeConfig.r;
|
|
250
254
|
if (typeof r === "function") r = r(d.data, d.i);
|
|
251
255
|
var px = d.parent.x - d.x + (isVertical ? 0 : r), py = d.parent.y - d.y + (isVertical ? r : 0), x = isVertical ? 0 : -r, y = isVertical ? -r : 0;
|
|
252
256
|
return isVertical ? "M".concat(x, ",").concat(y, "C").concat(x, ",").concat((y + py) / 2, " ").concat(px, ",").concat((y + py) / 2, " ").concat(px, ",").concat(py) : "M".concat(x, ",").concat(y, "C").concat((x + px) / 2, ",").concat(y, " ").concat((x + px) / 2, ",").concat(py, " ").concat(px, ",").concat(py);
|
|
253
257
|
},
|
|
254
|
-
id: function(d, i) {
|
|
258
|
+
id: function id(d, i) {
|
|
255
259
|
return _this._ids(d, i)[d.depth - 1];
|
|
256
260
|
}
|
|
257
261
|
}).render());
|
|
258
262
|
var shapeConfig = {
|
|
259
|
-
id: function(d, i) {
|
|
263
|
+
id: function id(d, i) {
|
|
260
264
|
return _this._ids(d, i)[d.depth - 1];
|
|
261
265
|
},
|
|
262
|
-
label: function(d, i) {
|
|
266
|
+
label: function label(d, i) {
|
|
263
267
|
if (_this._label) return _this._label(d.data, i);
|
|
264
268
|
var ids = _this._ids(d, i).slice(0, d.depth);
|
|
265
269
|
return ids[ids.length - 1];
|
|
266
270
|
},
|
|
267
271
|
labelConfig: {
|
|
268
|
-
textAnchor: function(d, i, x) {
|
|
272
|
+
textAnchor: function textAnchor(d, i, x) {
|
|
269
273
|
return isVertical ? "middle" : x.children && x.depth !== _this._drawDepth + 1 ? "end" : "start";
|
|
270
274
|
},
|
|
271
|
-
verticalAlign: function(d, i, x) {
|
|
275
|
+
verticalAlign: function verticalAlign(d, i, x) {
|
|
272
276
|
return isVertical ? x.depth === 1 ? "bottom" : "top" : "middle";
|
|
273
277
|
}
|
|
274
278
|
},
|
|
275
|
-
hitArea: function(d, i, s) {
|
|
279
|
+
hitArea: function hitArea(d, i, s) {
|
|
276
280
|
var h = _this._labelHeight, offset = s.r ? s.r : isVertical ? s.height / 2 : s.width / 2, w = _this._labelWidths[d.depth - 1];
|
|
277
281
|
return {
|
|
278
282
|
width: isVertical ? w : offset * 2 + w,
|
|
@@ -281,7 +285,7 @@ var Tree = /*#__PURE__*/ function(Viz) {
|
|
|
281
285
|
y: isHorizontal ? -h / 2 : d.children && d.depth !== _this._groupBy.length ? -(offset + _this._labelHeight) : -offset
|
|
282
286
|
};
|
|
283
287
|
},
|
|
284
|
-
labelBounds: function(d, i, s) {
|
|
288
|
+
labelBounds: function labelBounds(d, i, s) {
|
|
285
289
|
var h = _this._labelHeight, height = isVertical ? "height" : "width", offset = s.r ? s.r : isVertical ? s.height / 2 : s.width / 2, w = _this._labelWidths[d.depth - 1], width = isVertical ? "width" : "height", x = isVertical ? "x" : "y", y = isVertical ? "y" : "x";
|
|
286
290
|
var _obj;
|
|
287
291
|
return _obj = {}, _define_property(_obj, width, w), _define_property(_obj, height, h), _define_property(_obj, x, -w / 2), _define_property(_obj, y, d.children && d.depth !== _this._groupBy.length ? -(offset + h) : offset), _obj;
|
|
@@ -311,27 +315,24 @@ var Tree = /*#__PURE__*/ function(Viz) {
|
|
|
311
315
|
},
|
|
312
316
|
{
|
|
313
317
|
/**
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
@param {'vertical'|'horizontal'} [*value* = "vertical"] Accepts either "vertical" or "horizontal".
|
|
317
|
-
*/ key: "orient",
|
|
318
|
+
Changes the orientation of the entire Tree, either "vertical" (top to bottom) or "horizontal" (left to right).
|
|
319
|
+
*/ key: "orient",
|
|
318
320
|
value: function orient(_) {
|
|
319
321
|
return arguments.length ? (this._orient = _, this) : this._orient;
|
|
320
322
|
}
|
|
321
323
|
},
|
|
322
324
|
{
|
|
323
325
|
/**
|
|
324
|
-
|
|
325
|
-
@desc If *value* is specified, sets the separation accessor to the specified function. If *value* is not specified, returns the current separation accessor.
|
|
326
|
+
The separation function between neighboring nodes.
|
|
326
327
|
|
|
327
328
|
From the [d3-hierarchy documentation](https://github.com/d3/d3-hierarchy#tree_separation):
|
|
328
329
|
> The separation accessor is used to separate neighboring nodes. The separation function is passed two nodes a and b, and must return the desired separation. The nodes are typically siblings, though the nodes may be more distantly related if the layout decides to place such nodes adjacent.
|
|
329
|
-
|
|
330
|
-
|
|
330
|
+
|
|
331
|
+
@example
|
|
331
332
|
function separation(a, b) {
|
|
332
333
|
return a.parent === b.parent ? 1 : 2;
|
|
333
334
|
}
|
|
334
|
-
|
|
335
|
+
*/ key: "separation",
|
|
335
336
|
value: function separation(_) {
|
|
336
337
|
return arguments.length ? (this._separation = _, this) : this._separation;
|
|
337
338
|
}
|
|
@@ -340,7 +341,5 @@ function separation(a, b) {
|
|
|
340
341
|
return Tree;
|
|
341
342
|
}(Viz);
|
|
342
343
|
/**
|
|
343
|
-
|
|
344
|
-
@extends Viz
|
|
345
|
-
@desc Uses d3's [tree layout](https://github.com/d3/d3-hierarchy#tree) to create a tidy tree chart based on an array of data.
|
|
344
|
+
Uses d3's [tree layout](https://github.com/d3/d3-hierarchy#tree) to create a tidy tree chart based on an array of data.
|
|
346
345
|
*/ export { Tree as default };
|