@d3plus/core 3.0.16 → 3.1.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 (167) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +88482 -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 +29 -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 +20126 -18700
  162. package/umd/d3plus-core.full.js.map +1 -1
  163. package/umd/d3plus-core.full.min.js +2919 -5393
  164. package/umd/d3plus-core.js +1919 -4073
  165. package/umd/d3plus-core.js.map +1 -1
  166. package/umd/d3plus-core.min.js +1604 -3936
  167. package/es/src/utils/uuid.js +0 -13
@@ -27,6 +27,19 @@ function _create_class(Constructor, protoProps, staticProps) {
27
27
  if (staticProps) _defineProperties(Constructor, staticProps);
28
28
  return Constructor;
29
29
  }
30
+ function _define_property(obj, key, value) {
31
+ if (key in obj) {
32
+ Object.defineProperty(obj, key, {
33
+ value: value,
34
+ enumerable: true,
35
+ configurable: true,
36
+ writable: true
37
+ });
38
+ } else {
39
+ obj[key] = value;
40
+ }
41
+ return obj;
42
+ }
30
43
  function _get_prototype_of(o) {
31
44
  _get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
32
45
  return o.__proto__ || Object.getPrototypeOf(o);
@@ -73,8 +86,8 @@ function _is_native_reflect_construct() {
73
86
  }
74
87
  import { max, sum } from "d3-array";
75
88
  import { select } from "d3-selection";
76
- import { colorDefaults } from "@d3plus/color";
77
- import { assign, elem, rtl as detectRTL, textWidth } from "@d3plus/dom";
89
+ import { colorContrast } from "@d3plus/color";
90
+ import { assign, backgroundColor, elem, rtl as detectRTL, textWidth } from "@d3plus/dom";
78
91
  import { textWrap } from "@d3plus/text";
79
92
  import { TextBox } from "../components/index.js";
80
93
  import * as shapes from "../shapes/index.js";
@@ -86,7 +99,7 @@ var Legend = /*#__PURE__*/ function(BaseClass) {
86
99
  function Legend() {
87
100
  _class_call_check(this, Legend);
88
101
  var _this;
89
- _this = _call_super(this, Legend);
102
+ _this = _call_super(this, Legend), _define_property(_this, "_titleClass", void 0), _define_property(_this, "_align", void 0), _define_property(_this, "_data", void 0), _define_property(_this, "_direction", void 0), _define_property(_this, "_duration", void 0), _define_property(_this, "_height", void 0), _define_property(_this, "_id", void 0), _define_property(_this, "_label", void 0), _define_property(_this, "_lineData", void 0), _define_property(_this, "_outerBounds", void 0), _define_property(_this, "_padding", void 0), _define_property(_this, "_shape", void 0), _define_property(_this, "_select", void 0), _define_property(_this, "_shapes", void 0), _define_property(_this, "_shapeConfig", void 0), _define_property(_this, "_titleConfig", void 0), _define_property(_this, "_verticalAlign", void 0), _define_property(_this, "_width", void 0), _define_property(_this, "_rtl", void 0), _define_property(_this, "_group", void 0), _define_property(_this, "_titleGroup", void 0), _define_property(_this, "_shapeGroup", void 0), _define_property(_this, "_titleHeight", void 0), _define_property(_this, "_titleWidth", void 0), _define_property(_this, "_title", void 0), _define_property(_this, "_wrapLines", void 0), _define_property(_this, "_wrapRows", void 0);
90
103
  _this._titleClass = new TextBox();
91
104
  _this._align = "center";
92
105
  _this._data = [];
@@ -108,7 +121,7 @@ var Legend = /*#__PURE__*/ function(BaseClass) {
108
121
  _this._shapeConfig = {
109
122
  fill: accessor("color"),
110
123
  height: constant(12),
111
- hitArea: function(dd, i) {
124
+ hitArea: function hitArea(dd, i) {
112
125
  var d = _this._lineData[i], h = max([
113
126
  d.height,
114
127
  d.shapeHeight
@@ -120,7 +133,7 @@ var Legend = /*#__PURE__*/ function(BaseClass) {
120
133
  y: -h / 2
121
134
  };
122
135
  },
123
- labelBounds: function(dd, i) {
136
+ labelBounds: function labelBounds(dd, i) {
124
137
  var d = _this._lineData[i];
125
138
  var x = d.shapeWidth / 2;
126
139
  if (d.shape === "Circle") x -= d.shapeR / 2;
@@ -137,7 +150,10 @@ var Legend = /*#__PURE__*/ function(BaseClass) {
137
150
  };
138
151
  },
139
152
  labelConfig: {
140
- fontColor: constant(colorDefaults.dark),
153
+ fontColor: function fontColor() {
154
+ var bg = _this._select ? backgroundColor(_this._select.node()) : "rgb(255, 255, 255)";
155
+ return colorContrast(bg);
156
+ },
141
157
  fontFamily: _this._titleClass.fontFamily(),
142
158
  fontResize: false,
143
159
  fontSize: constant(10),
@@ -146,7 +162,7 @@ var Legend = /*#__PURE__*/ function(BaseClass) {
146
162
  opacity: 1,
147
163
  r: constant(6),
148
164
  width: constant(12),
149
- x: function(d, i) {
165
+ x: function x(d, i) {
150
166
  var datum = _this._lineData[i];
151
167
  var y = datum.y;
152
168
  var pad = _this._align === "left" || _this._align === "right" && _this._direction === "column" ? 0 : _this._align === "center" ? (_this._outerBounds.width - _this._rowWidth(_this._lineData.filter(function(l) {
@@ -160,7 +176,7 @@ var Legend = /*#__PURE__*/ function(BaseClass) {
160
176
  var rtlMod = _this._rtl ? datum.width + _this._padding : 0;
161
177
  return _this._rowWidth(prevWords) + _this._padding * (prevWords.length ? datum.sentence ? 2 : 1 : 0) + _this._outerBounds.x + datum.shapeWidth / 2 + pad + rtlMod;
162
178
  },
163
- y: function(d, i) {
179
+ y: function y(d, i) {
164
180
  var ld = _this._lineData[i];
165
181
  return ld.y + _this._titleHeight + _this._outerBounds.y + max(_this._lineData.filter(function(l) {
166
182
  return ld.y === l.y;
@@ -176,19 +192,31 @@ var Legend = /*#__PURE__*/ function(BaseClass) {
176
192
  };
177
193
  _this._verticalAlign = "middle";
178
194
  _this._width = 400;
195
+ _this._rtl = false;
196
+ _this._titleHeight = 0;
197
+ _this._titleWidth = 0;
179
198
  return _this;
180
199
  }
181
200
  _create_class(Legend, [
182
201
  {
183
- key: "_fetchConfig",
202
+ /**
203
+ @param key The configuration key.
204
+ @param d The data point.
205
+ @param i The data index.
206
+ @private
207
+ */ key: "_fetchConfig",
184
208
  value: function _fetchConfig(key, d, i) {
185
- var val = this._shapeConfig[key] !== undefined ? this._shapeConfig[key] : this._shapeConfig.labelConfig[key];
209
+ var labelConfig = this._shapeConfig.labelConfig;
210
+ var val = this._shapeConfig[key] !== undefined ? this._shapeConfig[key] : labelConfig === null || labelConfig === void 0 ? void 0 : labelConfig[key];
186
211
  if (!val && key === "lineHeight") return this._fetchConfig("fontSize", d, i) * 1.4;
187
212
  return typeof val === "function" ? val(d, i) : val;
188
213
  }
189
214
  },
190
215
  {
191
- key: "_rowHeight",
216
+ /**
217
+ @param row The legend row data.
218
+ @private
219
+ */ key: "_rowHeight",
192
220
  value: function _rowHeight(row) {
193
221
  return max(row.map(function(d) {
194
222
  return d.height;
@@ -198,7 +226,10 @@ var Legend = /*#__PURE__*/ function(BaseClass) {
198
226
  }
199
227
  },
200
228
  {
201
- key: "_rowWidth",
229
+ /**
230
+ @param row The legend row data.
231
+ @private
232
+ */ key: "_rowWidth",
202
233
  value: function _rowWidth(row) {
203
234
  var _this = this;
204
235
  return sum(row.map(function(d, i) {
@@ -209,11 +240,9 @@ var Legend = /*#__PURE__*/ function(BaseClass) {
209
240
  },
210
241
  {
211
242
  /**
212
- @memberof Legend
213
- @desc Renders the current Legend to the page. If a *callback* is specified, it will be called once the legend is done drawing.
214
- @param {Function} [*callback* = undefined]
215
- @chainable
216
- */ key: "render",
243
+ Renders the current Legend to the page.
244
+ @param callback Optional callback invoked after rendering completes.
245
+ */ key: "render",
217
246
  value: function render(callback) {
218
247
  var _this = this;
219
248
  if (this._select === void 0) this.select(select("body").append("svg").attr("width", "".concat(this._width, "px")).attr("height", "".concat(this._height, "px")).node());
@@ -231,9 +260,11 @@ var Legend = /*#__PURE__*/ function(BaseClass) {
231
260
  this._titleHeight = 0;
232
261
  this._titleWidth = 0;
233
262
  if (this._title) {
234
- var f = this._titleConfig.fontFamily || this._titleClass.fontFamily()(), s = this._titleConfig.fontSize || this._titleClass.fontSize()();
263
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
264
+ var f = this._titleConfig.fontFamily || this._titleClass.fontFamily()(), // eslint-disable-next-line @typescript-eslint/no-explicit-any
265
+ s = this._titleConfig.fontSize || this._titleClass.fontSize()();
235
266
  var lH = this._titleConfig.lineHeight || this._titleClass.lineHeight();
236
- lH = lH ? lH() : s * 1.4;
267
+ lH = typeof lH === "function" ? lH() : lH !== null && lH !== void 0 ? lH : s * 1.4;
237
268
  var res = textWrap().fontFamily(f).fontSize(s).lineHeight(lH).width(this._width).height(this._height)(this._title);
238
269
  this._titleHeight = lH + res.lines.length + this._padding;
239
270
  this._titleWidth = max(res.widths);
@@ -301,7 +332,8 @@ var Legend = /*#__PURE__*/ function(BaseClass) {
301
332
  if (wrappable.length && availableHeight > wrappable[0].height * lines) {
302
333
  var _loop = function(x) {
303
334
  var label = wrappable[x];
304
- var h = label.og.height * lines, w = label.og.width * (1.5 * (1 / lines));
335
+ var og = label.og;
336
+ var h = og.height * lines, w = og.width * (1.5 * (1 / lines));
305
337
  var res = textWrap().fontFamily(label.f).fontSize(label.s).lineHeight(label.lh).width(w).height(h)(label.sentence);
306
338
  if (!res.truncated) {
307
339
  label.width = Math.ceil(max(res.lines.map(function(t) {
@@ -411,14 +443,15 @@ var Legend = /*#__PURE__*/ function(BaseClass) {
411
443
  right: "end"
412
444
  }[this._align]).width(this._width - this._padding * 2).x(this._padding).y(this._outerBounds.y).config(this._titleConfig).render();
413
445
  this._shapes = [];
446
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
414
447
  var baseConfig = configPrep.bind(this)(this._shapeConfig, "legend"), config = {
415
- id: function(d) {
448
+ id: function id(d) {
416
449
  return d.id;
417
450
  },
418
- label: function(d) {
451
+ label: function label(d) {
419
452
  return d.label;
420
453
  },
421
- lineHeight: function(d) {
454
+ lineHeight: function lineHeight(d) {
422
455
  return d.lH;
423
456
  }
424
457
  };
@@ -440,7 +473,8 @@ var Legend = /*#__PURE__*/ function(BaseClass) {
440
473
  "Circle",
441
474
  "Rect"
442
475
  ].forEach(function(Shape) {
443
- _this._shapes.push(new shapes[Shape]().parent(_this).data(data.filter(function(d) {
476
+ _this._shapes.push(// eslint-disable-next-line @typescript-eslint/no-explicit-any
477
+ new shapes[Shape]().parent(_this).data(data.filter(function(d) {
444
478
  return d.shape === Shape;
445
479
  })).duration(_this._duration).labelConfig({
446
480
  padding: 0
@@ -452,11 +486,8 @@ var Legend = /*#__PURE__*/ function(BaseClass) {
452
486
  },
453
487
  {
454
488
  /**
455
- @memberof Legend
456
- @desc If *value* is specified, sets the active method for all shapes to the specified function and returns the current class instance. If *value* is not specified, returns the current active method.
457
- @param {Function} [*value*]
458
- @chainable
459
- */ key: "active",
489
+ The active method for all shapes.
490
+ */ key: "active",
460
491
  value: function active(_) {
461
492
  this._shapes.forEach(function(s) {
462
493
  return s.active(_);
@@ -465,67 +496,39 @@ var Legend = /*#__PURE__*/ function(BaseClass) {
465
496
  }
466
497
  },
467
498
  {
468
- /**
469
- @memberof Legend
470
- @desc If *value* is specified, sets the horizontal alignment to the specified value and returns the current class instance. If *value* is not specified, returns the current horizontal alignment.
471
- @param {String} [*value* = "center"] Supports `"left"` and `"center"` and `"right"`.
472
- @chainable
473
- */ key: "align",
499
+ key: "align",
474
500
  value: function align(_) {
475
501
  return arguments.length ? (this._align = _, this) : this._align;
476
502
  }
477
503
  },
478
504
  {
479
- /**
480
- @memberof Legend
481
- @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. A shape key will be drawn for each object in the array.
482
- @param {Array} [*data* = []]
483
- @chainable
484
- */ key: "data",
505
+ key: "data",
485
506
  value: function data(_) {
486
507
  return arguments.length ? (this._data = _, this) : this._data;
487
508
  }
488
509
  },
489
510
  {
490
- /**
491
- @memberof Legend
492
- @desc Sets the flow of the items inside the legend. If no value is passed, the current flow will be returned.
493
- @param {String} [*value* = "row"]
494
- @chainable
495
- */ key: "direction",
511
+ key: "direction",
496
512
  value: function direction(_) {
497
513
  return arguments.length ? (this._direction = _, this) : this._direction;
498
514
  }
499
515
  },
500
516
  {
501
- /**
502
- @memberof Legend
503
- @desc If *value* is specified, sets the transition duration of the legend and returns the current class instance. If *value* is not specified, returns the current duration.
504
- @param {Number} [*value* = 600]
505
- @chainable
506
- */ key: "duration",
517
+ key: "duration",
507
518
  value: function duration(_) {
508
519
  return arguments.length ? (this._duration = _, this) : this._duration;
509
520
  }
510
521
  },
511
522
  {
512
- /**
513
- @memberof Legend
514
- @desc If *value* is specified, sets the overall height of the legend and returns the current class instance. If *value* is not specified, returns the current height value.
515
- @param {Number} [*value* = 100]
516
- @chainable
517
- */ key: "height",
523
+ key: "height",
518
524
  value: function height(_) {
519
525
  return arguments.length ? (this._height = _, this) : this._height;
520
526
  }
521
527
  },
522
528
  {
523
529
  /**
524
- @memberof Legend
525
- @desc If *value* is specified, sets the hover method for all shapes to the specified function and returns the current class instance. If *value* is not specified, returns the current hover method.
526
- @param {Function} [*value*]
527
- @chainable
528
- */ key: "hover",
530
+ The hover method for all shapes.
531
+ */ key: "hover",
529
532
  value: function hover(_) {
530
533
  this._shapes.forEach(function(s) {
531
534
  return s.hover(_);
@@ -534,131 +537,77 @@ var Legend = /*#__PURE__*/ function(BaseClass) {
534
537
  }
535
538
  },
536
539
  {
537
- /**
538
- @memberof Legend
539
- @desc If *value* is specified, sets the id accessor to the specified function and returns the current class instance. If *value* is not specified, returns the current id accessor.
540
- @param {Function} [*value*]
541
- @chainable
542
- @example
543
- function value(d) {
544
- return d.id;
545
- }
546
- */ key: "id",
540
+ key: "id",
547
541
  value: function id(_) {
548
542
  return arguments.length ? (this._id = _, this) : this._id;
549
543
  }
550
544
  },
551
545
  {
552
- /**
553
- @memberof Legend
554
- @desc If *value* is specified, sets the label accessor to the specified function or string and returns the current class instance. If *value* is not specified, returns the current label accessor, which is the [id](#shape.id) accessor by default.
555
- @param {Function|String} [*value*]
556
- @chainable
557
- */ key: "label",
546
+ key: "label",
558
547
  value: function label(_) {
559
548
  return arguments.length ? (this._label = typeof _ === "function" ? _ : constant(_), this) : this._label;
560
549
  }
561
550
  },
562
551
  {
563
552
  /**
564
- @memberof Legend
565
- @desc If called after the elements have been drawn to DOM, will returns the outer bounds of the legend content.
553
+ Returns the outer bounds of the legend content. Must be called after rendering.
566
554
  @example
567
555
  {"width": 180, "height": 24, "x": 10, "y": 20}
568
- */ key: "outerBounds",
556
+ */ key: "outerBounds",
569
557
  value: function outerBounds() {
570
558
  return this._outerBounds;
571
559
  }
572
560
  },
573
561
  {
574
- /**
575
- @memberof Legend
576
- @desc If *value* is specified, sets the padding between each key to the specified number and returns the current class instance. If *value* is not specified, returns the current padding value.
577
- @param {Number} [*value* = 10]
578
- @chainable
579
- */ key: "padding",
562
+ key: "padding",
580
563
  value: function padding(_) {
581
564
  return arguments.length ? (this._padding = _, this) : this._padding;
582
565
  }
583
566
  },
584
567
  {
585
- /**
586
- @memberof Legend
587
- @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.
588
- @param {String|HTMLElement} [*selector* = d3.select("body").append("svg")]
589
- @chainable
590
- */ key: "select",
568
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
569
+ key: "select",
591
570
  value: function select1(_) {
592
571
  if (arguments.length) {
593
572
  this._select = select(_);
594
- this._rtl = detectRTL(this._select.node());
573
+ this._rtl = detectRTL();
595
574
  return this;
596
575
  }
597
576
  return this._select;
598
577
  }
599
578
  },
600
579
  {
601
- /**
602
- @memberof Legend
603
- @desc If *value* is specified, sets the shape accessor to the specified function or string and returns the current class instance. If *value* is not specified, returns the current shape accessor.
604
- @param {Function|String} [*value* = "Rect"]
605
- @chainable
606
- */ key: "shape",
580
+ key: "shape",
607
581
  value: function shape(_) {
608
582
  return arguments.length ? (this._shape = typeof _ === "function" ? _ : constant(_), this) : this._shape;
609
583
  }
610
584
  },
611
585
  {
612
- /**
613
- @memberof Legend
614
- @desc If *config* is specified, sets the methods that correspond to the key/value pairs for each shape and returns the current class instance. If *config* is not specified, returns the current shape configuration.
615
- @param {Object} [*config* = {}]
616
- @chainable
617
- */ key: "shapeConfig",
586
+ key: "shapeConfig",
618
587
  value: function shapeConfig(_) {
619
588
  return arguments.length ? (this._shapeConfig = assign(this._shapeConfig, _), this) : this._shapeConfig;
620
589
  }
621
590
  },
622
591
  {
623
- /**
624
- @memberof Legend
625
- @desc If *value* is specified, sets the title of the legend and returns the current class instance. If *value* is not specified, returns the current title.
626
- @param {String} [*value*]
627
- @chainable
628
- */ key: "title",
592
+ key: "title",
629
593
  value: function title(_) {
630
594
  return arguments.length ? (this._title = _, this) : this._title;
631
595
  }
632
596
  },
633
597
  {
634
- /**
635
- @memberof Legend
636
- @desc If *value* is specified, sets the title configuration of the legend and returns the current class instance. If *value* is not specified, returns the current title configuration.
637
- @param {Object} [*value*]
638
- @chainable
639
- */ key: "titleConfig",
598
+ key: "titleConfig",
640
599
  value: function titleConfig(_) {
641
600
  return arguments.length ? (this._titleConfig = assign(this._titleConfig, _), this) : this._titleConfig;
642
601
  }
643
602
  },
644
603
  {
645
- /**
646
- @memberof Legend
647
- @desc If *value* is specified, sets the vertical alignment to the specified value and returns the current class instance. If *value* is not specified, returns the current vertical alignment.
648
- @param {String} [*value* = "middle"] Supports `"top"` and `"middle"` and `"bottom"`.
649
- @chainable
650
- */ key: "verticalAlign",
604
+ key: "verticalAlign",
651
605
  value: function verticalAlign(_) {
652
606
  return arguments.length ? (this._verticalAlign = _, this) : this._verticalAlign;
653
607
  }
654
608
  },
655
609
  {
656
- /**
657
- @memberof Legend
658
- @desc If *value* is specified, sets the overall width of the legend and returns the current class instance. If *value* is not specified, returns the current width value.
659
- @param {Number} [*value* = 400]
660
- @chainable
661
- */ key: "width",
610
+ key: "width",
662
611
  value: function width(_) {
663
612
  return arguments.length ? (this._width = _, this) : this._width;
664
613
  }
@@ -667,7 +616,5 @@ function value(d) {
667
616
  return Legend;
668
617
  }(BaseClass);
669
618
  /**
670
- @class Legend
671
- @extends BaseClass
672
- @desc Creates an SVG scale based on an array of data. If *data* is specified, immediately draws based on the specified array and returns the current class instance. If *data* is not specified on instantiation, it can be passed/updated after instantiation using the [data](#shape.data) method.
619
+ Creates an SVG legend based on an array of data.
673
620
  */ export { Legend as default };
@@ -17,20 +17,34 @@ 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 { select } from "d3-selection";
21
34
  import { stylize } from "@d3plus/dom";
22
35
  var Message = /*#__PURE__*/ function() {
23
36
  "use strict";
24
37
  function Message() {
25
38
  _class_call_check(this, Message);
39
+ _define_property(this, "_isVisible", void 0);
40
+ _define_property(this, "mask", void 0);
41
+ _define_property(this, "elem", void 0);
26
42
  this._isVisible = false;
27
43
  }
28
44
  _create_class(Message, [
29
45
  {
30
46
  /**
31
- @memberof Message
32
- @desc Removes the message from the page.
33
- @chainable
47
+ Removes the message from the page.
34
48
  */ key: "exit",
35
49
  value: function exit(elem, duration) {
36
50
  elem.transition().duration(duration).style("opacity", 0).transition().remove();
@@ -39,9 +53,7 @@ var Message = /*#__PURE__*/ function() {
39
53
  },
40
54
  {
41
55
  /**
42
- @memberof Message
43
- @desc Removes the message from the page.
44
- @chainable
56
+ Removes the message from the page.
45
57
  */ key: "hide",
46
58
  value: function hide() {
47
59
  var _ref = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, _ref_duration = _ref.duration, duration = _ref_duration === void 0 ? 600 : _ref_duration, callback = _ref.callback;
@@ -54,11 +66,8 @@ var Message = /*#__PURE__*/ function() {
54
66
  },
55
67
  {
56
68
  /**
57
- @memberof Message
58
- @desc Draws the message given the specified configuration.
59
- @param {Object} [*config*]
60
- @chainable
61
- */ key: "render",
69
+ Draws the message given the specified configuration.
70
+ */ key: "render",
62
71
  value: function render() {
63
72
  var _ref = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, callback = _ref.callback, _ref_container = _ref.container, container = _ref_container === void 0 ? "body" : _ref_container, _ref_duration = _ref.duration, duration = _ref_duration === void 0 ? 600 : _ref_duration, _ref_html = _ref.html, html = _ref_html === void 0 ? "Please Wait" : _ref_html, _ref_mask = _ref.mask, mask = _ref_mask === void 0 ? "rgba(0, 0, 0, 0.05)" : _ref_mask, _ref_style = _ref.style, style = _ref_style === void 0 ? {} : _ref_style;
64
73
  var parent = select(container);
@@ -68,12 +77,12 @@ var Message = /*#__PURE__*/ function() {
68
77
  this.mask = this.mask.enter().append("div").attr("class", "d3plus-Mask").style("opacity", 1).merge(this.mask);
69
78
  this.mask.exit().call(this.exit.bind(this), duration);
70
79
  stylize(this.mask, {
71
- "background-color": String,
72
- "bottom": "0px",
73
- "left": "0px",
74
- "position": "absolute",
75
- "right": "0px",
76
- "top": "0px"
80
+ "background-color": "transparent",
81
+ bottom: "0px",
82
+ left: "0px",
83
+ position: "absolute",
84
+ right: "0px",
85
+ top: "0px"
77
86
  });
78
87
  this.elem = parent.selectAll("div.d3plus-Message").data([
79
88
  html
@@ -89,7 +98,6 @@ var Message = /*#__PURE__*/ function() {
89
98
  return Message;
90
99
  }();
91
100
  /**
92
- @class Message
93
- @desc Displays a message using plain HTML.
101
+ Displays a message using plain HTML.
94
102
  @private
95
103
  */ export { Message as default };