@d3plus/core 3.0.16 → 3.1.1

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 (167) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +88485 -2998
  3. package/es/index.js +1 -1
  4. package/es/src/charts/AreaPlot.js +1 -3
  5. package/es/src/charts/BarChart.js +1 -3
  6. package/es/src/charts/BoxWhisker.js +2 -4
  7. package/es/src/charts/BumpChart.js +4 -5
  8. package/es/src/charts/Donut.js +1 -3
  9. package/es/src/charts/Geomap.js +47 -88
  10. package/es/src/charts/LinePlot.js +1 -3
  11. package/es/src/charts/Matrix.js +27 -46
  12. package/es/src/charts/Network.js +87 -81
  13. package/es/src/charts/Pack.js +21 -34
  14. package/es/src/charts/Pie.js +12 -24
  15. package/es/src/charts/Plot.js +226 -321
  16. package/es/src/charts/Priestley.js +18 -36
  17. package/es/src/charts/Radar.js +100 -47
  18. package/es/src/charts/RadialMatrix.js +35 -47
  19. package/es/src/charts/Rings.js +99 -90
  20. package/es/src/charts/Sankey.js +85 -75
  21. package/es/src/charts/StackedArea.js +1 -3
  22. package/es/src/charts/Tree.js +27 -28
  23. package/es/src/charts/Treemap.js +117 -71
  24. package/es/src/charts/Viz.js +296 -492
  25. package/es/src/charts/drawSteps/drawAttribution.js +1 -1
  26. package/es/src/charts/drawSteps/drawBack.js +1 -2
  27. package/es/src/charts/drawSteps/drawColorScale.js +1 -2
  28. package/es/src/charts/drawSteps/drawLegend.js +8 -10
  29. package/es/src/charts/drawSteps/drawSubtitle.js +1 -3
  30. package/es/src/charts/drawSteps/drawTimeline.js +12 -9
  31. package/es/src/charts/drawSteps/drawTitle.js +1 -3
  32. package/es/src/charts/drawSteps/drawTotal.js +1 -3
  33. package/es/src/charts/drawSteps/zoomControls.js +19 -21
  34. package/es/src/charts/events/click.legend.js +2 -3
  35. package/es/src/charts/events/click.shape.js +2 -4
  36. package/es/src/charts/events/mouseenter.js +7 -8
  37. package/es/src/charts/events/mouseleave.js +1 -3
  38. package/es/src/charts/events/mousemove.legend.js +3 -4
  39. package/es/src/charts/events/mousemove.shape.js +2 -4
  40. package/es/src/charts/events/touchstart.body.js +1 -1
  41. package/es/src/charts/helpers/matrixData.js +11 -4
  42. package/es/src/charts/helpers/tileAttributions.js +2 -1
  43. package/es/src/charts/plotBuffers/Bar.js +55 -12
  44. package/es/src/charts/plotBuffers/Box.js +55 -12
  45. package/es/src/charts/plotBuffers/Circle.js +9 -11
  46. package/es/src/charts/plotBuffers/Line.js +4 -6
  47. package/es/src/charts/plotBuffers/Rect.js +10 -12
  48. package/es/src/charts/plotBuffers/discreteBuffer.js +4 -2
  49. package/es/src/charts/plotBuffers/numericBuffer.js +7 -6
  50. package/es/src/components/Axis.js +298 -426
  51. package/es/src/components/AxisBottom.js +1 -3
  52. package/es/src/components/AxisLeft.js +1 -3
  53. package/es/src/components/AxisRight.js +1 -3
  54. package/es/src/components/AxisTop.js +1 -3
  55. package/es/src/components/ColorScale.js +80 -197
  56. package/es/src/components/Legend.js +82 -135
  57. package/es/src/components/Message.js +27 -19
  58. package/es/src/components/TextBox.js +106 -262
  59. package/es/src/components/Timeline.js +88 -155
  60. package/es/src/components/Tooltip.js +301 -330
  61. package/es/src/shapes/Area.js +95 -74
  62. package/es/src/shapes/Bar.js +46 -86
  63. package/es/src/shapes/Box.js +104 -118
  64. package/es/src/shapes/Circle.js +29 -30
  65. package/es/src/shapes/Image.js +44 -102
  66. package/es/src/shapes/Line.js +74 -40
  67. package/es/src/shapes/Path.js +23 -25
  68. package/es/src/shapes/Rect.js +29 -41
  69. package/es/src/shapes/Shape.js +146 -363
  70. package/es/src/shapes/Whisker.js +89 -90
  71. package/es/src/utils/AccessorFn.js +4 -0
  72. package/es/src/utils/BaseClass.js +53 -82
  73. package/es/src/utils/D3plusConfig.js +1 -0
  74. package/es/src/utils/RESET.js +2 -4
  75. package/es/src/utils/accessor.js +4 -5
  76. package/es/src/utils/configPrep.js +13 -12
  77. package/es/src/utils/constant.js +2 -3
  78. package/es/src/utils/getProp.js +4 -4
  79. package/es/src/utils/index.js +0 -1
  80. package/package.json +30 -22
  81. package/types/index.d.ts +5 -0
  82. package/types/src/charts/AreaPlot.d.ts +16 -0
  83. package/types/src/charts/BarChart.d.ts +16 -0
  84. package/types/src/charts/BoxWhisker.d.ts +11 -0
  85. package/types/src/charts/BumpChart.d.ts +36 -0
  86. package/types/src/charts/Donut.d.ts +11 -0
  87. package/types/src/charts/Geomap.d.ts +120 -0
  88. package/types/src/charts/LinePlot.d.ts +15 -0
  89. package/types/src/charts/Matrix.d.ts +74 -0
  90. package/types/src/charts/Network.d.ts +78 -0
  91. package/types/src/charts/Pack.d.ts +47 -0
  92. package/types/src/charts/Pie.d.ts +44 -0
  93. package/types/src/charts/Plot.d.ts +199 -0
  94. package/types/src/charts/Priestley.d.ts +37 -0
  95. package/types/src/charts/Radar.d.ts +38 -0
  96. package/types/src/charts/RadialMatrix.d.ts +78 -0
  97. package/types/src/charts/Rings.d.ts +74 -0
  98. package/types/src/charts/Sankey.d.ts +81 -0
  99. package/types/src/charts/StackedArea.d.ts +14 -0
  100. package/types/src/charts/Tree.d.ts +33 -0
  101. package/types/src/charts/Treemap.d.ts +51 -0
  102. package/types/src/charts/Viz.d.ts +402 -0
  103. package/types/src/charts/drawSteps/drawAttribution.d.ts +7 -0
  104. package/types/src/charts/drawSteps/drawBack.d.ts +6 -0
  105. package/types/src/charts/drawSteps/drawColorScale.d.ts +6 -0
  106. package/types/src/charts/drawSteps/drawLegend.d.ts +12 -0
  107. package/types/src/charts/drawSteps/drawSubtitle.d.ts +7 -0
  108. package/types/src/charts/drawSteps/drawTimeline.d.ts +7 -0
  109. package/types/src/charts/drawSteps/drawTitle.d.ts +7 -0
  110. package/types/src/charts/drawSteps/drawTotal.d.ts +7 -0
  111. package/types/src/charts/drawSteps/zoomControls.d.ts +7 -0
  112. package/types/src/charts/events/click.legend.d.ts +8 -0
  113. package/types/src/charts/events/click.shape.d.ts +8 -0
  114. package/types/src/charts/events/mouseenter.d.ts +8 -0
  115. package/types/src/charts/events/mouseleave.d.ts +8 -0
  116. package/types/src/charts/events/mousemove.legend.d.ts +9 -0
  117. package/types/src/charts/events/mousemove.shape.d.ts +9 -0
  118. package/types/src/charts/events/touchstart.body.d.ts +7 -0
  119. package/types/src/charts/helpers/matrixData.d.ts +11 -0
  120. package/types/src/charts/helpers/tileAttributions.d.ts +6 -0
  121. package/types/src/charts/index.d.ts +21 -0
  122. package/types/src/charts/plotBuffers/Bar.d.ts +16 -0
  123. package/types/src/charts/plotBuffers/Box.d.ts +16 -0
  124. package/types/src/charts/plotBuffers/Circle.d.ts +20 -0
  125. package/types/src/charts/plotBuffers/Line.d.ts +16 -0
  126. package/types/src/charts/plotBuffers/Rect.d.ts +19 -0
  127. package/types/src/charts/plotBuffers/discreteBuffer.d.ts +7 -0
  128. package/types/src/charts/plotBuffers/numericBuffer.d.ts +5 -0
  129. package/types/src/components/Axis.d.ts +309 -0
  130. package/types/src/components/AxisBottom.d.ts +11 -0
  131. package/types/src/components/AxisLeft.d.ts +11 -0
  132. package/types/src/components/AxisRight.d.ts +11 -0
  133. package/types/src/components/AxisTop.d.ts +11 -0
  134. package/types/src/components/ColorScale.d.ts +208 -0
  135. package/types/src/components/Legend.d.ts +157 -0
  136. package/types/src/components/Message.d.ts +40 -0
  137. package/types/src/components/TextBox.d.ts +278 -0
  138. package/types/src/components/Timeline.d.ts +157 -0
  139. package/types/src/components/Tooltip.d.ts +297 -0
  140. package/types/src/components/index.d.ts +11 -0
  141. package/types/src/shapes/Area.d.ts +81 -0
  142. package/types/src/shapes/Bar.d.ts +104 -0
  143. package/types/src/shapes/Box.d.ts +121 -0
  144. package/types/src/shapes/Circle.d.ts +44 -0
  145. package/types/src/shapes/Image.d.ts +124 -0
  146. package/types/src/shapes/Line.d.ts +48 -0
  147. package/types/src/shapes/Path.d.ts +38 -0
  148. package/types/src/shapes/Rect.d.ts +54 -0
  149. package/types/src/shapes/Shape.d.ts +378 -0
  150. package/types/src/shapes/Whisker.d.ts +96 -0
  151. package/types/src/shapes/index.d.ts +10 -0
  152. package/types/src/utils/AccessorFn.d.ts +6 -0
  153. package/types/src/utils/BaseClass.d.ts +76 -0
  154. package/types/src/utils/D3plusConfig.d.ts +164 -0
  155. package/types/src/utils/RESET.d.ts +3 -0
  156. package/types/src/utils/accessor.d.ts +13 -0
  157. package/types/src/utils/configPrep.d.ts +28 -0
  158. package/types/src/utils/constant.d.ts +11 -0
  159. package/types/src/utils/getProp.d.ts +9 -0
  160. package/types/src/utils/index.d.ts +8 -0
  161. package/umd/d3plus-core.full.js +20127 -18701
  162. package/umd/d3plus-core.full.js.map +1 -1
  163. package/umd/d3plus-core.full.min.js +2920 -5394
  164. package/umd/d3plus-core.js +1920 -4074
  165. package/umd/d3plus-core.js.map +1 -1
  166. package/umd/d3plus-core.min.js +1605 -3937
  167. package/es/src/utils/uuid.js +0 -13
@@ -1,3 +1,11 @@
1
+ function _array_like_to_array(arr, len) {
2
+ if (len == null || len > arr.length) len = arr.length;
3
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
4
+ return arr2;
5
+ }
6
+ function _array_with_holes(arr) {
7
+ if (Array.isArray(arr)) return arr;
8
+ }
1
9
  function _assert_this_initialized(self) {
2
10
  if (self === void 0) {
3
11
  throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
@@ -27,6 +35,19 @@ function _create_class(Constructor, protoProps, staticProps) {
27
35
  if (staticProps) _defineProperties(Constructor, staticProps);
28
36
  return Constructor;
29
37
  }
38
+ function _define_property(obj, key, value) {
39
+ if (key in obj) {
40
+ Object.defineProperty(obj, key, {
41
+ value: value,
42
+ enumerable: true,
43
+ configurable: true,
44
+ writable: true
45
+ });
46
+ } else {
47
+ obj[key] = value;
48
+ }
49
+ return obj;
50
+ }
30
51
  function _get_prototype_of(o) {
31
52
  _get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
32
53
  return o.__proto__ || Object.getPrototypeOf(o);
@@ -46,6 +67,33 @@ function _inherits(subClass, superClass) {
46
67
  });
47
68
  if (superClass) _set_prototype_of(subClass, superClass);
48
69
  }
70
+ function _iterable_to_array_limit(arr, i) {
71
+ var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
72
+ if (_i == null) return;
73
+ var _arr = [];
74
+ var _n = true;
75
+ var _d = false;
76
+ var _s, _e;
77
+ try {
78
+ for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
79
+ _arr.push(_s.value);
80
+ if (i && _arr.length === i) break;
81
+ }
82
+ } catch (err) {
83
+ _d = true;
84
+ _e = err;
85
+ } finally{
86
+ try {
87
+ if (!_n && _i["return"] != null) _i["return"]();
88
+ } finally{
89
+ if (_d) throw _e;
90
+ }
91
+ }
92
+ return _arr;
93
+ }
94
+ function _non_iterable_rest() {
95
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
96
+ }
49
97
  function _possible_constructor_return(self, call) {
50
98
  if (call && (_type_of(call) === "object" || typeof call === "function")) {
51
99
  return call;
@@ -59,10 +107,21 @@ function _set_prototype_of(o, p) {
59
107
  };
60
108
  return _set_prototype_of(o, p);
61
109
  }
110
+ function _sliced_to_array(arr, i) {
111
+ return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
112
+ }
62
113
  function _type_of(obj) {
63
114
  "@swc/helpers - typeof";
64
115
  return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
65
116
  }
117
+ function _unsupported_iterable_to_array(o, minLen) {
118
+ if (!o) return;
119
+ if (typeof o === "string") return _array_like_to_array(o, minLen);
120
+ var n = Object.prototype.toString.call(o).slice(8, -1);
121
+ if (n === "Object" && o.constructor) n = o.constructor.name;
122
+ if (n === "Map" || n === "Set") return Array.from(n);
123
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
124
+ }
66
125
  function _is_native_reflect_construct() {
67
126
  try {
68
127
  var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
@@ -71,7 +130,7 @@ function _is_native_reflect_construct() {
71
130
  return !!result;
72
131
  })();
73
132
  }
74
- import { nest } from "d3-collection";
133
+ import { groups } from "d3-array";
75
134
  import { select } from "d3-selection";
76
135
  import { assign, elem } from "@d3plus/dom";
77
136
  import { accessor, BaseClass, configPrep, constant } from "../utils/index.js";
@@ -88,7 +147,7 @@ var Whisker = /*#__PURE__*/ function(BaseClass) {
88
147
  function Whisker() {
89
148
  _class_call_check(this, Whisker);
90
149
  var _this;
91
- _this = _call_super(this, Whisker);
150
+ _this = _call_super(this, Whisker), _define_property(_this, "_endpoint", void 0), _define_property(_this, "_endpointConfig", void 0), _define_property(_this, "_length", void 0), _define_property(_this, "_lineConfig", void 0), _define_property(_this, "_orient", void 0), _define_property(_this, "_x", void 0), _define_property(_this, "_y", void 0), _define_property(_this, "_data", void 0), _define_property(_this, "_select", void 0), _define_property(_this, "_line", void 0), _define_property(_this, "_whiskerEndpoint", void 0);
92
151
  _this._endpoint = accessor("endpoint", "Rect");
93
152
  _this._endpointConfig = {
94
153
  Circle: {
@@ -100,16 +159,15 @@ var Whisker = /*#__PURE__*/ function(BaseClass) {
100
159
  _this._orient = accessor("orient", "top");
101
160
  _this._x = accessor("x", 0);
102
161
  _this._y = accessor("y", 0);
162
+ _this._whiskerEndpoint = [];
103
163
  return _this;
104
164
  }
105
165
  _create_class(Whisker, [
106
166
  {
107
167
  /**
108
- @memberof Whisker
109
- @desc Draws the whisker.
110
- @param {Function} [*callback*]
111
- @chainable
112
- */ key: "render",
168
+ Draws the whisker.
169
+ @param callback Optional callback invoked after rendering completes.
170
+ */ key: "render",
113
171
  value: function render(callback) {
114
172
  var _this = this;
115
173
  if (this._select === void 0) {
@@ -146,7 +204,8 @@ var Whisker = /*#__PURE__*/ function(BaseClass) {
146
204
  // Draw whisker line.
147
205
  this._line = new Line().data(lineData).select(elem("g.d3plus-Whisker", {
148
206
  parent: this._select
149
- }).node()).config(configPrep.bind(this)(this._lineConfig, "shape")).render(callback);
207
+ }).node())// eslint-disable-next-line @typescript-eslint/no-explicit-any
208
+ .config(configPrep.bind(this)(this._lineConfig, "shape")).render(callback);
150
209
  var whiskerData = this._data.map(function(d, i) {
151
210
  var dataObj = {};
152
211
  dataObj.__d3plus__ = true;
@@ -167,31 +226,29 @@ var Whisker = /*#__PURE__*/ function(BaseClass) {
167
226
  });
168
227
  // Draw whisker endpoint.
169
228
  this._whiskerEndpoint = [];
170
- nest().key(function(d) {
229
+ groups(whiskerData, function(d) {
171
230
  return d.endpoint;
172
- }).entries(whiskerData).forEach(function(shapeData) {
173
- var shapeName = shapeData.key;
174
- _this._whiskerEndpoint.push(new shapes[shapeName]().data(shapeData.values).select(elem("g.d3plus-Whisker-Endpoint-".concat(shapeName), {
231
+ }).forEach(function(param) {
232
+ var _param = _sliced_to_array(param, 2), shapeName = _param[0], values = _param[1];
233
+ _this._whiskerEndpoint.push(new shapes[shapeName]().data(values).select(elem("g.d3plus-Whisker-Endpoint-".concat(shapeName), {
175
234
  parent: _this._select
176
235
  }).node()).config({
177
- height: function(d) {
236
+ height: function height(d) {
178
237
  return d.orient === "top" || d.orient === "bottom" ? 5 : 20;
179
238
  },
180
- width: function(d) {
239
+ width: function width(d) {
181
240
  return d.orient === "top" || d.orient === "bottom" ? 20 : 5;
182
241
  }
183
- }).config(configPrep.bind(_this)(_this._endpointConfig, "shape", shapeName)).render());
242
+ })// eslint-disable-next-line @typescript-eslint/no-explicit-any
243
+ .config(configPrep.bind(_this)(_this._endpointConfig, "shape", shapeName)).render());
184
244
  });
185
245
  return this;
186
246
  }
187
247
  },
188
248
  {
189
249
  /**
190
- @memberof Whisker
191
- @desc Sets the highlight accessor to the Shape class's active function.
192
- @param {Function} [*value*]
193
- @chainable
194
- */ key: "active",
250
+ The active highlight state for all sub-shapes in this Whisker.
251
+ */ key: "active",
195
252
  value: function active(_) {
196
253
  if (this._line) this._line.active(_);
197
254
  if (this._whiskerEndpoint) this._whiskerEndpoint.forEach(function(endPoint) {
@@ -200,45 +257,27 @@ var Whisker = /*#__PURE__*/ function(BaseClass) {
200
257
  }
201
258
  },
202
259
  {
203
- /**
204
- @memberof Whisker
205
- @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.
206
- @param {Array} [*data* = []]
207
- @chainable
208
- */ key: "data",
260
+ key: "data",
209
261
  value: function data(_) {
210
262
  return arguments.length ? (this._data = _, this) : this._data;
211
263
  }
212
264
  },
213
265
  {
214
- /**
215
- @memberof Whisker
216
- @desc If *value* is specified, sets the endpoint accessor to the specified function or string and returns the current class instance.
217
- @param {Function|String}
218
- @chainable
219
- */ key: "endpoint",
266
+ key: "endpoint",
220
267
  value: function endpoint(_) {
221
268
  return arguments.length ? (this._endpoint = typeof _ === "function" ? _ : constant(_), this) : this._endpoint;
222
269
  }
223
270
  },
224
271
  {
225
- /**
226
- @memberof Whisker
227
- @desc If *value* is specified, sets the config method for each endpoint and returns the current class instance.
228
- @param {Object} [*value*]
229
- @chainable
230
- */ key: "endpointConfig",
272
+ key: "endpointConfig",
231
273
  value: function endpointConfig(_) {
232
274
  return arguments.length ? (this._endpointConfig = assign(this._endpointConfig, _), this) : this._endpointConfig;
233
275
  }
234
276
  },
235
277
  {
236
278
  /**
237
- @memberof Whisker
238
- @desc Sets the highlight accessor to the Shape class's hover function.
239
- @param {Function} [*value*]
240
- @chainable
241
- */ key: "hover",
279
+ The hover highlight state for all sub-shapes in this Whisker.
280
+ */ key: "hover",
242
281
  value: function hover(_) {
243
282
  if (this._line) this._line.hover(_);
244
283
  if (this._whiskerEndpoint) this._whiskerEndpoint.forEach(function(endPoint) {
@@ -247,75 +286,37 @@ var Whisker = /*#__PURE__*/ function(BaseClass) {
247
286
  }
248
287
  },
249
288
  {
250
- /**
251
- @memberof Whisker
252
- @desc If *value* is specified, sets the length accessor for whisker and returns the current class instance.
253
- @param {Function|Number} [*value*]
254
- @chainable
255
- */ key: "length",
289
+ key: "length",
256
290
  value: function length(_) {
257
291
  return arguments.length ? (this._length = typeof _ === "function" ? _ : constant(_), this) : this._length;
258
292
  }
259
293
  },
260
294
  {
261
- /**
262
- @memberof Whisker
263
- @desc If *value* is specified, sets the config method for line shape and returns the current class instance.
264
- @param {Object} [*value*]
265
- @chainable
266
- */ key: "lineConfig",
295
+ key: "lineConfig",
267
296
  value: function lineConfig(_) {
268
297
  return arguments.length ? (this._lineConfig = assign(this._lineConfig, _), this) : this._lineConfig;
269
298
  }
270
299
  },
271
300
  {
272
- /**
273
- @memberof Whisker
274
- @desc If *value* is specified, sets the orientation to the specified value. If *value* is not specified, returns the current orientation.
275
- @param {Function|String} [*value* = "top"] Accepts "top", "right", "bottom" or "left"
276
- @chainable
277
- */ key: "orient",
301
+ key: "orient",
278
302
  value: function orient(_) {
279
303
  return arguments.length ? (this._orient = typeof _ === "function" ? _ : constant(_), this) : this._orient;
280
304
  }
281
305
  },
282
306
  {
283
- /**
284
- @memberof Whisker
285
- @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.
286
- @param {String|HTMLElement} [*selector* = d3.select("body").append("svg")]
287
- @chainable
288
- */ key: "select",
307
+ key: "select",
289
308
  value: function select1(_) {
290
309
  return arguments.length ? (this._select = select(_), this) : this._select;
291
310
  }
292
311
  },
293
312
  {
294
- /**
295
- @memberof Whisker
296
- @desc If *value* is specified, sets the x axis to the specified function or number and returns the current class instance.
297
- @param {Function|Number} [*value*]
298
- @chainable
299
- @example
300
- function(d) {
301
- return d.x;
302
- }
303
- */ key: "x",
313
+ key: "x",
304
314
  value: function x(_) {
305
315
  return arguments.length ? (this._x = typeof _ === "function" ? _ : constant(_), this) : this._x;
306
316
  }
307
317
  },
308
318
  {
309
- /**
310
- @memberof Whisker
311
- @desc If *value* is specified, sets the y axis to the specified function or number and returns the current class instance.
312
- @param {Function|Number} [*value*]
313
- @chainable
314
- @example
315
- function(d) {
316
- return d.y;
317
- }
318
- */ key: "y",
319
+ key: "y",
319
320
  value: function y(_) {
320
321
  return arguments.length ? (this._y = typeof _ === "function" ? _ : constant(_), this) : this._y;
321
322
  }
@@ -324,7 +325,5 @@ function(d) {
324
325
  return Whisker;
325
326
  }(BaseClass);
326
327
  /**
327
- @class Whisker
328
- @extends BaseClass
329
- @desc Creates SVG whisker based on an array of data.
328
+ Creates SVG whisker based on an array of data.
330
329
  */ export { Whisker as default };
@@ -0,0 +1,4 @@
1
+ /**
2
+ @type AccessorFn
3
+ A function that accesses a property from a DataPoint.
4
+ */ export { };
@@ -17,14 +17,25 @@ function _create_class(Constructor, protoProps, staticProps) {
17
17
  if (staticProps) _defineProperties(Constructor, staticProps);
18
18
  return Constructor;
19
19
  }
20
+ function _define_property(obj, key, value) {
21
+ if (key in obj) {
22
+ Object.defineProperty(obj, key, {
23
+ value: value,
24
+ enumerable: true,
25
+ configurable: true,
26
+ writable: true
27
+ });
28
+ } else {
29
+ obj[key] = value;
30
+ }
31
+ return obj;
32
+ }
20
33
  import { assign, isObject } from "@d3plus/dom";
21
34
  import { findLocale, translateLocale as dictionaries } from "@d3plus/locales";
22
35
  import RESET from "./RESET.js";
23
- import uuid from "./uuid.js";
24
36
  /**
25
- @desc Recursive function that resets nested Object configs.
26
- @param {Object} obj
27
- @param {Object} defaults
37
+ Recursive function that resets nested Object configs.
38
+
28
39
  @private
29
40
  */ function nestedReset(obj, defaults) {
30
41
  if (isObject(obj)) {
@@ -42,10 +53,10 @@ import uuid from "./uuid.js";
42
53
  }
43
54
  }
44
55
  /**
45
- * @desc finds all prototype methods of a class and it's parent classes
46
- * @param {*} obj
47
- * @private
48
- */ function getAllMethods(obj) {
56
+ finds all prototype methods of a class and it's parent classes
57
+ @param obj
58
+ @private
59
+ */ function getAllMethods(obj) {
49
60
  var props = [];
50
61
  do {
51
62
  props = props.concat(Object.getOwnPropertyNames(obj));
@@ -65,29 +76,32 @@ var BaseClass = /*#__PURE__*/ function() {
65
76
  function BaseClass() {
66
77
  var _this = this;
67
78
  _class_call_check(this, BaseClass);
79
+ _define_property(this, "_locale", void 0);
80
+ _define_property(this, "_on", void 0);
81
+ _define_property(this, "_parent", void 0);
82
+ _define_property(this, "_translate", void 0);
83
+ _define_property(this, "_uuid", void 0);
84
+ _define_property(this, "_configDefault", void 0);
85
+ _define_property(this, "_shapeConfig", void 0);
68
86
  this._locale = "en-US";
69
87
  this._on = {};
70
88
  this._parent = {};
71
89
  this._translate = function(d) {
72
90
  var locale = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : _this._locale;
73
91
  var dictionary = dictionaries[locale];
74
- return dictionary && dictionary[d] ? dictionary[d] : d;
92
+ var key = d;
93
+ return dictionary && dictionary[key] ? dictionary[key] : d;
75
94
  };
76
- this._uuid = uuid();
95
+ this._uuid = crypto.randomUUID();
77
96
  }
78
97
  _create_class(BaseClass, [
79
98
  {
80
- /**
81
- @memberof BaseClass
82
- @desc If *value* is specified, sets the methods that correspond to the key/value pairs and returns this class. If *value* is not specified, returns the current configuration.
83
- @param {Object} [*value*]
84
- @chainable
85
- */ key: "config",
99
+ key: "config",
86
100
  value: function config(_) {
87
101
  var _this = this;
88
102
  if (!this._configDefault) {
89
103
  var config = {};
90
- getAllMethods(this.__proto__).forEach(function(k) {
104
+ getAllMethods(Object.getPrototypeOf(this)).forEach(function(k) {
91
105
  var v = _this[k]();
92
106
  if (v !== _this) config[k] = isObject(v) ? assign({}, v) : v;
93
107
  });
@@ -95,21 +109,27 @@ var BaseClass = /*#__PURE__*/ function() {
95
109
  }
96
110
  if (arguments.length) {
97
111
  for(var k in _){
98
- if (({}).hasOwnProperty.call(_, k) && k in this) {
99
- var v = _[k];
100
- if (v === RESET) {
101
- if (k === "on") this._on = this._configDefault[k];
102
- else this[k](this._configDefault[k]);
112
+ if (({}).hasOwnProperty.call(_, k)) {
113
+ if (k in this) {
114
+ var v = _[k];
115
+ if (v === RESET) {
116
+ if (k === "on") this._on = this._configDefault[k];
117
+ else this[k](this._configDefault[k]);
118
+ } else {
119
+ nestedReset(v, this._configDefault[k]);
120
+ this[k](v);
121
+ }
103
122
  } else {
104
- nestedReset(v, this._configDefault[k]);
105
- this[k](v);
123
+ // console.warn(
124
+ // `${this.constructor.name}.config() received unknown property "${k}".`,
125
+ // );
106
126
  }
107
127
  }
108
128
  }
109
129
  return this;
110
130
  } else {
111
131
  var config1 = {};
112
- getAllMethods(this.__proto__).forEach(function(k) {
132
+ getAllMethods(Object.getPrototypeOf(this)).forEach(function(k) {
113
133
  config1[k] = _this[k]();
114
134
  });
115
135
  return config1;
@@ -117,88 +137,39 @@ var BaseClass = /*#__PURE__*/ function() {
117
137
  }
118
138
  },
119
139
  {
120
- /**
121
- @memberof BaseClass
122
- @desc Sets the locale used for all text and number formatting. This method supports the locales defined in [d3plus-format](https://github.com/d3plus/d3plus-format/blob/master/src/locale.js). The locale can be defined as a complex Object (like in d3plus-format), a locale code (like "en-US"), or a 2-digit language code (like "en"). If a 2-digit code is provided, the "findLocale" function is used to identify the most approximate locale from d3plus-format.
123
- @param {Object|String} [*value* = "en-US"]
124
- @chainable
125
- @example
126
- {
127
- separator: "",
128
- suffixes: ["y", "z", "a", "f", "p", "n", "µ", "m", "", "k", "M", "B", "t", "q", "Q", "Z", "Y"],
129
- grouping: [3],
130
- delimiters: {
131
- thousands: ",",
132
- decimal: "."
133
- },
134
- currency: ["$", ""]
135
- }
136
- */ key: "locale",
140
+ key: "locale",
137
141
  value: function locale(_) {
138
142
  return arguments.length ? (this._locale = findLocale(_), this) : this._locale;
139
143
  }
140
144
  },
141
145
  {
142
- /**
143
- @memberof BaseClass
144
- @desc Adds or removes a *listener* to each object for the specified event *typenames*. If a *listener* is not specified, returns the currently assigned listener for the specified event *typename*. Mirrors the core [d3-selection](https://github.com/d3/d3-selection#selection_on) behavior.
145
- @param {String} [*typenames*]
146
- @param {Function} [*listener*]
147
- @chainable
148
- @example <caption>By default, listeners apply globally to all objects, however, passing a namespace with the class name gives control over specific elements:</caption>
149
- new Plot
150
- .on("click.Shape", function(d) {
151
- console.log("data for shape clicked:", d);
152
- })
153
- .on("click.Legend", function(d) {
154
- console.log("data for legend clicked:", d);
155
- })
156
- */ key: "on",
146
+ key: "on",
157
147
  value: function on(_, f) {
158
148
  return arguments.length === 2 ? (this._on[_] = f, this) : arguments.length ? typeof _ === "string" ? this._on[_] : (this._on = Object.assign({}, this._on, _), this) : this._on;
159
149
  }
160
150
  },
161
151
  {
162
- /**
163
- @memberof Viz
164
- @desc If *value* is specified, sets the parent config used by the wrapper and returns the current class instance.
165
- @param {Object} [*value*]
166
- @chainable
167
- */ key: "parent",
152
+ key: "parent",
168
153
  value: function parent(_) {
169
154
  return arguments.length ? (this._parent = _, this) : this._parent;
170
155
  }
171
156
  },
172
157
  {
173
- /**
174
- @memberof BaseClass
175
- @desc Defines how informational text strings should be displayed. By default, this function will try to find the string in question (which is the first argument provided to this function) inside of an internally managed translation Object. If you'd like to override to use custom text, simply pass this method your own custom formatting function.
176
- @param {Function} [*value*]
177
- @chainable
178
- @example <caption>For example, if we wanted to only change the string "Back" and allow all other string to return in English:</caption>
179
- .translate(function(d) {
180
- return d === "Back" ? "Get outta here" : d;
181
- })
182
- */ key: "translate",
158
+ key: "translate",
183
159
  value: function translate(_) {
184
160
  return arguments.length ? (this._translate = _, this) : this._translate;
185
161
  }
186
162
  },
187
163
  {
188
- /**
189
- @memberof Viz
190
- @desc If *value* is specified, sets the config method for each shape and returns the current class instance.
191
- @param {Object} [*value*]
192
- @chainable
193
- */ key: "shapeConfig",
164
+ key: "shapeConfig",
194
165
  value: function shapeConfig(_) {
195
- return arguments.length ? (this._shapeConfig = assign(this._shapeConfig, _), this) : this._shapeConfig;
166
+ var _this__shapeConfig;
167
+ return arguments.length ? (this._shapeConfig = assign((_this__shapeConfig = this._shapeConfig) !== null && _this__shapeConfig !== void 0 ? _this__shapeConfig : {}, _), this) : this._shapeConfig;
196
168
  }
197
169
  }
198
170
  ]);
199
171
  return BaseClass;
200
172
  }();
201
173
  /**
202
- @class BaseClass
203
- @summary An abstract class that contains some global methods and functionality.
174
+ Provides shared configuration, event handling, and locale management inherited by all d3plus classes.
204
175
  */ export { BaseClass as default };
@@ -0,0 +1 @@
1
+ export { };
@@ -1,4 +1,2 @@
1
- /**
2
- @constant RESET
3
- @desc String constant used to reset an individual config property.
4
- */ export default "D3PLUS-COMMON-RESET";
1
+ /** String constant used to reset an individual config property. */ var RESET = "D3PLUS-COMMON-RESET";
2
+ export default RESET;
@@ -1,15 +1,14 @@
1
1
  /**
2
- @function accessor
3
- @desc Wraps an object key in a simple accessor function.
4
- @param {String} key The key to be returned from each Object passed to the function.
5
- @param {*} [def] A default value to be returned if the key is not present.
2
+ Wraps an object key in a simple accessor function.
3
+ @param key The key to be returned from each Object passed to the function.
4
+ @param def A default value to be returned if the key is not present.
6
5
  @example <caption>this</caption>
7
6
  accessor("id");
8
7
  @example <caption>returns this</caption>
9
8
  function(d) {
10
9
  return d["id"];
11
10
  }
12
- */ export default function(key, def) {
11
+ */ export default function accessor(key, def) {
13
12
  if (def === undefined) return function(d) {
14
13
  return d[key];
15
14
  };
@@ -1,10 +1,5 @@
1
- /**
2
- @function configPrep
3
- @desc Preps a config object for d3plus data, and optionally bubbles up a specific nested type. When using this function, you must bind a d3plus class' `this` context.
4
- @param {Object} [config = this._shapeConfig] The configuration object to parse.
5
- @param {String} [type = "shape"] The event classifier to user for "on" events. For example, the default event type of "shape" will apply all events in the "on" config object with that key, like "click.shape" and "mouseleave.shape", in addition to any gloval events like "click" and "mouseleave".
6
- @param {String} [nest] An optional nested key to bubble up to the parent config level.
7
- */ function _instanceof(left, right) {
1
+ function _instanceof(left, right) {
2
+ "@swc/helpers - instanceof";
8
3
  if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
9
4
  return !!right[Symbol.hasInstance](left);
10
5
  } else {
@@ -15,14 +10,19 @@ function _type_of(obj) {
15
10
  "@swc/helpers - typeof";
16
11
  return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
17
12
  }
18
- export default function configPrep() {
13
+ /**
14
+ Preps a config object for d3plus data, and optionally bubbles up a specific nested type. When using this function, you must bind a d3plus class' `this` context.
15
+ @param config The configuration object to parse.
16
+ @param type The event classifier to user for "on" events. For example, the default event type of "shape" will apply all events in the "on" config object with that key, like "click.shape" and "mouseleave.shape", in addition to any gloval events like "click" and "mouseleave".
17
+ @param nest An optional nested key to bubble up to the parent config level.
18
+ */ export default function configPrep() {
19
19
  var _this = this;
20
20
  var config = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : this._shapeConfig, type = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "shape", nest = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : false;
21
21
  var newConfig = {
22
22
  duration: this._duration,
23
23
  on: {}
24
24
  };
25
- var wrapFunction = function(func) {
25
+ var wrapFunction = function wrapFunction(func) {
26
26
  return function(d, i, s, e) {
27
27
  if (!func) return func;
28
28
  var parent;
@@ -35,14 +35,14 @@ export default function configPrep() {
35
35
  return func.bind(_this)(d, i, s || parent, e);
36
36
  };
37
37
  };
38
- var parseEvents = function(newObj, on) {
38
+ var parseEvents = function parseEvents(newObj, on) {
39
39
  for(var event in on){
40
40
  if (({}).hasOwnProperty.call(on, event) && !event.includes(".") || event.includes(".".concat(type))) {
41
41
  newObj.on[event] = wrapFunction(on[event]);
42
42
  }
43
43
  }
44
44
  };
45
- var arrayEval = function(arr) {
45
+ var arrayEval = function arrayEval1(arr) {
46
46
  return arr.map(function(d) {
47
47
  if (_instanceof(d, Array)) return arrayEval(d);
48
48
  else if ((typeof d === "undefined" ? "undefined" : _type_of(d)) === "object") return keyEval({}, d);
@@ -50,7 +50,7 @@ export default function configPrep() {
50
50
  else return d;
51
51
  });
52
52
  };
53
- var keyEval = function(newObj, obj) {
53
+ var keyEval = function keyEval1(newObj, obj) {
54
54
  for(var key in obj){
55
55
  if (({}).hasOwnProperty.call(obj, key)) {
56
56
  if (key === "on") parseEvents(newObj, obj[key]);
@@ -65,6 +65,7 @@ export default function configPrep() {
65
65
  } else newObj[key] = obj[key];
66
66
  }
67
67
  }
68
+ return newObj;
68
69
  };
69
70
  keyEval(newConfig, config);
70
71
  if (this._on) parseEvents(newConfig, this._on);
@@ -1,7 +1,6 @@
1
1
  /**
2
- @function constant
3
- @desc Wraps non-function variables in a simple return function.
4
- @param {Array|Number|Object|String} value The value to be returned from the function.
2
+ Wraps non-function variables in a simple return function.
3
+ @param value The value to wrap in a return function.
5
4
  @example <caption>this</caption>
6
5
  constant(42);
7
6
  @example <caption>returns this</caption>
@@ -1,9 +1,9 @@
1
1
  /**
2
2
  @module getProp
3
- @param {String} type
4
- @param {Object} d
5
- @param {Number} i
3
+ @param type
4
+ @param d
5
+ @param i
6
6
  @private
7
- */ export default function(type, d, i) {
7
+ */ export default function getProp(type, d, i) {
8
8
  return d[type] || this["_".concat(type)](d, i);
9
9
  }