@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.
Files changed (87) hide show
  1. package/README.md +6219 -0
  2. package/es/index.js +4 -0
  3. package/es/src/charts/AreaPlot.js +86 -0
  4. package/es/src/charts/BarChart.js +93 -0
  5. package/es/src/charts/BoxWhisker.js +97 -0
  6. package/es/src/charts/BumpChart.js +148 -0
  7. package/es/src/charts/Donut.js +84 -0
  8. package/es/src/charts/Geomap.js +833 -0
  9. package/es/src/charts/LinePlot.js +84 -0
  10. package/es/src/charts/Matrix.js +358 -0
  11. package/es/src/charts/Network.js +787 -0
  12. package/es/src/charts/Pack.js +318 -0
  13. package/es/src/charts/Pie.js +242 -0
  14. package/es/src/charts/Plot.js +2212 -0
  15. package/es/src/charts/Priestley.js +312 -0
  16. package/es/src/charts/Radar.js +365 -0
  17. package/es/src/charts/RadialMatrix.js +393 -0
  18. package/es/src/charts/Rings.js +777 -0
  19. package/es/src/charts/Sankey.js +413 -0
  20. package/es/src/charts/StackedArea.js +80 -0
  21. package/es/src/charts/Tree.js +312 -0
  22. package/es/src/charts/Treemap.js +406 -0
  23. package/es/src/charts/Viz.js +2017 -0
  24. package/es/src/charts/drawSteps/drawAttribution.js +14 -0
  25. package/es/src/charts/drawSteps/drawBack.js +23 -0
  26. package/es/src/charts/drawSteps/drawColorScale.js +69 -0
  27. package/es/src/charts/drawSteps/drawLegend.js +120 -0
  28. package/es/src/charts/drawSteps/drawSubtitle.js +31 -0
  29. package/es/src/charts/drawSteps/drawTimeline.js +80 -0
  30. package/es/src/charts/drawSteps/drawTitle.js +31 -0
  31. package/es/src/charts/drawSteps/drawTotal.js +32 -0
  32. package/es/src/charts/drawSteps/zoomControls.js +254 -0
  33. package/es/src/charts/events/click.legend.js +76 -0
  34. package/es/src/charts/events/click.shape.js +26 -0
  35. package/es/src/charts/events/mouseenter.js +31 -0
  36. package/es/src/charts/events/mouseleave.js +21 -0
  37. package/es/src/charts/events/mousemove.legend.js +64 -0
  38. package/es/src/charts/events/mousemove.shape.js +42 -0
  39. package/es/src/charts/events/touchstart.body.js +7 -0
  40. package/es/src/charts/helpers/matrixData.js +104 -0
  41. package/es/src/charts/helpers/tileAttributions.js +34 -0
  42. package/es/src/charts/index.js +21 -0
  43. package/es/src/charts/plotBuffers/Bar.js +65 -0
  44. package/es/src/charts/plotBuffers/Box.js +60 -0
  45. package/es/src/charts/plotBuffers/Circle.js +39 -0
  46. package/es/src/charts/plotBuffers/Line.js +30 -0
  47. package/es/src/charts/plotBuffers/Rect.js +40 -0
  48. package/es/src/charts/plotBuffers/discreteBuffer.js +24 -0
  49. package/es/src/charts/plotBuffers/numericBuffer.js +111 -0
  50. package/es/src/components/Axis.js +1567 -0
  51. package/es/src/components/AxisBottom.js +77 -0
  52. package/es/src/components/AxisLeft.js +77 -0
  53. package/es/src/components/AxisRight.js +77 -0
  54. package/es/src/components/AxisTop.js +77 -0
  55. package/es/src/components/ColorScale.js +958 -0
  56. package/es/src/components/Legend.js +673 -0
  57. package/es/src/components/Message.js +95 -0
  58. package/es/src/components/TextBox.js +752 -0
  59. package/es/src/components/Timeline.js +760 -0
  60. package/es/src/components/Tooltip.js +726 -0
  61. package/es/src/components/index.js +11 -0
  62. package/es/src/shapes/Area.js +361 -0
  63. package/es/src/shapes/Bar.js +342 -0
  64. package/es/src/shapes/Box.js +482 -0
  65. package/es/src/shapes/Circle.js +201 -0
  66. package/es/src/shapes/Image.js +255 -0
  67. package/es/src/shapes/Line.js +289 -0
  68. package/es/src/shapes/Path.js +186 -0
  69. package/es/src/shapes/Rect.js +215 -0
  70. package/es/src/shapes/Shape.js +1156 -0
  71. package/es/src/shapes/Whisker.js +330 -0
  72. package/es/src/shapes/index.js +10 -0
  73. package/es/src/utils/BaseClass.js +204 -0
  74. package/es/src/utils/RESET.js +4 -0
  75. package/es/src/utils/accessor.js +19 -0
  76. package/es/src/utils/configPrep.js +76 -0
  77. package/es/src/utils/constant.js +15 -0
  78. package/es/src/utils/getProp.js +9 -0
  79. package/es/src/utils/index.js +7 -0
  80. package/es/src/utils/uuid.js +13 -0
  81. package/package.json +68 -0
  82. package/umd/d3plus-core.full.js +56459 -0
  83. package/umd/d3plus-core.full.js.map +1 -0
  84. package/umd/d3plus-core.full.min.js +7241 -0
  85. package/umd/d3plus-core.js +14422 -0
  86. package/umd/d3plus-core.js.map +1 -0
  87. package/umd/d3plus-core.min.js +4564 -0
@@ -0,0 +1,11 @@
1
+ export { default as Axis } from "./Axis.js";
2
+ export { default as AxisBottom } from "./AxisBottom.js";
3
+ export { default as AxisLeft } from "./AxisLeft.js";
4
+ export { default as AxisRight } from "./AxisRight.js";
5
+ export { default as AxisTop } from "./AxisTop.js";
6
+ export { default as ColorScale } from "./ColorScale.js";
7
+ export { default as Legend } from "./Legend.js";
8
+ export { default as Message } from "./Message.js";
9
+ export { default as TextBox } from "./TextBox.js";
10
+ export { default as Timeline } from "./Timeline.js";
11
+ export { default as Tooltip } from "./Tooltip.js";
@@ -0,0 +1,361 @@
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 { extent } from "d3-array";
98
+ import { nest } from "d3-collection";
99
+ import { interpolatePath } from "d3-interpolate-path";
100
+ import { select } from "d3-selection";
101
+ import * as paths from "d3-shape";
102
+ import { merge } from "@d3plus/data";
103
+ import { largestRect } from "@d3plus/math";
104
+ import { accessor, constant } from "../utils/index.js";
105
+ import Shape from "./Shape.js";
106
+ var Area = /*#__PURE__*/ function(Shape) {
107
+ "use strict";
108
+ _inherits(Area, Shape);
109
+ function Area() {
110
+ _class_call_check(this, Area);
111
+ var _this;
112
+ _this = _call_super(this, Area);
113
+ _this._curve = constant("linear");
114
+ _this._defined = function() {
115
+ return true;
116
+ };
117
+ _this._labelBounds = function(d, i, aes) {
118
+ var r = largestRect(aes.points);
119
+ if (!r) return null;
120
+ return {
121
+ angle: r.angle,
122
+ width: r.width,
123
+ height: r.height,
124
+ x: r.cx - r.width / 2 - _this._x(d, i),
125
+ y: r.cy - r.height / 2 - _this._y(d, i)
126
+ };
127
+ };
128
+ _this._labelConfig = Object.assign(_this._labelConfig, {
129
+ textAnchor: "middle",
130
+ verticalAlign: "middle"
131
+ });
132
+ _this._name = "Area";
133
+ _this._x = accessor("x");
134
+ _this._x0 = accessor("x");
135
+ _this._x1 = null;
136
+ _this._y = constant(0);
137
+ _this._y0 = constant(0);
138
+ _this._y1 = accessor("y");
139
+ return _this;
140
+ }
141
+ _create_class(Area, [
142
+ {
143
+ /**
144
+ @memberof Area
145
+ @desc Given a specific data point and index, returns the aesthetic properties of the shape.
146
+ @param {Object} *data point*
147
+ @param {Number} *index*
148
+ @private
149
+ */ key: "_aes",
150
+ value: function _aes(d) {
151
+ var _this = this;
152
+ var values = d.values.slice().sort(function(a, b) {
153
+ return _this._y1 ? _this._x(a) - _this._x(b) : _this._y(a) - _this._y(b);
154
+ });
155
+ var points1 = values.map(function(v, z) {
156
+ return [
157
+ _this._x0(v, z),
158
+ _this._y0(v, z)
159
+ ];
160
+ });
161
+ var points2 = values.reverse().map(function(v, z) {
162
+ return _this._y1 ? [
163
+ _this._x(v, z),
164
+ _this._y1(v, z)
165
+ ] : [
166
+ _this._x1(v, z),
167
+ _this._y(v, z)
168
+ ];
169
+ });
170
+ var points = points1.concat(points2);
171
+ if (points1[0][1] > points2[0][1]) points = points.reverse();
172
+ points.push(points[0]);
173
+ return {
174
+ points: points
175
+ };
176
+ }
177
+ },
178
+ {
179
+ /**
180
+ @memberof Area
181
+ @desc Filters/manipulates the data array before binding each point to an SVG group.
182
+ @param {Array} [*data* = the data array to be filtered]
183
+ @private
184
+ */ key: "_dataFilter",
185
+ value: function _dataFilter(data) {
186
+ var _this = this;
187
+ var areas = nest().key(this._id).entries(data).map(function(d) {
188
+ d.data = merge(d.values);
189
+ d.i = data.indexOf(d.values[0]);
190
+ var x = extent(d.values.map(_this._x).concat(d.values.map(_this._x0)).concat(_this._x1 ? d.values.map(_this._x1) : []));
191
+ d.xR = x;
192
+ d.width = x[1] - x[0];
193
+ d.x = x[0] + d.width / 2;
194
+ var y = extent(d.values.map(_this._y).concat(d.values.map(_this._y0)).concat(_this._y1 ? d.values.map(_this._y1) : []));
195
+ d.yR = y;
196
+ d.height = y[1] - y[0];
197
+ d.y = y[0] + d.height / 2;
198
+ d.nested = true;
199
+ d.translate = [
200
+ d.x,
201
+ d.y
202
+ ];
203
+ d.__d3plusShape__ = true;
204
+ return d;
205
+ });
206
+ areas.key = function(d) {
207
+ return d.key;
208
+ };
209
+ return areas;
210
+ }
211
+ },
212
+ {
213
+ /**
214
+ @memberof Area
215
+ @desc Draws the area polygons.
216
+ @param {Function} [*callback*]
217
+ @chainable
218
+ */ key: "render",
219
+ value: function render(callback) {
220
+ var _this = this;
221
+ _get(_get_prototype_of(Area.prototype), "render", this).call(this, callback);
222
+ var userCurve = this._curve.bind(this)(this.config());
223
+ var curve = paths["curve".concat(userCurve.charAt(0).toUpperCase()).concat(userCurve.slice(1))];
224
+ var path = this._path = paths.area().defined(this._defined).curve(curve).x(this._x).x0(this._x0).x1(this._x1).y(this._y).y0(this._y0).y1(this._y1);
225
+ var exitPath = paths.area().defined(function(d) {
226
+ return d;
227
+ }).curve(curve).x(this._x).y(this._y).x0(function(d, i) {
228
+ return _this._x1 ? _this._x0(d, i) + (_this._x1(d, i) - _this._x0(d, i)) / 2 : _this._x0(d, i);
229
+ }).x1(function(d, i) {
230
+ return _this._x1 ? _this._x0(d, i) + (_this._x1(d, i) - _this._x0(d, i)) / 2 : _this._x0(d, i);
231
+ }).y0(function(d, i) {
232
+ return _this._y1 ? _this._y0(d, i) + (_this._y1(d, i) - _this._y0(d, i)) / 2 : _this._y0(d, i);
233
+ }).y1(function(d, i) {
234
+ return _this._y1 ? _this._y0(d, i) + (_this._y1(d, i) - _this._y0(d, i)) / 2 : _this._y0(d, i);
235
+ });
236
+ this._enter.append("path").attr("transform", function(d) {
237
+ return "translate(".concat(-d.xR[0] - d.width / 2, ", ").concat(-d.yR[0] - d.height / 2, ")");
238
+ }).attr("d", function(d) {
239
+ return exitPath(d.values);
240
+ }).call(this._applyStyle.bind(this)).transition(this._transition).attrTween("d", function(d) {
241
+ return interpolatePath(select(this).attr("d"), path(d.values));
242
+ });
243
+ this._update.select("path").transition(this._transition).attr("transform", function(d) {
244
+ return "translate(".concat(-d.xR[0] - d.width / 2, ", ").concat(-d.yR[0] - d.height / 2, ")");
245
+ }).attrTween("d", function(d) {
246
+ return interpolatePath(select(this).attr("d"), path(d.values));
247
+ }).call(this._applyStyle.bind(this));
248
+ this._exit.select("path").transition(this._transition).attrTween("d", function(d) {
249
+ return interpolatePath(select(this).attr("d"), exitPath(d.values));
250
+ });
251
+ return this;
252
+ }
253
+ },
254
+ {
255
+ /**
256
+ @memberof Area
257
+ @desc If *value* is specified, sets the area curve to the specified string and returns the current class instance. If *value* is not specified, returns the current area curve.
258
+ @param {Function|String} [*value* = "linear"]
259
+ @chainable
260
+ */ key: "curve",
261
+ value: function curve(_) {
262
+ return arguments.length ? (this._curve = typeof _ === "function" ? _ : constant(_), this) : this._curve;
263
+ }
264
+ },
265
+ {
266
+ /**
267
+ @memberof Area
268
+ @desc If *value* is specified, sets the defined accessor to the specified function and returns the current class instance. If *value* is not specified, returns the current defined accessor.
269
+ @param {Function} [*value*]
270
+ @chainable
271
+ */ key: "defined",
272
+ value: function defined(_) {
273
+ return arguments.length ? (this._defined = _, this) : this._defined;
274
+ }
275
+ },
276
+ {
277
+ /**
278
+ @memberof Area
279
+ @desc If *value* is specified, sets the x accessor to the specified function or number and returns the current class instance. If *value* is not specified, returns the current x accessor.
280
+ @param {Function|Number} [*value*]
281
+ @chainable
282
+ */ key: "x",
283
+ value: function x(_) {
284
+ if (!arguments.length) return this._x;
285
+ this._x = typeof _ === "function" ? _ : constant(_);
286
+ this._x0 = this._x;
287
+ return this;
288
+ }
289
+ },
290
+ {
291
+ /**
292
+ @memberof Area
293
+ @desc If *value* is specified, sets the x0 accessor to the specified function or number and returns the current class instance. If *value* is not specified, returns the current x0 accessor.
294
+ @param {Function|Number} [*value*]
295
+ @chainable
296
+ */ key: "x0",
297
+ value: function x0(_) {
298
+ if (!arguments.length) return this._x0;
299
+ this._x0 = typeof _ === "function" ? _ : constant(_);
300
+ this._x = this._x0;
301
+ return this;
302
+ }
303
+ },
304
+ {
305
+ /**
306
+ @memberof Area
307
+ @desc If *value* is specified, sets the x1 accessor to the specified function or number and returns the current class instance. If *value* is not specified, returns the current x1 accessor.
308
+ @param {Function|Number|null} [*value*]
309
+ @chainable
310
+ */ key: "x1",
311
+ value: function x1(_) {
312
+ return arguments.length ? (this._x1 = typeof _ === "function" || _ === null ? _ : constant(_), this) : this._x1;
313
+ }
314
+ },
315
+ {
316
+ /**
317
+ @memberof Area
318
+ @desc If *value* is specified, sets the y accessor to the specified function or number and returns the current class instance. If *value* is not specified, returns the current y accessor.
319
+ @param {Function|Number} [*value*]
320
+ @chainable
321
+ */ key: "y",
322
+ value: function y(_) {
323
+ if (!arguments.length) return this._y;
324
+ this._y = typeof _ === "function" ? _ : constant(_);
325
+ this._y0 = this._y;
326
+ return this;
327
+ }
328
+ },
329
+ {
330
+ /**
331
+ @memberof Area
332
+ @desc If *value* is specified, sets the y0 accessor to the specified function or number and returns the current class instance. If *value* is not specified, returns the current y0 accessor.
333
+ @param {Function|Number} [*value*]
334
+ @chainable
335
+ */ key: "y0",
336
+ value: function y0(_) {
337
+ if (!arguments.length) return this._y0;
338
+ this._y0 = typeof _ === "function" ? _ : constant(_);
339
+ this._y = this._y0;
340
+ return this;
341
+ }
342
+ },
343
+ {
344
+ /**
345
+ @memberof Area
346
+ @desc If *value* is specified, sets the y1 accessor to the specified function or number and returns the current class instance. If *value* is not specified, returns the current y1 accessor.
347
+ @param {Function|Number|null} [*value*]
348
+ @chainable
349
+ */ key: "y1",
350
+ value: function y1(_) {
351
+ return arguments.length ? (this._y1 = typeof _ === "function" || _ === null ? _ : constant(_), this) : this._y1;
352
+ }
353
+ }
354
+ ]);
355
+ return Area;
356
+ }(Shape);
357
+ /**
358
+ @class Area
359
+ @extends Shape
360
+ @desc Creates SVG areas based on an array of data.
361
+ */ export { Area as default };