@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,342 @@
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 { accessor, constant } from "../utils/index.js";
98
+ import Shape from "./Shape.js";
99
+ var Bar = /*#__PURE__*/ function(Shape) {
100
+ "use strict";
101
+ _inherits(Bar, Shape);
102
+ function Bar() {
103
+ _class_call_check(this, Bar);
104
+ var _this;
105
+ _this = _call_super(this, Bar, [
106
+ "rect"
107
+ ]);
108
+ _this._name = "Bar";
109
+ _this._height = constant(10);
110
+ _this._labelBounds = function(d, i, s) {
111
+ return {
112
+ width: s.width,
113
+ height: s.height,
114
+ x: _this._x1 !== null ? _this._getX(d, i) : -s.width / 2,
115
+ y: _this._x1 === null ? _this._getY(d, i) : -s.height / 2
116
+ };
117
+ };
118
+ _this._width = constant(10);
119
+ _this._x = accessor("x");
120
+ _this._x0 = accessor("x");
121
+ _this._x1 = null;
122
+ _this._y = constant(0);
123
+ _this._y0 = constant(0);
124
+ _this._y1 = accessor("y");
125
+ return _this;
126
+ }
127
+ _create_class(Bar, [
128
+ {
129
+ /**
130
+ @memberof Bar
131
+ @desc Draws the bars.
132
+ @param {Function} [*callback*]
133
+ @chainable
134
+ */ key: "render",
135
+ value: function render(callback) {
136
+ var _this = this;
137
+ _get(_get_prototype_of(Bar.prototype), "render", this).call(this, callback);
138
+ var enter = this._enter.attr("width", function(d, i) {
139
+ return _this._x1 === null ? _this._getWidth(d, i) : 0;
140
+ }).attr("height", function(d, i) {
141
+ return _this._x1 !== null ? _this._getHeight(d, i) : 0;
142
+ }).attr("x", function(d, i) {
143
+ return _this._x1 === null ? -_this._getWidth(d, i) / 2 : 0;
144
+ }).attr("y", function(d, i) {
145
+ return _this._x1 !== null ? -_this._getHeight(d, i) / 2 : 0;
146
+ }).call(this._applyStyle.bind(this));
147
+ var update = this._update;
148
+ if (this._duration) {
149
+ enter = enter.transition(this._transition);
150
+ update = update.transition(this._transition);
151
+ this._exit.transition(this._transition).attr("width", function(d, i) {
152
+ return _this._x1 === null ? _this._getWidth(d, i) : 0;
153
+ }).attr("height", function(d, i) {
154
+ return _this._x1 !== null ? _this._getHeight(d, i) : 0;
155
+ }).attr("x", function(d, i) {
156
+ return _this._x1 === null ? -_this._getWidth(d, i) / 2 : 0;
157
+ }).attr("y", function(d, i) {
158
+ return _this._x1 !== null ? -_this._getHeight(d, i) / 2 : 0;
159
+ });
160
+ }
161
+ enter.call(this._applyPosition.bind(this));
162
+ update.call(this._applyStyle.bind(this)).call(this._applyPosition.bind(this));
163
+ return this;
164
+ }
165
+ },
166
+ {
167
+ /**
168
+ @memberof Bar
169
+ @desc Given a specific data point and index, returns the aesthetic properties of the shape.
170
+ @param {Object} *data point*
171
+ @param {Number} *index*
172
+ @private
173
+ */ key: "_aes",
174
+ value: function _aes(d, i) {
175
+ return {
176
+ height: this._getHeight(d, i),
177
+ width: this._getWidth(d, i)
178
+ };
179
+ }
180
+ },
181
+ {
182
+ /**
183
+ @memberof Bar
184
+ @desc Provides the default positioning to the <rect> elements.
185
+ @param {D3Selection} *elem*
186
+ @private
187
+ */ key: "_applyPosition",
188
+ value: function _applyPosition(elem) {
189
+ var _this = this;
190
+ elem.attr("width", function(d, i) {
191
+ return _this._getWidth(d, i);
192
+ }).attr("height", function(d, i) {
193
+ return _this._getHeight(d, i);
194
+ }).attr("x", function(d, i) {
195
+ return _this._x1 !== null ? _this._getX(d, i) : -_this._getWidth(d, i) / 2;
196
+ }).attr("y", function(d, i) {
197
+ return _this._x1 === null ? _this._getY(d, i) : -_this._getHeight(d, i) / 2;
198
+ });
199
+ }
200
+ },
201
+ {
202
+ /**
203
+ @memberof Bar
204
+ @desc Calculates the height of the <rect> by assessing the x and y properties.
205
+ @param {Object} *d*
206
+ @param {Number} *i*
207
+ @private
208
+ */ key: "_getHeight",
209
+ value: function _getHeight(d, i) {
210
+ if (this._x1 !== null) return this._height(d, i);
211
+ return Math.abs(this._y1(d, i) - this._y(d, i));
212
+ }
213
+ },
214
+ {
215
+ /**
216
+ @memberof Bar
217
+ @desc Calculates the width of the <rect> by assessing the x and y properties.
218
+ @param {Object} *d*
219
+ @param {Number} *i*
220
+ @private
221
+ */ key: "_getWidth",
222
+ value: function _getWidth(d, i) {
223
+ if (this._x1 === null) return this._width(d, i);
224
+ return Math.abs(this._x1(d, i) - this._x(d, i));
225
+ }
226
+ },
227
+ {
228
+ /**
229
+ @memberof Bar
230
+ @desc Calculates the x of the <rect> by assessing the x and width properties.
231
+ @param {Object} *d*
232
+ @param {Number} *i*
233
+ @private
234
+ */ key: "_getX",
235
+ value: function _getX(d, i) {
236
+ var w = this._x1 === null ? this._x(d, i) : this._x1(d, i) - this._x(d, i);
237
+ if (w < 0) return w;
238
+ else return 0;
239
+ }
240
+ },
241
+ {
242
+ /**
243
+ @memberof Bar
244
+ @desc Calculates the y of the <rect> by assessing the y and height properties.
245
+ @param {Object} *d*
246
+ @param {Number} *i*
247
+ @private
248
+ */ key: "_getY",
249
+ value: function _getY(d, i) {
250
+ var h = this._x1 !== null ? this._y(d, i) : this._y1(d, i) - this._y(d, i);
251
+ if (h < 0) return h;
252
+ else return 0;
253
+ }
254
+ },
255
+ {
256
+ /**
257
+ @memberof Bar
258
+ @desc If *value* is specified, sets the height accessor to the specified function or number and returns the current class instance.
259
+ @param {Function|Number} [*value*]
260
+ @chainable
261
+ @example
262
+ function(d) {
263
+ return d.height;
264
+ }
265
+ */ key: "height",
266
+ value: function height(_) {
267
+ return arguments.length ? (this._height = typeof _ === "function" ? _ : constant(_), this) : this._height;
268
+ }
269
+ },
270
+ {
271
+ /**
272
+ @memberof Bar
273
+ @desc If *value* is specified, sets the width accessor to the specified function or number and returns the current class instance.
274
+ @param {Function|Number} [*value*]
275
+ @chainable
276
+ @example
277
+ function(d) {
278
+ return d.width;
279
+ }
280
+ */ key: "width",
281
+ value: function width(_) {
282
+ return arguments.length ? (this._width = typeof _ === "function" ? _ : constant(_), this) : this._width;
283
+ }
284
+ },
285
+ {
286
+ /**
287
+ @memberof Bar
288
+ @desc If *value* is specified, sets the x0 accessor to the specified function or number and returns the current class instance.
289
+ @param {Function|Number} [*value*]
290
+ @chainable
291
+ */ key: "x0",
292
+ value: function x0(_) {
293
+ if (!arguments.length) return this._x0;
294
+ this._x0 = typeof _ === "function" ? _ : constant(_);
295
+ this._x = this._x0;
296
+ return this;
297
+ }
298
+ },
299
+ {
300
+ /**
301
+ @memberof Bar
302
+ @desc If *value* is specified, sets the x1 accessor to the specified function or number and returns the current class instance.
303
+ @param {Function|Number|null} [*value*]
304
+ @chainable
305
+ */ key: "x1",
306
+ value: function x1(_) {
307
+ return arguments.length ? (this._x1 = typeof _ === "function" || _ === null ? _ : constant(_), this) : this._x1;
308
+ }
309
+ },
310
+ {
311
+ /**
312
+ @memberof Bar
313
+ @desc If *value* is specified, sets the y0 accessor to the specified function or number and returns the current class instance.
314
+ @param {Function|Number} [*value*]
315
+ @chainable
316
+ */ key: "y0",
317
+ value: function y0(_) {
318
+ if (!arguments.length) return this._y0;
319
+ this._y0 = typeof _ === "function" ? _ : constant(_);
320
+ this._y = this._y0;
321
+ return this;
322
+ }
323
+ },
324
+ {
325
+ /**
326
+ @memberof Bar
327
+ @desc If *value* is specified, sets the y1 accessor to the specified function or number and returns the current class instance.
328
+ @param {Function|Number|null} [*value*]
329
+ @chainable
330
+ */ key: "y1",
331
+ value: function y1(_) {
332
+ return arguments.length ? (this._y1 = typeof _ === "function" || _ === null ? _ : constant(_), this) : this._y1;
333
+ }
334
+ }
335
+ ]);
336
+ return Bar;
337
+ }(Shape);
338
+ /**
339
+ @class Bar
340
+ @extends Shape
341
+ @desc Creates SVG areas based on an array of data.
342
+ */ export { Bar as default };