@d3plus/core 3.0.0-alpha.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/README.md +6219 -0
- package/es/index.js +4 -0
- package/es/src/charts/AreaPlot.js +86 -0
- package/es/src/charts/BarChart.js +93 -0
- package/es/src/charts/BoxWhisker.js +97 -0
- package/es/src/charts/BumpChart.js +148 -0
- package/es/src/charts/Donut.js +84 -0
- package/es/src/charts/Geomap.js +833 -0
- package/es/src/charts/LinePlot.js +84 -0
- package/es/src/charts/Matrix.js +358 -0
- package/es/src/charts/Network.js +787 -0
- package/es/src/charts/Pack.js +318 -0
- package/es/src/charts/Pie.js +242 -0
- package/es/src/charts/Plot.js +2212 -0
- package/es/src/charts/Priestley.js +312 -0
- package/es/src/charts/Radar.js +365 -0
- package/es/src/charts/RadialMatrix.js +393 -0
- package/es/src/charts/Rings.js +777 -0
- package/es/src/charts/Sankey.js +413 -0
- package/es/src/charts/StackedArea.js +80 -0
- package/es/src/charts/Tree.js +312 -0
- package/es/src/charts/Treemap.js +406 -0
- package/es/src/charts/Viz.js +2017 -0
- package/es/src/charts/drawSteps/drawAttribution.js +14 -0
- package/es/src/charts/drawSteps/drawBack.js +23 -0
- package/es/src/charts/drawSteps/drawColorScale.js +69 -0
- package/es/src/charts/drawSteps/drawLegend.js +120 -0
- package/es/src/charts/drawSteps/drawSubtitle.js +31 -0
- package/es/src/charts/drawSteps/drawTimeline.js +80 -0
- package/es/src/charts/drawSteps/drawTitle.js +31 -0
- package/es/src/charts/drawSteps/drawTotal.js +32 -0
- package/es/src/charts/drawSteps/zoomControls.js +254 -0
- package/es/src/charts/events/click.legend.js +76 -0
- package/es/src/charts/events/click.shape.js +26 -0
- package/es/src/charts/events/mouseenter.js +31 -0
- package/es/src/charts/events/mouseleave.js +21 -0
- package/es/src/charts/events/mousemove.legend.js +64 -0
- package/es/src/charts/events/mousemove.shape.js +42 -0
- package/es/src/charts/events/touchstart.body.js +7 -0
- package/es/src/charts/helpers/matrixData.js +104 -0
- package/es/src/charts/helpers/tileAttributions.js +34 -0
- package/es/src/charts/index.js +21 -0
- package/es/src/charts/plotBuffers/Bar.js +65 -0
- package/es/src/charts/plotBuffers/Box.js +60 -0
- package/es/src/charts/plotBuffers/Circle.js +39 -0
- package/es/src/charts/plotBuffers/Line.js +30 -0
- package/es/src/charts/plotBuffers/Rect.js +40 -0
- package/es/src/charts/plotBuffers/discreteBuffer.js +24 -0
- package/es/src/charts/plotBuffers/numericBuffer.js +111 -0
- package/es/src/components/Axis.js +1567 -0
- package/es/src/components/AxisBottom.js +77 -0
- package/es/src/components/AxisLeft.js +77 -0
- package/es/src/components/AxisRight.js +77 -0
- package/es/src/components/AxisTop.js +77 -0
- package/es/src/components/ColorScale.js +958 -0
- package/es/src/components/Legend.js +673 -0
- package/es/src/components/Message.js +95 -0
- package/es/src/components/TextBox.js +752 -0
- package/es/src/components/Timeline.js +760 -0
- package/es/src/components/Tooltip.js +726 -0
- package/es/src/components/index.js +11 -0
- package/es/src/shapes/Area.js +361 -0
- package/es/src/shapes/Bar.js +342 -0
- package/es/src/shapes/Box.js +482 -0
- package/es/src/shapes/Circle.js +201 -0
- package/es/src/shapes/Image.js +255 -0
- package/es/src/shapes/Line.js +289 -0
- package/es/src/shapes/Path.js +186 -0
- package/es/src/shapes/Rect.js +215 -0
- package/es/src/shapes/Shape.js +1156 -0
- package/es/src/shapes/Whisker.js +330 -0
- package/es/src/shapes/index.js +10 -0
- package/es/src/utils/BaseClass.js +204 -0
- package/es/src/utils/RESET.js +4 -0
- package/es/src/utils/accessor.js +19 -0
- package/es/src/utils/configPrep.js +76 -0
- package/es/src/utils/constant.js +15 -0
- package/es/src/utils/getProp.js +9 -0
- package/es/src/utils/index.js +7 -0
- package/es/src/utils/uuid.js +13 -0
- package/package.json +68 -0
- package/umd/d3plus-core.full.js +56459 -0
- package/umd/d3plus-core.full.js.map +1 -0
- package/umd/d3plus-core.full.min.js +7241 -0
- package/umd/d3plus-core.js +14422 -0
- package/umd/d3plus-core.js.map +1 -0
- package/umd/d3plus-core.min.js +4564 -0
|
@@ -0,0 +1,413 @@
|
|
|
1
|
+
function _assert_this_initialized(self) {
|
|
2
|
+
if (self === void 0) {
|
|
3
|
+
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
4
|
+
}
|
|
5
|
+
return self;
|
|
6
|
+
}
|
|
7
|
+
function _call_super(_this, derived, args) {
|
|
8
|
+
derived = _get_prototype_of(derived);
|
|
9
|
+
return _possible_constructor_return(_this, _is_native_reflect_construct() ? Reflect.construct(derived, args || [], _get_prototype_of(_this).constructor) : derived.apply(_this, args));
|
|
10
|
+
}
|
|
11
|
+
function _class_call_check(instance, Constructor) {
|
|
12
|
+
if (!(instance instanceof Constructor)) {
|
|
13
|
+
throw new TypeError("Cannot call a class as a function");
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
function _defineProperties(target, props) {
|
|
17
|
+
for(var i = 0; i < props.length; i++){
|
|
18
|
+
var descriptor = props[i];
|
|
19
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
20
|
+
descriptor.configurable = true;
|
|
21
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
22
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
function _create_class(Constructor, protoProps, staticProps) {
|
|
26
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
27
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
28
|
+
return Constructor;
|
|
29
|
+
}
|
|
30
|
+
function _get(target, property, receiver) {
|
|
31
|
+
if (typeof Reflect !== "undefined" && Reflect.get) {
|
|
32
|
+
_get = Reflect.get;
|
|
33
|
+
} else {
|
|
34
|
+
_get = function get(target, property, receiver) {
|
|
35
|
+
var base = _super_prop_base(target, property);
|
|
36
|
+
if (!base) return;
|
|
37
|
+
var desc = Object.getOwnPropertyDescriptor(base, property);
|
|
38
|
+
if (desc.get) {
|
|
39
|
+
return desc.get.call(receiver || target);
|
|
40
|
+
}
|
|
41
|
+
return desc.value;
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
return _get(target, property, receiver || target);
|
|
45
|
+
}
|
|
46
|
+
function _get_prototype_of(o) {
|
|
47
|
+
_get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
|
|
48
|
+
return o.__proto__ || Object.getPrototypeOf(o);
|
|
49
|
+
};
|
|
50
|
+
return _get_prototype_of(o);
|
|
51
|
+
}
|
|
52
|
+
function _inherits(subClass, superClass) {
|
|
53
|
+
if (typeof superClass !== "function" && superClass !== null) {
|
|
54
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
55
|
+
}
|
|
56
|
+
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
57
|
+
constructor: {
|
|
58
|
+
value: subClass,
|
|
59
|
+
writable: true,
|
|
60
|
+
configurable: true
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
if (superClass) _set_prototype_of(subClass, superClass);
|
|
64
|
+
}
|
|
65
|
+
function _possible_constructor_return(self, call) {
|
|
66
|
+
if (call && (_type_of(call) === "object" || typeof call === "function")) {
|
|
67
|
+
return call;
|
|
68
|
+
}
|
|
69
|
+
return _assert_this_initialized(self);
|
|
70
|
+
}
|
|
71
|
+
function _set_prototype_of(o, p) {
|
|
72
|
+
_set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
|
|
73
|
+
o.__proto__ = p;
|
|
74
|
+
return o;
|
|
75
|
+
};
|
|
76
|
+
return _set_prototype_of(o, p);
|
|
77
|
+
}
|
|
78
|
+
function _super_prop_base(object, property) {
|
|
79
|
+
while(!Object.prototype.hasOwnProperty.call(object, property)){
|
|
80
|
+
object = _get_prototype_of(object);
|
|
81
|
+
if (object === null) break;
|
|
82
|
+
}
|
|
83
|
+
return object;
|
|
84
|
+
}
|
|
85
|
+
function _type_of(obj) {
|
|
86
|
+
"@swc/helpers - typeof";
|
|
87
|
+
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
88
|
+
}
|
|
89
|
+
function _is_native_reflect_construct() {
|
|
90
|
+
try {
|
|
91
|
+
var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
|
|
92
|
+
} catch (_) {}
|
|
93
|
+
return (_is_native_reflect_construct = function() {
|
|
94
|
+
return !!result;
|
|
95
|
+
})();
|
|
96
|
+
}
|
|
97
|
+
import { nest } from "d3-collection";
|
|
98
|
+
import { sankey, sankeyCenter, sankeyJustify, sankeyLeft, sankeyLinkHorizontal, sankeyRight } from "d3-sankey";
|
|
99
|
+
var sankeyAligns = {
|
|
100
|
+
center: sankeyCenter,
|
|
101
|
+
justify: sankeyJustify,
|
|
102
|
+
left: sankeyLeft,
|
|
103
|
+
right: sankeyRight
|
|
104
|
+
};
|
|
105
|
+
import { addToQueue } from "@d3plus/data";
|
|
106
|
+
import { assign, elem } from "@d3plus/dom";
|
|
107
|
+
import { accessor, configPrep, constant } from "../utils/index.js";
|
|
108
|
+
import { Path } from "../shapes/index.js";
|
|
109
|
+
import * as shapes from "../shapes/index.js";
|
|
110
|
+
import Viz from "./Viz";
|
|
111
|
+
var Sankey = /*#__PURE__*/ function(Viz) {
|
|
112
|
+
"use strict";
|
|
113
|
+
_inherits(Sankey, Viz);
|
|
114
|
+
function Sankey() {
|
|
115
|
+
_class_call_check(this, Sankey);
|
|
116
|
+
var _this;
|
|
117
|
+
_this = _call_super(this, Sankey);
|
|
118
|
+
_this._nodeId = accessor("id");
|
|
119
|
+
_this._links = accessor("links");
|
|
120
|
+
_this._linksSource = "source";
|
|
121
|
+
_this._linksTarget = "target";
|
|
122
|
+
_this._noDataMessage = false;
|
|
123
|
+
_this._nodes = accessor("nodes");
|
|
124
|
+
_this._nodeAlign = sankeyAligns.justify;
|
|
125
|
+
_this._nodePadding = 8;
|
|
126
|
+
_this._nodeWidth = 30;
|
|
127
|
+
_this._on.mouseenter = function() {};
|
|
128
|
+
_this._on["mouseleave.shape"] = function() {
|
|
129
|
+
_this.hover(false);
|
|
130
|
+
};
|
|
131
|
+
var defaultMouseMove = _this._on["mousemove.shape"];
|
|
132
|
+
_this._on["mousemove.shape"] = function(d, i, x, event) {
|
|
133
|
+
defaultMouseMove(d, i, x, event);
|
|
134
|
+
if (_this._focus && _this._focus === d.id) {
|
|
135
|
+
_this.hover(false);
|
|
136
|
+
_this._on.mouseenter.bind(_this)(d, i, x, event);
|
|
137
|
+
_this._focus = undefined;
|
|
138
|
+
} else {
|
|
139
|
+
var id = _this._nodeId(d, i), node = _this._nodeLookup[id], nodeLookup = Object.keys(_this._nodeLookup).reduce(function(all, item) {
|
|
140
|
+
all[_this._nodeLookup[item]] = !isNaN(item) ? parseInt(item, 10) : item;
|
|
141
|
+
return all;
|
|
142
|
+
}, {});
|
|
143
|
+
var links = _this._linkLookup[node];
|
|
144
|
+
var filterIds = [
|
|
145
|
+
id
|
|
146
|
+
];
|
|
147
|
+
links.forEach(function(l) {
|
|
148
|
+
filterIds.push(nodeLookup[l]);
|
|
149
|
+
});
|
|
150
|
+
_this.hover(function(h, x) {
|
|
151
|
+
if (h.source && h.target) {
|
|
152
|
+
return h.source.id === id || h.target.id === id;
|
|
153
|
+
} else {
|
|
154
|
+
return filterIds.includes(_this._nodeId(h, x));
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
_this._path = sankeyLinkHorizontal();
|
|
160
|
+
_this._sankey = sankey();
|
|
161
|
+
_this._shape = constant("Rect");
|
|
162
|
+
_this._shapeConfig = assign(_this._shapeConfig, {
|
|
163
|
+
Path: {
|
|
164
|
+
fill: "none",
|
|
165
|
+
hoverStyle: {
|
|
166
|
+
"stroke-width": function(d) {
|
|
167
|
+
return Math.max(1, Math.abs(d.source.y1 - d.source.y0) * (d.value / d.source.value) - 2);
|
|
168
|
+
}
|
|
169
|
+
},
|
|
170
|
+
label: false,
|
|
171
|
+
stroke: "#DBDBDB",
|
|
172
|
+
strokeOpacity: 0.5,
|
|
173
|
+
strokeWidth: function(d) {
|
|
174
|
+
return Math.max(1, Math.abs(d.source.y1 - d.source.y0) * (d.value / d.source.value) - 2);
|
|
175
|
+
}
|
|
176
|
+
},
|
|
177
|
+
Rect: {}
|
|
178
|
+
});
|
|
179
|
+
_this._value = constant(1);
|
|
180
|
+
return _this;
|
|
181
|
+
}
|
|
182
|
+
_create_class(Sankey, [
|
|
183
|
+
{
|
|
184
|
+
/**
|
|
185
|
+
Extends the draw behavior of the abstract Viz class.
|
|
186
|
+
@private
|
|
187
|
+
*/ key: "_draw",
|
|
188
|
+
value: function _draw(callback) {
|
|
189
|
+
var _this = this;
|
|
190
|
+
_get(_get_prototype_of(Sankey.prototype), "_draw", this).call(this, callback);
|
|
191
|
+
var height = this._height - this._margin.top - this._margin.bottom, width = this._width - this._margin.left - this._margin.right;
|
|
192
|
+
var _nodes = Array.isArray(this._nodes) ? this._nodes : this._links.reduce(function(all, d) {
|
|
193
|
+
if (!all.includes(d[_this._linksSource])) all.push(d[_this._linksSource]);
|
|
194
|
+
if (!all.includes(d[_this._linksTarget])) all.push(d[_this._linksTarget]);
|
|
195
|
+
return all;
|
|
196
|
+
}, []).map(function(id) {
|
|
197
|
+
return {
|
|
198
|
+
id: id
|
|
199
|
+
};
|
|
200
|
+
});
|
|
201
|
+
var nodes = _nodes.map(function(n, i) {
|
|
202
|
+
return {
|
|
203
|
+
__d3plus__: true,
|
|
204
|
+
data: n,
|
|
205
|
+
i: i,
|
|
206
|
+
id: _this._nodeId(n, i),
|
|
207
|
+
node: n,
|
|
208
|
+
shape: "Rect"
|
|
209
|
+
};
|
|
210
|
+
});
|
|
211
|
+
var nodeLookup = this._nodeLookup = nodes.reduce(function(obj, d, i) {
|
|
212
|
+
obj[d.id] = i;
|
|
213
|
+
return obj;
|
|
214
|
+
}, {});
|
|
215
|
+
var links = this._links.map(function(link, i) {
|
|
216
|
+
var check = [
|
|
217
|
+
_this._linksSource,
|
|
218
|
+
_this._linksTarget
|
|
219
|
+
];
|
|
220
|
+
var linkLookup = check.reduce(function(result, item) {
|
|
221
|
+
result[item] = nodeLookup[link[item]];
|
|
222
|
+
return result;
|
|
223
|
+
}, {});
|
|
224
|
+
return {
|
|
225
|
+
source: linkLookup[_this._linksSource],
|
|
226
|
+
target: linkLookup[_this._linksTarget],
|
|
227
|
+
value: _this._value(link, i)
|
|
228
|
+
};
|
|
229
|
+
});
|
|
230
|
+
this._linkLookup = links.reduce(function(obj, d) {
|
|
231
|
+
if (!obj[d.source]) obj[d.source] = [];
|
|
232
|
+
obj[d.source].push(d.target);
|
|
233
|
+
if (!obj[d.target]) obj[d.target] = [];
|
|
234
|
+
obj[d.target].push(d.source);
|
|
235
|
+
return obj;
|
|
236
|
+
}, {});
|
|
237
|
+
var transform = "translate(".concat(this._margin.left, ", ").concat(this._margin.top, ")");
|
|
238
|
+
this._sankey.nodeAlign(this._nodeAlign).nodePadding(this._nodePadding).nodeWidth(this._nodeWidth).nodes(nodes).links(links).size([
|
|
239
|
+
width,
|
|
240
|
+
height
|
|
241
|
+
])();
|
|
242
|
+
this._shapes.push(new Path().config(this._shapeConfig.Path).data(links).d(this._path).select(elem("g.d3plus-Links", {
|
|
243
|
+
parent: this._select,
|
|
244
|
+
enter: {
|
|
245
|
+
transform: transform
|
|
246
|
+
},
|
|
247
|
+
update: {
|
|
248
|
+
transform: transform
|
|
249
|
+
}
|
|
250
|
+
}).node()).render());
|
|
251
|
+
nest().key(function(d) {
|
|
252
|
+
return d.shape;
|
|
253
|
+
}).entries(nodes).forEach(function(d) {
|
|
254
|
+
_this._shapes.push(new shapes[d.key]().data(d.values).height(function(d) {
|
|
255
|
+
return d.y1 - d.y0;
|
|
256
|
+
}).width(function(d) {
|
|
257
|
+
return d.x1 - d.x0;
|
|
258
|
+
}).x(function(d) {
|
|
259
|
+
return (d.x1 + d.x0) / 2;
|
|
260
|
+
}).y(function(d) {
|
|
261
|
+
return (d.y1 + d.y0) / 2;
|
|
262
|
+
}).select(elem("g.d3plus-sankey-nodes", {
|
|
263
|
+
parent: _this._select,
|
|
264
|
+
enter: {
|
|
265
|
+
transform: transform
|
|
266
|
+
},
|
|
267
|
+
update: {
|
|
268
|
+
transform: transform
|
|
269
|
+
}
|
|
270
|
+
}).node()).config(configPrep.bind(_this)(_this._shapeConfig, "shape", d.key)).render());
|
|
271
|
+
});
|
|
272
|
+
return this;
|
|
273
|
+
}
|
|
274
|
+
},
|
|
275
|
+
{
|
|
276
|
+
/**
|
|
277
|
+
@memberof Sankey
|
|
278
|
+
@desc If *value* is specified, sets the hover method to the specified function and returns the current class instance.
|
|
279
|
+
@param {Function} [*value*]
|
|
280
|
+
@chainable
|
|
281
|
+
*/ key: "hover",
|
|
282
|
+
value: function hover(_) {
|
|
283
|
+
this._hover = _;
|
|
284
|
+
this._shapes.forEach(function(s) {
|
|
285
|
+
return s.hover(_);
|
|
286
|
+
});
|
|
287
|
+
if (this._legend) this._legendClass.hover(_);
|
|
288
|
+
return this;
|
|
289
|
+
}
|
|
290
|
+
},
|
|
291
|
+
{
|
|
292
|
+
/**
|
|
293
|
+
@memberof Sankey
|
|
294
|
+
@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:
|
|
295
|
+
1. A *String* value matching the `id` of the node.
|
|
296
|
+
|
|
297
|
+
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*.
|
|
298
|
+
@param {Array} *links* = []
|
|
299
|
+
@chainable
|
|
300
|
+
*/ key: "links",
|
|
301
|
+
value: function links(_, f) {
|
|
302
|
+
if (arguments.length) {
|
|
303
|
+
addToQueue.bind(this)(_, f, "links");
|
|
304
|
+
return this;
|
|
305
|
+
}
|
|
306
|
+
return this._links;
|
|
307
|
+
}
|
|
308
|
+
},
|
|
309
|
+
{
|
|
310
|
+
/**
|
|
311
|
+
@memberof Sankey
|
|
312
|
+
@desc The key inside of each link Object that references the source node.
|
|
313
|
+
@param {String} [*value* = "source"]
|
|
314
|
+
@chainable
|
|
315
|
+
*/ key: "linksSource",
|
|
316
|
+
value: function linksSource(_) {
|
|
317
|
+
return arguments.length ? (this._linksSource = _, this) : this._linksSource;
|
|
318
|
+
}
|
|
319
|
+
},
|
|
320
|
+
{
|
|
321
|
+
/**
|
|
322
|
+
@memberof Sankey
|
|
323
|
+
@desc The key inside of each link Object that references the target node.
|
|
324
|
+
@param {String} [*value* = "target"]
|
|
325
|
+
@chainable
|
|
326
|
+
*/ key: "linksTarget",
|
|
327
|
+
value: function linksTarget(_) {
|
|
328
|
+
return arguments.length ? (this._linksTarget = _, this) : this._linksTarget;
|
|
329
|
+
}
|
|
330
|
+
},
|
|
331
|
+
{
|
|
332
|
+
/**
|
|
333
|
+
@memberof Sankey
|
|
334
|
+
@desc Sets the nodeAlign property of the sankey layout, which can either be "left", "right", "center", or "justify".
|
|
335
|
+
@param {Function|String} [*value* = "justify"]
|
|
336
|
+
@chainable
|
|
337
|
+
*/ key: "nodeAlign",
|
|
338
|
+
value: function nodeAlign(_) {
|
|
339
|
+
return arguments.length ? (this._nodeAlign = typeof _ === "function" ? _ : sankeyAligns[_], this) : this._nodeAlign;
|
|
340
|
+
}
|
|
341
|
+
},
|
|
342
|
+
{
|
|
343
|
+
/**
|
|
344
|
+
@memberof Sankey
|
|
345
|
+
@desc If *value* is specified, sets the node id accessor(s) to the specified array of values and returns the current class instance. If *value* is not specified, returns the current node group accessor.
|
|
346
|
+
@param {String} [*value* = "id"]
|
|
347
|
+
@chainable
|
|
348
|
+
*/ key: "nodeId",
|
|
349
|
+
value: function nodeId(_) {
|
|
350
|
+
return arguments.length ? (this._nodeId = typeof _ === "function" ? _ : accessor(_), this) : this._nodeId;
|
|
351
|
+
}
|
|
352
|
+
},
|
|
353
|
+
{
|
|
354
|
+
/**
|
|
355
|
+
@memberof Sankey
|
|
356
|
+
@desc The list of nodes to be used for drawing the network. The value passed must be an *Array* of data.
|
|
357
|
+
|
|
358
|
+
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*.
|
|
359
|
+
@param {Array} *nodes* = []
|
|
360
|
+
@chainable
|
|
361
|
+
*/ key: "nodes",
|
|
362
|
+
value: function nodes(_, f) {
|
|
363
|
+
if (arguments.length) {
|
|
364
|
+
addToQueue.bind(this)(_, f, "nodes");
|
|
365
|
+
return this;
|
|
366
|
+
}
|
|
367
|
+
return this._nodes;
|
|
368
|
+
}
|
|
369
|
+
},
|
|
370
|
+
{
|
|
371
|
+
/**
|
|
372
|
+
@memberof Sankey
|
|
373
|
+
@desc If *value* is specified, sets the padding of the node and returns the current class instance. If *value* is not specified, returns the current nodePadding. By default, the nodePadding size is 8.
|
|
374
|
+
@param {Number} [*value* = 8]
|
|
375
|
+
@chainable
|
|
376
|
+
*/ key: "nodePadding",
|
|
377
|
+
value: function nodePadding(_) {
|
|
378
|
+
return arguments.length ? (this._nodePadding = _, this) : this._nodePadding;
|
|
379
|
+
}
|
|
380
|
+
},
|
|
381
|
+
{
|
|
382
|
+
/**
|
|
383
|
+
@memberof Sankey
|
|
384
|
+
@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.
|
|
385
|
+
@param {Number} [*value* = 30]
|
|
386
|
+
@chainable
|
|
387
|
+
*/ key: "nodeWidth",
|
|
388
|
+
value: function nodeWidth(_) {
|
|
389
|
+
return arguments.length ? (this._nodeWidth = _, this) : this._nodeWidth;
|
|
390
|
+
}
|
|
391
|
+
},
|
|
392
|
+
{
|
|
393
|
+
/**
|
|
394
|
+
@memberof Sankey
|
|
395
|
+
@desc If *value* is specified, sets the width of the links and returns the current class instance. If *value* is not specified, returns the current value accessor.
|
|
396
|
+
@param {Function|Number} *value*
|
|
397
|
+
@example
|
|
398
|
+
function value(d) {
|
|
399
|
+
return d.value;
|
|
400
|
+
}
|
|
401
|
+
*/ key: "value",
|
|
402
|
+
value: function value(_) {
|
|
403
|
+
return arguments.length ? (this._value = typeof _ === "function" ? _ : accessor(_), this) : this._value;
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
]);
|
|
407
|
+
return Sankey;
|
|
408
|
+
}(Viz);
|
|
409
|
+
/**
|
|
410
|
+
@class Sankey
|
|
411
|
+
@extends Viz
|
|
412
|
+
@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.
|
|
413
|
+
*/ export { Sankey as default };
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
function _assert_this_initialized(self) {
|
|
2
|
+
if (self === void 0) {
|
|
3
|
+
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
4
|
+
}
|
|
5
|
+
return self;
|
|
6
|
+
}
|
|
7
|
+
function _call_super(_this, derived, args) {
|
|
8
|
+
derived = _get_prototype_of(derived);
|
|
9
|
+
return _possible_constructor_return(_this, _is_native_reflect_construct() ? Reflect.construct(derived, args || [], _get_prototype_of(_this).constructor) : derived.apply(_this, args));
|
|
10
|
+
}
|
|
11
|
+
function _class_call_check(instance, Constructor) {
|
|
12
|
+
if (!(instance instanceof Constructor)) {
|
|
13
|
+
throw new TypeError("Cannot call a class as a function");
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
function _get_prototype_of(o) {
|
|
17
|
+
_get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
|
|
18
|
+
return o.__proto__ || Object.getPrototypeOf(o);
|
|
19
|
+
};
|
|
20
|
+
return _get_prototype_of(o);
|
|
21
|
+
}
|
|
22
|
+
function _inherits(subClass, superClass) {
|
|
23
|
+
if (typeof superClass !== "function" && superClass !== null) {
|
|
24
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
25
|
+
}
|
|
26
|
+
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
27
|
+
constructor: {
|
|
28
|
+
value: subClass,
|
|
29
|
+
writable: true,
|
|
30
|
+
configurable: true
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
if (superClass) _set_prototype_of(subClass, superClass);
|
|
34
|
+
}
|
|
35
|
+
function _possible_constructor_return(self, call) {
|
|
36
|
+
if (call && (_type_of(call) === "object" || typeof call === "function")) {
|
|
37
|
+
return call;
|
|
38
|
+
}
|
|
39
|
+
return _assert_this_initialized(self);
|
|
40
|
+
}
|
|
41
|
+
function _set_prototype_of(o, p) {
|
|
42
|
+
_set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
|
|
43
|
+
o.__proto__ = p;
|
|
44
|
+
return o;
|
|
45
|
+
};
|
|
46
|
+
return _set_prototype_of(o, p);
|
|
47
|
+
}
|
|
48
|
+
function _type_of(obj) {
|
|
49
|
+
"@swc/helpers - typeof";
|
|
50
|
+
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
51
|
+
}
|
|
52
|
+
function _is_native_reflect_construct() {
|
|
53
|
+
try {
|
|
54
|
+
var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
|
|
55
|
+
} catch (_) {}
|
|
56
|
+
return (_is_native_reflect_construct = function() {
|
|
57
|
+
return !!result;
|
|
58
|
+
})();
|
|
59
|
+
}
|
|
60
|
+
import { default as AreaPlot } from "./AreaPlot.js";
|
|
61
|
+
var StackedArea = /*#__PURE__*/ function(AreaPlot) {
|
|
62
|
+
"use strict";
|
|
63
|
+
_inherits(StackedArea, AreaPlot);
|
|
64
|
+
function StackedArea() {
|
|
65
|
+
_class_call_check(this, StackedArea);
|
|
66
|
+
var _this;
|
|
67
|
+
_this = _call_super(this, StackedArea);
|
|
68
|
+
_this._stacked = true;
|
|
69
|
+
return _this;
|
|
70
|
+
}
|
|
71
|
+
return StackedArea;
|
|
72
|
+
}(AreaPlot);
|
|
73
|
+
/**
|
|
74
|
+
@class StackedArea
|
|
75
|
+
@extends Area
|
|
76
|
+
@desc Creates a stacked area plot based on an array of data.
|
|
77
|
+
@example <caption>the equivalent of calling:</caption>
|
|
78
|
+
new d3plus.AreaPlot()
|
|
79
|
+
.stacked(true)
|
|
80
|
+
*/ export { StackedArea as default };
|