@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
@@ -95,10 +95,10 @@ function _is_native_reflect_construct() {
95
95
  })();
96
96
  }
97
97
  import { min, max, range } from "d3-array";
98
- import { nest } from "d3-collection";
99
98
  import { scaleBand } from "d3-scale";
100
99
  import { Axis } from "../components/index.js";
101
100
  import { assign, date, elem } from "@d3plus/dom";
101
+ import { nestGroups } from "@d3plus/data";
102
102
  import { Rect } from "../shapes/index.js";
103
103
  import { accessor, configPrep } from "../utils/index.js";
104
104
  import Viz from "./Viz.js";
@@ -118,7 +118,7 @@ var Priestley = /*#__PURE__*/ function(Viz) {
118
118
  _this._paddingInner = 0.05;
119
119
  _this._paddingOuter = 0.05;
120
120
  _this._shapeConfig = assign({}, _this._shapeConfig, {
121
- ariaLabel: function(d, i) {
121
+ ariaLabel: function ariaLabel(d, i) {
122
122
  return "".concat(_this._drawLabel(d, i), ", ").concat(_this._start(d, i), " - ").concat(_this._end(d, i), ".");
123
123
  }
124
124
  });
@@ -128,10 +128,9 @@ var Priestley = /*#__PURE__*/ function(Viz) {
128
128
  _create_class(Priestley, [
129
129
  {
130
130
  /**
131
- @memberof Priestley
132
- @desc Extends the render behavior of the abstract Viz class.
131
+ Extends the render behavior of the abstract Viz class.
133
132
  @private
134
- */ key: "_draw",
133
+ */ key: "_draw",
135
134
  value: function _draw(callback) {
136
135
  var _this = this;
137
136
  _get(_get_prototype_of(Priestley.prototype), "_draw", this).call(this, callback);
@@ -153,13 +152,13 @@ var Priestley = /*#__PURE__*/ function(Viz) {
153
152
  var nestedData;
154
153
  if (this._groupBy.length > 1 && this._drawDepth > 0) {
155
154
  var _loop = function(i) {
156
- dataNest.key(function(d) {
155
+ keyFns.push(function(d) {
157
156
  return _this._groupBy[i](d.data, d.i);
158
157
  });
159
158
  };
160
- var dataNest = nest();
159
+ var keyFns = [];
161
160
  for(var i = 0; i < this._drawDepth; i++)_loop(i);
162
- nestedData = dataNest.entries(data);
161
+ nestedData = nestGroups(data, keyFns);
163
162
  } else nestedData = [
164
163
  {
165
164
  values: data
@@ -235,22 +234,16 @@ var Priestley = /*#__PURE__*/ function(Viz) {
235
234
  },
236
235
  {
237
236
  /**
238
- @memberof Priestley
239
- @desc If *value* is specified, sets the config method for the axis and returns the current class instance. If *value* is not specified, returns the current axis configuration.
240
- @param {Object} [*value*]
241
- @chainable
242
- */ key: "axisConfig",
237
+ Configuration object for the axis.
238
+ */ key: "axisConfig",
243
239
  value: function axisConfig(_) {
244
240
  return arguments.length ? (this._axisConfig = assign(this._axisConfig, _), this) : this._axisConfig;
245
241
  }
246
242
  },
247
243
  {
248
244
  /**
249
- @memberof Priestley
250
- @desc If *value* is specified, sets the end accessor to the specified function or key and returns the current class instance. If *value* is not specified, returns the current end accessor.
251
- @param {Function|String} [*value*]
252
- @chainable
253
- */ key: "end",
245
+ Accessor function or string key for the end date of each data point.
246
+ */ key: "end",
254
247
  value: function end(_) {
255
248
  if (arguments.length) {
256
249
  if (typeof _ === "function") this._end = _;
@@ -264,33 +257,24 @@ var Priestley = /*#__PURE__*/ function(Viz) {
264
257
  },
265
258
  {
266
259
  /**
267
- @memberof Priestley
268
- @desc Sets the [paddingInner](https://github.com/d3/d3-scale#band_paddingInner) value of the underlining [Band Scale](https://github.com/d3/d3-scale#band-scales) used to determine the height of each bar. Values should be a ratio between 0 and 1 representing the space in between each rectangle.
269
- @param {Number} [*value* = 0.05]
270
- @chainable
271
- */ key: "paddingInner",
260
+ The [paddingInner](https://github.com/d3/d3-scale#band_paddingInner) value of the underlining [Band Scale](https://github.com/d3/d3-scale#band-scales) used to determine the height of each bar. Values should be a ratio between 0 and 1 representing the space in between each rectangle.
261
+ */ key: "paddingInner",
272
262
  value: function paddingInner(_) {
273
263
  return arguments.length ? (this._paddingInner = _, this) : this._paddingInner;
274
264
  }
275
265
  },
276
266
  {
277
267
  /**
278
- @memberof Priestley
279
- @desc Sets the [paddingOuter](https://github.com/d3/d3-scale#band_paddingOuter) value of the underlining [Band Scale](https://github.com/d3/d3-scale#band-scales) used to determine the height of each bar. Values should be a ratio between 0 and 1 representing the space around the outer rectangles.
280
- @param {Number} [*value* = 0.05]
281
- @chainable
282
- */ key: "paddingOuter",
268
+ The [paddingOuter](https://github.com/d3/d3-scale#band_paddingOuter) value of the underlining [Band Scale](https://github.com/d3/d3-scale#band-scales) used to determine the height of each bar. Values should be a ratio between 0 and 1 representing the space around the outer rectangles.
269
+ */ key: "paddingOuter",
283
270
  value: function paddingOuter(_) {
284
271
  return arguments.length ? (this._paddingOuter = _, this) : this._paddingOuter;
285
272
  }
286
273
  },
287
274
  {
288
275
  /**
289
- @memberof Priestley
290
- @desc If *value* is specified, sets the start accessor to the specified function or key and returns the current class instance. If *value* is not specified, returns the current start accessor.
291
- @param {Function|String} [*value*]
292
- @chainable
293
- */ key: "start",
276
+ Accessor function or string key for the start date of each data point.
277
+ */ key: "start",
294
278
  value: function start(_) {
295
279
  if (arguments.length) {
296
280
  if (typeof _ === "function") this._start = _;
@@ -306,7 +290,5 @@ var Priestley = /*#__PURE__*/ function(Viz) {
306
290
  return Priestley;
307
291
  }(Viz);
308
292
  /**
309
- @class Priestley
310
- @extends Viz
311
- @desc Creates a priestley timeline based on an array of data.
293
+ Creates a priestley timeline based on an array of data.
312
294
  */ export { Priestley as default };
@@ -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");
@@ -62,6 +70,33 @@ function _inherits(subClass, superClass) {
62
70
  });
63
71
  if (superClass) _set_prototype_of(subClass, superClass);
64
72
  }
73
+ function _iterable_to_array_limit(arr, i) {
74
+ var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
75
+ if (_i == null) return;
76
+ var _arr = [];
77
+ var _n = true;
78
+ var _d = false;
79
+ var _s, _e;
80
+ try {
81
+ for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
82
+ _arr.push(_s.value);
83
+ if (i && _arr.length === i) break;
84
+ }
85
+ } catch (err) {
86
+ _d = true;
87
+ _e = err;
88
+ } finally{
89
+ try {
90
+ if (!_n && _i["return"] != null) _i["return"]();
91
+ } finally{
92
+ if (_d) throw _e;
93
+ }
94
+ }
95
+ return _arr;
96
+ }
97
+ function _non_iterable_rest() {
98
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
99
+ }
65
100
  function _possible_constructor_return(self, call) {
66
101
  if (call && (_type_of(call) === "object" || typeof call === "function")) {
67
102
  return call;
@@ -75,6 +110,9 @@ function _set_prototype_of(o, p) {
75
110
  };
76
111
  return _set_prototype_of(o, p);
77
112
  }
113
+ function _sliced_to_array(arr, i) {
114
+ return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
115
+ }
78
116
  function _super_prop_base(object, property) {
79
117
  while(!Object.prototype.hasOwnProperty.call(object, property)){
80
118
  object = _get_prototype_of(object);
@@ -86,6 +124,14 @@ function _type_of(obj) {
86
124
  "@swc/helpers - typeof";
87
125
  return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
88
126
  }
127
+ function _unsupported_iterable_to_array(o, minLen) {
128
+ if (!o) return;
129
+ if (typeof o === "string") return _array_like_to_array(o, minLen);
130
+ var n = Object.prototype.toString.call(o).slice(8, -1);
131
+ if (n === "Object" && o.constructor) n = o.constructor.name;
132
+ if (n === "Map" || n === "Set") return Array.from(n);
133
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
134
+ }
89
135
  function _is_native_reflect_construct() {
90
136
  try {
91
137
  var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
@@ -94,11 +140,11 @@ function _is_native_reflect_construct() {
94
140
  return !!result;
95
141
  })();
96
142
  }
97
- import { min, max, sum } from "d3-array";
98
- import { nest } from "d3-collection";
143
+ import { groups, min, max, sum } from "d3-array";
99
144
  import { pointer } from "d3-selection";
145
+ import { colorContrast } from "@d3plus/color";
100
146
  import { merge } from "@d3plus/data";
101
- import { assign, elem } from "@d3plus/dom";
147
+ import { assign, backgroundColor, elem } from "@d3plus/dom";
102
148
  import { accessor, configPrep, constant } from "../utils/index.js";
103
149
  import { Circle, Path, Rect } from "../shapes/index.js";
104
150
  import Viz from "./Viz.js";
@@ -114,14 +160,20 @@ var Radar = /*#__PURE__*/ function(Viz) {
114
160
  shapeConfig: {
115
161
  fill: constant("none"),
116
162
  labelConfig: {
117
- fontColor: "#999",
163
+ fontColor: function fontColor() {
164
+ var bg = _this._select ? backgroundColor(_this._select.node()) : "rgb(255, 255, 255)";
165
+ return colorContrast(bg);
166
+ },
118
167
  padding: 0,
119
- textAnchor: function(d, i, x) {
168
+ textAnchor: function textAnchor(d, i, x) {
120
169
  return x.textAnchor;
121
170
  },
122
171
  verticalAlign: "middle"
123
172
  },
124
- stroke: "#eee",
173
+ stroke: function stroke() {
174
+ var bg = _this._select ? backgroundColor(_this._select.node()) : "rgb(255, 255, 255)";
175
+ return colorContrast(bg);
176
+ },
125
177
  strokeWidth: constant(1)
126
178
  }
127
179
  };
@@ -138,7 +190,7 @@ var Radar = /*#__PURE__*/ function(Viz) {
138
190
  /**
139
191
  Extends the draw behavior of the abstract Viz class.
140
192
  @private
141
- */ key: "_draw",
193
+ */ key: "_draw",
142
194
  value: function _draw(callback) {
143
195
  var _loop = function(e) {
144
196
  var event = events[e];
@@ -163,16 +215,19 @@ var Radar = /*#__PURE__*/ function(Viz) {
163
215
  };
164
216
  };
165
217
  var _this = this;
218
+ var _pathConfig_on;
166
219
  _get(_get_prototype_of(Radar.prototype), "_draw", this).call(this, callback);
167
220
  var height = this._height - this._margin.top - this._margin.bottom, width = this._width - this._margin.left - this._margin.right;
168
221
  var radius = min([
169
222
  height,
170
223
  width
171
224
  ]) / 2 - this._outerPadding, transform = "translate(".concat(width / 2, ", ").concat(height / 2, ")");
172
- var nestedAxisData = nest().key(this._metric).entries(this._filteredData), nestedGroupData = nest().key(this._id).key(this._metric).entries(this._filteredData);
173
- var maxValue = max(nestedGroupData.map(function(h) {
174
- return h.values.map(function(d) {
175
- return sum(d.values, function(x, i) {
225
+ var nestedAxisData = groups(this._filteredData, this._metric), nestedGroupData = groups(this._filteredData, this._id, this._metric);
226
+ var maxValue = max(nestedGroupData.map(function(param) {
227
+ var _param = _sliced_to_array(param, 2), innerEntries = _param[1];
228
+ return innerEntries.map(function(param) {
229
+ var _param = _sliced_to_array(param, 2), vals = _param[1];
230
+ return sum(vals, function(x, i) {
176
231
  return _this._value(x, i);
177
232
  });
178
233
  });
@@ -195,12 +250,17 @@ var Radar = /*#__PURE__*/ function(Viz) {
195
250
  }
196
251
  }).node()).config(circleConfig).render();
197
252
  var totalAxis = nestedAxisData.length;
198
- var polarAxis = nestedAxisData.map(function(d, i) {
253
+ var polarAxis = nestedAxisData.map(function(param, i) {
254
+ var _param = _sliced_to_array(param, 2), key = _param[0], values = _param[1];
255
+ var d = {
256
+ key: key,
257
+ values: values
258
+ };
199
259
  var width = _this._outerPadding;
200
260
  var fontSize = _this._shapeConfig.labelConfig.fontSize && _this._shapeConfig.labelConfig.fontSize(d, i) || 11;
201
261
  var lineHeight = fontSize * 1.4;
202
262
  var height = lineHeight * 2;
203
- var padding = 10, quadrant = parseInt(360 - 360 / totalAxis * i / 90, 10) % 4 + 1, radians = tau / totalAxis * i;
263
+ var padding = 10, quadrant = parseInt(String(360 - 360 / totalAxis * i / 90), 10) % 4 + 1, radians = tau / totalAxis * i;
204
264
  var angle = 360 / totalAxis * i;
205
265
  var textAnchor = "start";
206
266
  var x = padding;
@@ -220,6 +280,7 @@ var Radar = /*#__PURE__*/ function(Viz) {
220
280
  data: merge(d.values, _this._aggs),
221
281
  i: i,
222
282
  id: d.key,
283
+ key: d.key,
223
284
  angle: angle,
224
285
  textAnchor: textAnchor,
225
286
  labelBounds: labelBounds,
@@ -263,9 +324,11 @@ var Radar = /*#__PURE__*/ function(Viz) {
263
324
  transform: transform
264
325
  }
265
326
  }).node()).config(configPrep.bind(this)(this._axisConfig.shapeConfig, "shape", "Path")).render();
266
- var groupData = nestedGroupData.map(function(h) {
267
- var q = h.values.map(function(d, i) {
268
- var value = sum(d.values, function(x, i) {
327
+ var groupData = nestedGroupData.map(function(param) {
328
+ var _param = _sliced_to_array(param, 2), hKey = _param[0], innerEntries = _param[1];
329
+ var q = innerEntries.map(function(param, i) {
330
+ var _param = _sliced_to_array(param, 2), vals = _param[1];
331
+ var value = sum(vals, function(x, i) {
269
332
  return _this._value(x, i);
270
333
  });
271
334
  var r = value / maxValue * radius, radians = tau / totalAxis * i;
@@ -274,24 +337,26 @@ var Radar = /*#__PURE__*/ function(Viz) {
274
337
  y: r * Math.sin(radians)
275
338
  };
276
339
  });
277
- var d = "M ".concat(q[0].x, " ").concat(q[0].y, " ").concat(q.map(function(l) {
340
+ var pathD = "M ".concat(q[0].x, " ").concat(q[0].y, " ").concat(q.map(function(l) {
278
341
  return "L ".concat(l.x, " ").concat(l.y);
279
342
  }).join(" "), " L ").concat(q[0].x, " ").concat(q[0].y);
280
343
  return {
281
- arr: h.values.map(function(d) {
282
- return merge(d.values, _this._aggs);
344
+ arr: innerEntries.map(function(param) {
345
+ var _param = _sliced_to_array(param, 2), vals = _param[1];
346
+ return merge(vals, _this._aggs);
283
347
  }),
284
- id: h.key,
348
+ id: hKey,
285
349
  points: q,
286
- d: d,
350
+ d: pathD,
287
351
  __d3plus__: true,
288
- data: merge(h.values.map(function(d) {
289
- return merge(d.values, _this._aggs);
352
+ data: merge(innerEntries.map(function(param) {
353
+ var _param = _sliced_to_array(param, 2), vals = _param[1];
354
+ return merge(vals, _this._aggs);
290
355
  }), _this._aggs)
291
356
  };
292
357
  });
293
358
  var pathConfig = configPrep.bind(this)(this._shapeConfig, "shape", "Path");
294
- var events = Object.keys(pathConfig.on);
359
+ var events = Object.keys((_pathConfig_on = pathConfig.on) !== null && _pathConfig_on !== void 0 ? _pathConfig_on : {});
295
360
  pathConfig.on = {};
296
361
  for(var e = 0; e < events.length; e++)_loop(e);
297
362
  this._shapes.push(new Path().data(groupData).d(function(d) {
@@ -310,47 +375,37 @@ var Radar = /*#__PURE__*/ function(Viz) {
310
375
  },
311
376
  {
312
377
  /**
313
- @memberof Radar
314
- @desc Sets the config method used for the radial spokes, circles, and labels.
315
- @param {Object} *value*
316
- @chainable
317
- */ key: "axisConfig",
378
+ Configuration object for the radial spokes, circles, and labels.
379
+ */ key: "axisConfig",
318
380
  value: function axisConfig(_) {
319
381
  return arguments.length ? (this._axisConfig = assign(this._axisConfig, _), this) : this._axisConfig;
320
382
  }
321
383
  },
322
384
  {
323
385
  /**
324
- @memberof Radar
325
- @desc Defines the value used as axis. If *value* is specified, sets the accessor to the specified metric function. If *value* is not specified, returns the current metric accessor.
326
- @param {Function|String} *value*
327
- @chainable
328
- */ key: "metric",
386
+ Accessor function for the metric value used as each axis.
387
+ */ key: "metric",
329
388
  value: function metric(_) {
330
389
  return arguments.length ? (this._metric = typeof _ === "function" ? _ : accessor(_), this) : this._metric;
331
390
  }
332
391
  },
333
392
  {
334
393
  /**
335
- @memberof Radar
336
- @desc Determines how much pixel spaces to give the outer labels.
337
- @param {Number} [*value* = 100]
338
- @chainable
339
- */ key: "outerPadding",
394
+ Determines how much pixel spaces to give the outer labels.
395
+ */ key: "outerPadding",
340
396
  value: function outerPadding(_) {
341
397
  return arguments.length ? (this._outerPadding = _, this) : this._outerPadding;
342
398
  }
343
399
  },
344
400
  {
345
401
  /**
346
- @memberof Radar
347
- @desc If *value* is specified, sets the value accessor to the specified function or number and returns the current class instance. If *value* is not specified, returns the current value accessor.
348
- @param {Function|String} *value*
349
- @example
402
+ The value accessor used to determine each data point's position along each axis.
403
+
404
+ @example
350
405
  function value(d) {
351
406
  return d.value;
352
407
  }
353
- */ key: "value",
408
+ */ key: "value",
354
409
  value: function value(_) {
355
410
  return arguments.length ? (this._value = typeof _ === "function" ? _ : accessor(_), this) : this._value;
356
411
  }
@@ -359,7 +414,5 @@ function value(d) {
359
414
  return Radar;
360
415
  }(Viz);
361
416
  /**
362
- @class Radar
363
- @extends Viz
364
- @desc Creates a radar visualization based on an array of data.
417
+ Creates a radar visualization based on an array of data.
365
418
  */ export { Radar as default };
@@ -63,6 +63,7 @@ function _inherits(subClass, superClass) {
63
63
  if (superClass) _set_prototype_of(subClass, superClass);
64
64
  }
65
65
  function _instanceof(left, right) {
66
+ "@swc/helpers - instanceof";
66
67
  if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
67
68
  return !!right[Symbol.hasInstance](left);
68
69
  } else {
@@ -103,7 +104,8 @@ function _is_native_reflect_construct() {
103
104
  }
104
105
  import { min } from "d3-array";
105
106
  import { arc } from "d3-shape";
106
- import { assign, elem } from "@d3plus/dom";
107
+ import { colorContrast } from "@d3plus/color";
108
+ import { assign, backgroundColor, elem } from "@d3plus/dom";
107
109
  import { Path } from "../shapes/index.js";
108
110
  import { TextBox } from "../components/index.js";
109
111
  import { accessor, configPrep, constant, getProp } from "../utils/index.js";
@@ -122,9 +124,12 @@ var RadialMatrix = /*#__PURE__*/ function(Viz) {
122
124
  _this._columnConfig = {
123
125
  shapeConfig: {
124
126
  labelConfig: {
125
- fontColor: "#000",
127
+ fontColor: function fontColor() {
128
+ var bg = _this._select ? backgroundColor(_this._select.node()) : "rgb(255, 255, 255)";
129
+ return colorContrast(bg);
130
+ },
126
131
  padding: 5,
127
- textAnchor: function(d) {
132
+ textAnchor: function textAnchor(d) {
128
133
  return [
129
134
  0,
130
135
  180
@@ -133,7 +138,7 @@ var RadialMatrix = /*#__PURE__*/ function(Viz) {
133
138
  3
134
139
  ].includes(d.quadrant) ? "end" : "start";
135
140
  },
136
- verticalAlign: function(d) {
141
+ verticalAlign: function verticalAlign(d) {
137
142
  return [
138
143
  90,
139
144
  270
@@ -173,8 +178,7 @@ var RadialMatrix = /*#__PURE__*/ function(Viz) {
173
178
  _create_class(RadialMatrix, [
174
179
  {
175
180
  /**
176
- @memberof RadialMatrix
177
- @desc Extends the draw behavior of the abstract Viz class.
181
+ Extends the draw behavior of the abstract Viz class.
178
182
  @private
179
183
  */ key: "_draw",
180
184
  value: function _draw(callback) {
@@ -263,7 +267,7 @@ var RadialMatrix = /*#__PURE__*/ function(Viz) {
263
267
  transform: transform
264
268
  }
265
269
  }).node()).config({
266
- id: function(d) {
270
+ id: function id(d) {
267
271
  return _this._ids(d).join("-");
268
272
  },
269
273
  x: 0,
@@ -274,20 +278,17 @@ var RadialMatrix = /*#__PURE__*/ function(Viz) {
274
278
  },
275
279
  {
276
280
  /**
277
- @memberof RadialMatrix
278
- @desc The pixel padding in between each cell.
279
- @param {Number} [*value* = 2]
280
- */ key: "cellPadding",
281
+ The pixel padding in between each cell.
282
+ */ key: "cellPadding",
281
283
  value: function cellPadding(_) {
282
284
  return arguments.length ? (this._cellPadding = _, this) : this._cellPadding;
283
285
  }
284
286
  },
285
287
  {
286
288
  /**
287
- @memberof RadialMatrix
288
- @desc Determines which key in your data should be used for each column in the matrix. Can be either a String that matches a key used in every data point, or an accessor function that receives a data point and it's index in the data array, and is expected to return it's column value.
289
- @param {String|Function} [*value*]
290
- @example
289
+ Determines which key in your data should be used for each column in the matrix. Can be either a String that matches a key used in every data point, or an accessor function that receives a data point and it's index in the data array, and is expected to return it's column value.
290
+
291
+ @example
291
292
  function column(d) {
292
293
  return d.name;
293
294
  }
@@ -298,31 +299,25 @@ function column(d) {
298
299
  },
299
300
  {
300
301
  /**
301
- @memberof RadialMatrix
302
- @desc A pass-through to the underlying [Axis](http://d3plus.org/docs/#Axis) config used for the column labels.
303
- @param {Object} *value*
304
- @chainable
305
- */ key: "columnConfig",
302
+ A pass-through to the underlying [Axis](http://d3plus.org/docs/#Axis) config used for the column labels.
303
+ */ key: "columnConfig",
306
304
  value: function columnConfig(_) {
307
305
  return arguments.length ? (this._columnConfig = assign(this._columnConfig, _), this) : this._columnConfig;
308
306
  }
309
307
  },
310
308
  {
311
309
  /**
312
- @memberof RadialMatrix
313
- @desc A manual list of IDs to be used for columns.
314
- @param {Array} [*value*]
315
- */ key: "columnList",
310
+ A manual list of IDs to be used for rows.
311
+ */ key: "columnList",
316
312
  value: function columnList(_) {
317
313
  return arguments.length ? (this._columnList = _, this) : this._columnList;
318
314
  }
319
315
  },
320
316
  {
321
317
  /**
322
- @memberof RadialMatrix
323
- @desc A sort comparator function that is run on the unique set of column values.
324
- @param {Function} [*value*]
325
- @example
318
+ A sort comparator function that is run on the unique set of column values.
319
+
320
+ @example
326
321
  function column(a, b) {
327
322
  return a.localeCompare(b);
328
323
  }
@@ -333,10 +328,9 @@ function column(a, b) {
333
328
  },
334
329
  {
335
330
  /**
336
- @memberof RadialMatrix
337
- @desc The radius (in pixels) for the inner donut hole of the diagram. Can either be a static Number, or an accessor function that receives the outer radius as it's only argument.
338
- @param {Function|Number} [*value*]
339
- @example
331
+ The radius (in pixels) for the inner donut hole of the diagram. Can either be a static Number, or an accessor function that receives the outer radius as it's only argument.
332
+
333
+ @example
340
334
  function(outerRadius) {
341
335
  return outerRadius / 5;
342
336
  }
@@ -347,10 +341,9 @@ function(outerRadius) {
347
341
  },
348
342
  {
349
343
  /**
350
- @memberof RadialMatrix
351
- @desc Determines which key in your data should be used for each row in the matrix. Can be either a String that matches a key used in every data point, or an accessor function that receives a data point and it's index in the data array, and is expected to return it's row value.
352
- @param {String|Function} [*value*]
353
- @example
344
+ Determines which key in your data should be used for each row in the matrix. Can be either a String that matches a key used in every data point, or an accessor function that receives a data point and it's index in the data array, and is expected to return it's row value.
345
+
346
+ @example
354
347
  function row(d) {
355
348
  return d.name;
356
349
  }
@@ -361,20 +354,17 @@ function row(d) {
361
354
  },
362
355
  {
363
356
  /**
364
- @memberof RadialMatrix
365
- @desc A manual list of IDs to be used for rows.
366
- @param {Array} [*value*]
367
- */ key: "rowList",
357
+ A manual list of IDs to be used for rows.
358
+ */ key: "rowList",
368
359
  value: function rowList(_) {
369
360
  return arguments.length ? (this._rowList = _, this) : this._rowList;
370
361
  }
371
362
  },
372
363
  {
373
364
  /**
374
- @memberof RadialMatrix
375
- @desc A sort comparator function that is run on the unique set of row values.
376
- @param {Function} [*value*]
377
- @example
365
+ A sort comparator function that is run on the unique set of row values.
366
+
367
+ @example
378
368
  function row(a, b) {
379
369
  return a.localeCompare(b);
380
370
  }
@@ -387,7 +377,5 @@ function row(a, b) {
387
377
  return RadialMatrix;
388
378
  }(Viz);
389
379
  /**
390
- @class RadialMatrix
391
- @extends Viz
392
- @desc Creates a radial layout of a rows/columns Matrix of any dataset. See [this example](https://d3plus.org/examples/d3plus-matrix/radial-matrix/) for help getting started using the Matrix class.
380
+ Creates a radial layout of a rows/columns Matrix of any dataset. See [this example](https://d3plus.org/examples/d3plus-matrix/radial-matrix/) for help getting started using the Matrix class.
393
381
  */ export { RadialMatrix as default };