@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,482 @@
|
|
|
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_prototype_of(o) {
|
|
31
|
+
_get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
|
|
32
|
+
return o.__proto__ || Object.getPrototypeOf(o);
|
|
33
|
+
};
|
|
34
|
+
return _get_prototype_of(o);
|
|
35
|
+
}
|
|
36
|
+
function _inherits(subClass, superClass) {
|
|
37
|
+
if (typeof superClass !== "function" && superClass !== null) {
|
|
38
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
39
|
+
}
|
|
40
|
+
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
41
|
+
constructor: {
|
|
42
|
+
value: subClass,
|
|
43
|
+
writable: true,
|
|
44
|
+
configurable: true
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
if (superClass) _set_prototype_of(subClass, superClass);
|
|
48
|
+
}
|
|
49
|
+
function _instanceof(left, right) {
|
|
50
|
+
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
|
|
51
|
+
return !!right[Symbol.hasInstance](left);
|
|
52
|
+
} else {
|
|
53
|
+
return left instanceof right;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
function _possible_constructor_return(self, call) {
|
|
57
|
+
if (call && (_type_of(call) === "object" || typeof call === "function")) {
|
|
58
|
+
return call;
|
|
59
|
+
}
|
|
60
|
+
return _assert_this_initialized(self);
|
|
61
|
+
}
|
|
62
|
+
function _set_prototype_of(o, p) {
|
|
63
|
+
_set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
|
|
64
|
+
o.__proto__ = p;
|
|
65
|
+
return o;
|
|
66
|
+
};
|
|
67
|
+
return _set_prototype_of(o, p);
|
|
68
|
+
}
|
|
69
|
+
function _type_of(obj) {
|
|
70
|
+
"@swc/helpers - typeof";
|
|
71
|
+
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
72
|
+
}
|
|
73
|
+
function _is_native_reflect_construct() {
|
|
74
|
+
try {
|
|
75
|
+
var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
|
|
76
|
+
} catch (_) {}
|
|
77
|
+
return (_is_native_reflect_construct = function() {
|
|
78
|
+
return !!result;
|
|
79
|
+
})();
|
|
80
|
+
}
|
|
81
|
+
import { max, min, quantile } from "d3-array";
|
|
82
|
+
import { nest } from "d3-collection";
|
|
83
|
+
import { select } from "d3-selection";
|
|
84
|
+
import { merge } from "@d3plus/data";
|
|
85
|
+
import { assign, elem } from "@d3plus/dom";
|
|
86
|
+
import { accessor, BaseClass, configPrep, constant } from "../utils/index.js";
|
|
87
|
+
import Circle from "./Circle.js";
|
|
88
|
+
import Rect from "./Rect.js";
|
|
89
|
+
import Whisker from "./Whisker.js";
|
|
90
|
+
var shapes = {
|
|
91
|
+
Circle: Circle,
|
|
92
|
+
Rect: Rect
|
|
93
|
+
};
|
|
94
|
+
var Box = /*#__PURE__*/ function(BaseClass) {
|
|
95
|
+
"use strict";
|
|
96
|
+
_inherits(Box, BaseClass);
|
|
97
|
+
function Box() {
|
|
98
|
+
_class_call_check(this, Box);
|
|
99
|
+
var _this;
|
|
100
|
+
_this = _call_super(this, Box);
|
|
101
|
+
_this._medianConfig = {
|
|
102
|
+
fill: constant("black")
|
|
103
|
+
};
|
|
104
|
+
_this._orient = accessor("orient", "vertical");
|
|
105
|
+
_this._outlier = accessor("outlier", "Circle");
|
|
106
|
+
_this._outlierConfig = {
|
|
107
|
+
Circle: {
|
|
108
|
+
r: accessor("r", 5)
|
|
109
|
+
},
|
|
110
|
+
Rect: {
|
|
111
|
+
height: function(d, i) {
|
|
112
|
+
return _this._orient(d, i) === "vertical" ? 5 : 20;
|
|
113
|
+
},
|
|
114
|
+
width: function(d, i) {
|
|
115
|
+
return _this._orient(d, i) === "vertical" ? 20 : 5;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
_this._rectConfig = {
|
|
120
|
+
fill: constant("white"),
|
|
121
|
+
stroke: constant("black"),
|
|
122
|
+
strokeWidth: constant(1)
|
|
123
|
+
};
|
|
124
|
+
_this._rectWidth = constant(50);
|
|
125
|
+
_this._whiskerConfig = {};
|
|
126
|
+
_this._whiskerMode = [
|
|
127
|
+
"tukey",
|
|
128
|
+
"tukey"
|
|
129
|
+
];
|
|
130
|
+
_this._x = accessor("x", 250);
|
|
131
|
+
_this._y = accessor("y", 250);
|
|
132
|
+
return _this;
|
|
133
|
+
}
|
|
134
|
+
_create_class(Box, [
|
|
135
|
+
{
|
|
136
|
+
/**
|
|
137
|
+
@memberof Box
|
|
138
|
+
@desc Draws the Box.
|
|
139
|
+
@param {Function} [*callback*]
|
|
140
|
+
@chainable
|
|
141
|
+
*/ key: "render",
|
|
142
|
+
value: function render() {
|
|
143
|
+
var _this = this;
|
|
144
|
+
if (this._select === void 0) {
|
|
145
|
+
this.select(select("body").append("svg").style("width", "".concat(window.innerWidth, "px")).style("height", "".concat(window.innerHeight, "px")).style("display", "block").node());
|
|
146
|
+
}
|
|
147
|
+
var outlierData = [];
|
|
148
|
+
var filteredData = nest().key(function(d, i) {
|
|
149
|
+
return _this._orient(d, i) === "vertical" ? _this._x(d, i) : _this._y(d, i);
|
|
150
|
+
}).entries(this._data).map(function(d) {
|
|
151
|
+
d.data = merge(d.values);
|
|
152
|
+
d.i = _this._data.indexOf(d.values[0]);
|
|
153
|
+
d.orient = _this._orient(d.data, d.i);
|
|
154
|
+
var values = d.values.map(d.orient === "vertical" ? _this._y : _this._x);
|
|
155
|
+
values.sort(function(a, b) {
|
|
156
|
+
return a - b;
|
|
157
|
+
});
|
|
158
|
+
d.first = quantile(values, 0.25);
|
|
159
|
+
d.median = quantile(values, 0.50);
|
|
160
|
+
d.third = quantile(values, 0.75);
|
|
161
|
+
var mode = _this._whiskerMode;
|
|
162
|
+
if (mode[0] === "tukey") {
|
|
163
|
+
d.lowerLimit = d.first - (d.third - d.first) * 1.5;
|
|
164
|
+
if (d.lowerLimit < min(values)) d.lowerLimit = min(values);
|
|
165
|
+
} else if (mode[0] === "extent") d.lowerLimit = min(values);
|
|
166
|
+
else if (typeof mode[0] === "number") d.lowerLimit = quantile(values, mode[0]);
|
|
167
|
+
if (mode[1] === "tukey") {
|
|
168
|
+
d.upperLimit = d.third + (d.third - d.first) * 1.5;
|
|
169
|
+
if (d.upperLimit > max(values)) d.upperLimit = max(values);
|
|
170
|
+
} else if (mode[1] === "extent") d.upperLimit = max(values);
|
|
171
|
+
else if (typeof mode[1] === "number") d.upperLimit = quantile(values, mode[1]);
|
|
172
|
+
var rectLength = d.third - d.first;
|
|
173
|
+
// Compute values for vertical orientation.
|
|
174
|
+
if (d.orient === "vertical") {
|
|
175
|
+
d.height = rectLength;
|
|
176
|
+
d.width = _this._rectWidth(d.data, d.i);
|
|
177
|
+
d.x = _this._x(d.data, d.i);
|
|
178
|
+
d.y = d.first + rectLength / 2;
|
|
179
|
+
} else if (d.orient === "horizontal") {
|
|
180
|
+
// Compute values for horizontal orientation.
|
|
181
|
+
d.height = _this._rectWidth(d.data, d.i);
|
|
182
|
+
d.width = rectLength;
|
|
183
|
+
d.x = d.first + rectLength / 2;
|
|
184
|
+
d.y = _this._y(d.data, d.i);
|
|
185
|
+
}
|
|
186
|
+
// Compute data for outliers.
|
|
187
|
+
d.values.forEach(function(eachValue, index) {
|
|
188
|
+
var value = d.orient === "vertical" ? _this._y(eachValue, index) : _this._x(eachValue, index);
|
|
189
|
+
if (value < d.lowerLimit || value > d.upperLimit) {
|
|
190
|
+
var dataObj = {};
|
|
191
|
+
dataObj.__d3plus__ = true;
|
|
192
|
+
dataObj.data = eachValue;
|
|
193
|
+
dataObj.i = index;
|
|
194
|
+
dataObj.outlier = _this._outlier(eachValue, index);
|
|
195
|
+
if (d.orient === "vertical") {
|
|
196
|
+
dataObj.x = d.x;
|
|
197
|
+
dataObj.y = value;
|
|
198
|
+
outlierData.push(dataObj);
|
|
199
|
+
} else if (d.orient === "horizontal") {
|
|
200
|
+
dataObj.y = d.y;
|
|
201
|
+
dataObj.x = value;
|
|
202
|
+
outlierData.push(dataObj);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
});
|
|
206
|
+
d.__d3plus__ = true;
|
|
207
|
+
return d;
|
|
208
|
+
});
|
|
209
|
+
// Draw box.
|
|
210
|
+
this._box = new Rect().data(filteredData).x(function(d) {
|
|
211
|
+
return d.x;
|
|
212
|
+
}).y(function(d) {
|
|
213
|
+
return d.y;
|
|
214
|
+
}).select(elem("g.d3plus-Box", {
|
|
215
|
+
parent: this._select
|
|
216
|
+
}).node()).config(configPrep.bind(this)(this._rectConfig, "shape")).render();
|
|
217
|
+
// Draw median.
|
|
218
|
+
this._median = new Rect().data(filteredData).x(function(d) {
|
|
219
|
+
return d.orient === "vertical" ? d.x : d.median;
|
|
220
|
+
}).y(function(d) {
|
|
221
|
+
return d.orient === "vertical" ? d.median : d.y;
|
|
222
|
+
}).height(function(d) {
|
|
223
|
+
return d.orient === "vertical" ? 1 : d.height;
|
|
224
|
+
}).width(function(d) {
|
|
225
|
+
return d.orient === "vertical" ? d.width : 1;
|
|
226
|
+
}).select(elem("g.d3plus-Box-Median", {
|
|
227
|
+
parent: this._select
|
|
228
|
+
}).node()).config(configPrep.bind(this)(this._medianConfig, "shape")).render();
|
|
229
|
+
// Draw 2 lines using Whisker class.
|
|
230
|
+
// Construct coordinates for whisker startpoints and push it to the whiskerData.
|
|
231
|
+
var whiskerData = [];
|
|
232
|
+
filteredData.forEach(function(d, i) {
|
|
233
|
+
var x = d.x;
|
|
234
|
+
var y = d.y;
|
|
235
|
+
var topLength = d.first - d.lowerLimit;
|
|
236
|
+
var bottomLength = d.upperLimit - d.third;
|
|
237
|
+
if (d.orient === "vertical") {
|
|
238
|
+
var topY = y - d.height / 2;
|
|
239
|
+
var bottomY = y + d.height / 2;
|
|
240
|
+
whiskerData.push({
|
|
241
|
+
__d3plus__: true,
|
|
242
|
+
data: d,
|
|
243
|
+
i: i,
|
|
244
|
+
x: x,
|
|
245
|
+
y: topY,
|
|
246
|
+
length: topLength,
|
|
247
|
+
orient: "top"
|
|
248
|
+
}, {
|
|
249
|
+
__d3plus__: true,
|
|
250
|
+
data: d,
|
|
251
|
+
i: i,
|
|
252
|
+
x: x,
|
|
253
|
+
y: bottomY,
|
|
254
|
+
length: bottomLength,
|
|
255
|
+
orient: "bottom"
|
|
256
|
+
});
|
|
257
|
+
} else if (d.orient === "horizontal") {
|
|
258
|
+
var topX = x + d.width / 2;
|
|
259
|
+
var bottomX = x - d.width / 2;
|
|
260
|
+
whiskerData.push({
|
|
261
|
+
__d3plus__: true,
|
|
262
|
+
data: d,
|
|
263
|
+
i: i,
|
|
264
|
+
x: topX,
|
|
265
|
+
y: y,
|
|
266
|
+
length: bottomLength,
|
|
267
|
+
orient: "right"
|
|
268
|
+
}, {
|
|
269
|
+
__d3plus__: true,
|
|
270
|
+
data: d,
|
|
271
|
+
i: i,
|
|
272
|
+
x: bottomX,
|
|
273
|
+
y: y,
|
|
274
|
+
length: topLength,
|
|
275
|
+
orient: "left"
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
});
|
|
279
|
+
// Draw whiskers.
|
|
280
|
+
this._whisker = new Whisker().data(whiskerData).select(elem("g.d3plus-Box-Whisker", {
|
|
281
|
+
parent: this._select
|
|
282
|
+
}).node()).config(configPrep.bind(this)(this._whiskerConfig, "shape")).render();
|
|
283
|
+
// Draw outliers.
|
|
284
|
+
this._whiskerEndpoint = [];
|
|
285
|
+
nest().key(function(d) {
|
|
286
|
+
return d.outlier;
|
|
287
|
+
}).entries(outlierData).forEach(function(shapeData) {
|
|
288
|
+
var shapeName = shapeData.key;
|
|
289
|
+
_this._whiskerEndpoint.push(new shapes[shapeName]().data(shapeData.values).select(elem("g.d3plus-Box-Outlier-".concat(shapeName), {
|
|
290
|
+
parent: _this._select
|
|
291
|
+
}).node()).config(configPrep.bind(_this)(_this._outlierConfig, "shape", shapeName)).render());
|
|
292
|
+
});
|
|
293
|
+
return this;
|
|
294
|
+
}
|
|
295
|
+
},
|
|
296
|
+
{
|
|
297
|
+
/**
|
|
298
|
+
@memberof Box
|
|
299
|
+
@desc Sets the highlight accessor to the Shape class's active function.
|
|
300
|
+
@param {Function} [*value*]
|
|
301
|
+
@chainable
|
|
302
|
+
*/ key: "active",
|
|
303
|
+
value: function active(_) {
|
|
304
|
+
if (this._box) this._box.active(_);
|
|
305
|
+
if (this._median) this._median.active(_);
|
|
306
|
+
if (this._whisker) this._whisker.active(_);
|
|
307
|
+
if (this._whiskerEndpoint) this._whiskerEndpoint.forEach(function(endPoint) {
|
|
308
|
+
return endPoint.active(_);
|
|
309
|
+
});
|
|
310
|
+
}
|
|
311
|
+
},
|
|
312
|
+
{
|
|
313
|
+
/**
|
|
314
|
+
@memberof Box
|
|
315
|
+
@desc If *data* is specified, sets the data array to the specified array and returns the current class instance. If *data* is not specified, returns the current data array.
|
|
316
|
+
@param {Array} [*data* = []]
|
|
317
|
+
@chainable
|
|
318
|
+
*/ key: "data",
|
|
319
|
+
value: function data(_) {
|
|
320
|
+
return arguments.length ? (this._data = _, this) : this._data;
|
|
321
|
+
}
|
|
322
|
+
},
|
|
323
|
+
{
|
|
324
|
+
/**
|
|
325
|
+
@memberof Box
|
|
326
|
+
@desc Sets the highlight accessor to the Shape class's hover function.
|
|
327
|
+
@param {Function} [*value*]
|
|
328
|
+
@chainable
|
|
329
|
+
*/ key: "hover",
|
|
330
|
+
value: function hover(_) {
|
|
331
|
+
if (this._box) this._box.hover(_);
|
|
332
|
+
if (this._median) this._median.hover(_);
|
|
333
|
+
if (this._whisker) this._whisker.hover(_);
|
|
334
|
+
if (this._whiskerEndpoint) this._whiskerEndpoint.forEach(function(endPoint) {
|
|
335
|
+
return endPoint.hover(_);
|
|
336
|
+
});
|
|
337
|
+
}
|
|
338
|
+
},
|
|
339
|
+
{
|
|
340
|
+
/**
|
|
341
|
+
@memberof Box
|
|
342
|
+
@desc If *value* is specified, sets the config method for median and returns the current class instance.
|
|
343
|
+
@param {Object} [*value*]
|
|
344
|
+
@chainable
|
|
345
|
+
*/ key: "medianConfig",
|
|
346
|
+
value: function medianConfig(_) {
|
|
347
|
+
return arguments.length ? (this._medianConfig = assign(this._medianConfig, _), this) : this._medianConfig;
|
|
348
|
+
}
|
|
349
|
+
},
|
|
350
|
+
{
|
|
351
|
+
/**
|
|
352
|
+
@memberof Box
|
|
353
|
+
@desc If *value* is specified, sets the orientation to the specified value. If *value* is not specified, returns the current orientation.
|
|
354
|
+
@param {Function|String} [*value* = "vertical"] Accepts "vertical" or "horizontal"
|
|
355
|
+
@chainable
|
|
356
|
+
*/ key: "orient",
|
|
357
|
+
value: function orient(_) {
|
|
358
|
+
return arguments.length ? (this._orient = typeof _ === "function" ? _ : constant(_), this) : this._orient;
|
|
359
|
+
}
|
|
360
|
+
},
|
|
361
|
+
{
|
|
362
|
+
/**
|
|
363
|
+
@memberof Box
|
|
364
|
+
@desc If *value* is specified, sets the outlier accessor to the specified function or string and returns the current class instance.
|
|
365
|
+
@param {Function|String}
|
|
366
|
+
@chainable
|
|
367
|
+
*/ key: "outlier",
|
|
368
|
+
value: function outlier(_) {
|
|
369
|
+
return arguments.length ? (this._outlier = typeof _ === "function" ? _ : constant(_), this) : this._outlier;
|
|
370
|
+
}
|
|
371
|
+
},
|
|
372
|
+
{
|
|
373
|
+
/**
|
|
374
|
+
@memberof Box
|
|
375
|
+
@desc If *value* is specified, sets the config method for each outlier point and returns the current class instance.
|
|
376
|
+
@param {Object} [*value*]
|
|
377
|
+
@chainable
|
|
378
|
+
*/ key: "outlierConfig",
|
|
379
|
+
value: function outlierConfig(_) {
|
|
380
|
+
return arguments.length ? (this._outlierConfig = assign(this._outlierConfig, _), this) : this._outlierConfig;
|
|
381
|
+
}
|
|
382
|
+
},
|
|
383
|
+
{
|
|
384
|
+
/**
|
|
385
|
+
@memberof Box
|
|
386
|
+
@desc If *value* is specified, sets the config method for rect shape and returns the current class instance.
|
|
387
|
+
@param {Object} [*value*]
|
|
388
|
+
@chainable
|
|
389
|
+
*/ key: "rectConfig",
|
|
390
|
+
value: function rectConfig(_) {
|
|
391
|
+
return arguments.length ? (this._rectConfig = assign(this._rectConfig, _), this) : this._rectConfig;
|
|
392
|
+
}
|
|
393
|
+
},
|
|
394
|
+
{
|
|
395
|
+
/**
|
|
396
|
+
@memberof Box
|
|
397
|
+
@desc If *value* is specified, sets the width accessor to the specified function or number and returns the current class instance.
|
|
398
|
+
@param {Function|Number} [*value*]
|
|
399
|
+
@chainable
|
|
400
|
+
@example
|
|
401
|
+
function(d) {
|
|
402
|
+
return d.width;
|
|
403
|
+
}
|
|
404
|
+
*/ key: "rectWidth",
|
|
405
|
+
value: function rectWidth(_) {
|
|
406
|
+
return arguments.length ? (this._rectWidth = typeof _ === "function" ? _ : constant(_), this) : this._rectWidth;
|
|
407
|
+
}
|
|
408
|
+
},
|
|
409
|
+
{
|
|
410
|
+
/**
|
|
411
|
+
@memberof Box
|
|
412
|
+
@desc If *selector* is specified, sets the SVG container element to the specified d3 selector or DOM element and returns the current class instance. If *selector* is not specified, returns the current SVG container element.
|
|
413
|
+
@param {String|HTMLElement} [*selector* = d3.select("body").append("svg")]
|
|
414
|
+
@chainable
|
|
415
|
+
*/ key: "select",
|
|
416
|
+
value: function select1(_) {
|
|
417
|
+
return arguments.length ? (this._select = select(_), this) : this._select;
|
|
418
|
+
}
|
|
419
|
+
},
|
|
420
|
+
{
|
|
421
|
+
/**
|
|
422
|
+
@memberof Box
|
|
423
|
+
@desc If *value* is specified, sets the config method for whisker and returns the current class instance.
|
|
424
|
+
@param {Object} [*value*]
|
|
425
|
+
@chainable
|
|
426
|
+
*/ key: "whiskerConfig",
|
|
427
|
+
value: function whiskerConfig(_) {
|
|
428
|
+
return arguments.length ? (this._whiskerConfig = assign(this._whiskerConfig, _), this) : this._whiskerConfig;
|
|
429
|
+
}
|
|
430
|
+
},
|
|
431
|
+
{
|
|
432
|
+
/**
|
|
433
|
+
@memberof Box
|
|
434
|
+
@desc Determines the value used for each whisker. Can be passed a single value to apply for both whiskers, or an Array of 2 values for the lower and upper whiskers (in that order). Accepted values are `"tukey"`, `"extent"`, or a Number representing a quantile.
|
|
435
|
+
@param {String|Number|String[]|Number[]} [*value* = "tukey"]
|
|
436
|
+
@chainable
|
|
437
|
+
*/ key: "whiskerMode",
|
|
438
|
+
value: function whiskerMode(_) {
|
|
439
|
+
return arguments.length ? (this._whiskerMode = _instanceof(_, Array) ? _ : [
|
|
440
|
+
_,
|
|
441
|
+
_
|
|
442
|
+
], this) : this._whiskerMode;
|
|
443
|
+
}
|
|
444
|
+
},
|
|
445
|
+
{
|
|
446
|
+
/**
|
|
447
|
+
@memberof Box
|
|
448
|
+
@desc If *value* is specified, sets the x axis to the specified function or number and returns the current class instance.
|
|
449
|
+
@param {Function|Number} [*value*]
|
|
450
|
+
@chainable
|
|
451
|
+
@example
|
|
452
|
+
function(d) {
|
|
453
|
+
return d.x;
|
|
454
|
+
}
|
|
455
|
+
*/ key: "x",
|
|
456
|
+
value: function x(_) {
|
|
457
|
+
return arguments.length ? (this._x = typeof _ === "function" ? _ : accessor(_), this) : this._x;
|
|
458
|
+
}
|
|
459
|
+
},
|
|
460
|
+
{
|
|
461
|
+
/**
|
|
462
|
+
@memberof Box
|
|
463
|
+
@desc If *value* is specified, sets the y axis to the specified function or number and returns the current class instance.
|
|
464
|
+
@param {Function|Number} [*value*]
|
|
465
|
+
@chainable
|
|
466
|
+
@example
|
|
467
|
+
function(d) {
|
|
468
|
+
return d.y;
|
|
469
|
+
}
|
|
470
|
+
*/ key: "y",
|
|
471
|
+
value: function y(_) {
|
|
472
|
+
return arguments.length ? (this._y = typeof _ === "function" ? _ : accessor(_), this) : this._y;
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
]);
|
|
476
|
+
return Box;
|
|
477
|
+
}(BaseClass);
|
|
478
|
+
/**
|
|
479
|
+
@class Box
|
|
480
|
+
@extends BaseClass
|
|
481
|
+
@desc Creates SVG box based on an array of data.
|
|
482
|
+
*/ export { Box as default };
|
|
@@ -0,0 +1,201 @@
|
|
|
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 { assign } from "@d3plus/dom";
|
|
98
|
+
import { accessor, constant } from "../utils/index.js";
|
|
99
|
+
import Shape from "./Shape.js";
|
|
100
|
+
var Circle = /*#__PURE__*/ function(Shape) {
|
|
101
|
+
"use strict";
|
|
102
|
+
_inherits(Circle, Shape);
|
|
103
|
+
function Circle() {
|
|
104
|
+
_class_call_check(this, Circle);
|
|
105
|
+
var _this;
|
|
106
|
+
_this = _call_super(this, Circle, [
|
|
107
|
+
"circle"
|
|
108
|
+
]);
|
|
109
|
+
_this._labelBounds = function(d, i, s) {
|
|
110
|
+
return {
|
|
111
|
+
width: s.r * 1.5,
|
|
112
|
+
height: s.r * 1.5,
|
|
113
|
+
x: -s.r * 0.75,
|
|
114
|
+
y: -s.r * 0.75
|
|
115
|
+
};
|
|
116
|
+
};
|
|
117
|
+
_this._labelConfig = assign(_this._labelConfig, {
|
|
118
|
+
textAnchor: "middle",
|
|
119
|
+
verticalAlign: "middle"
|
|
120
|
+
});
|
|
121
|
+
_this._name = "Circle";
|
|
122
|
+
_this._r = accessor("r");
|
|
123
|
+
return _this;
|
|
124
|
+
}
|
|
125
|
+
_create_class(Circle, [
|
|
126
|
+
{
|
|
127
|
+
/**
|
|
128
|
+
@memberof Circle
|
|
129
|
+
@desc Provides the default positioning to the <rect> elements.
|
|
130
|
+
@private
|
|
131
|
+
*/ key: "_applyPosition",
|
|
132
|
+
value: function _applyPosition(elem) {
|
|
133
|
+
var _this = this;
|
|
134
|
+
elem.attr("r", function(d, i) {
|
|
135
|
+
return _this._r(d, i);
|
|
136
|
+
}).attr("x", function(d, i) {
|
|
137
|
+
return -_this._r(d, i) / 2;
|
|
138
|
+
}).attr("y", function(d, i) {
|
|
139
|
+
return -_this._r(d, i) / 2;
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
/**
|
|
145
|
+
@memberof Circle
|
|
146
|
+
@desc Draws the circles.
|
|
147
|
+
@param {Function} [*callback*]
|
|
148
|
+
@chainable
|
|
149
|
+
*/ key: "render",
|
|
150
|
+
value: function render(callback) {
|
|
151
|
+
_get(_get_prototype_of(Circle.prototype), "render", this).call(this, callback);
|
|
152
|
+
var enter = this._enter.call(this._applyStyle.bind(this));
|
|
153
|
+
var update = this._update;
|
|
154
|
+
if (this._duration) {
|
|
155
|
+
enter.attr("r", 0).attr("x", 0).attr("y", 0).transition(this._transition).call(this._applyPosition.bind(this));
|
|
156
|
+
update = update.transition(this._transition);
|
|
157
|
+
this._exit.transition(this._transition).attr("r", 0).attr("x", 0).attr("y", 0);
|
|
158
|
+
} else {
|
|
159
|
+
enter.call(this._applyPosition.bind(this));
|
|
160
|
+
}
|
|
161
|
+
update.call(this._applyStyle.bind(this)).call(this._applyPosition.bind(this));
|
|
162
|
+
return this;
|
|
163
|
+
}
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
/**
|
|
167
|
+
@memberof Circle
|
|
168
|
+
@desc Given a specific data point and index, returns the aesthetic properties of the shape.
|
|
169
|
+
@param {Object} *data point*
|
|
170
|
+
@param {Number} *index*
|
|
171
|
+
@private
|
|
172
|
+
*/ key: "_aes",
|
|
173
|
+
value: function _aes(d, i) {
|
|
174
|
+
return {
|
|
175
|
+
r: this._r(d, i)
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
/**
|
|
181
|
+
@memberof Circle
|
|
182
|
+
@desc If *value* is specified, sets the radius accessor to the specified function or number and returns the current class instance.
|
|
183
|
+
@param {Function|Number} [*value*]
|
|
184
|
+
@chainable
|
|
185
|
+
@example
|
|
186
|
+
function(d) {
|
|
187
|
+
return d.r;
|
|
188
|
+
}
|
|
189
|
+
*/ key: "r",
|
|
190
|
+
value: function r(_) {
|
|
191
|
+
return arguments.length ? (this._r = typeof _ === "function" ? _ : constant(_), this) : this._r;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
]);
|
|
195
|
+
return Circle;
|
|
196
|
+
}(Shape);
|
|
197
|
+
/**
|
|
198
|
+
@class Circle
|
|
199
|
+
@extends Shape
|
|
200
|
+
@desc Creates SVG circles based on an array of data.
|
|
201
|
+
*/ export { Circle as default };
|