@d3plus/core 3.0.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. package/README.md +6219 -0
  2. package/es/index.js +4 -0
  3. package/es/src/charts/AreaPlot.js +86 -0
  4. package/es/src/charts/BarChart.js +93 -0
  5. package/es/src/charts/BoxWhisker.js +97 -0
  6. package/es/src/charts/BumpChart.js +148 -0
  7. package/es/src/charts/Donut.js +84 -0
  8. package/es/src/charts/Geomap.js +833 -0
  9. package/es/src/charts/LinePlot.js +84 -0
  10. package/es/src/charts/Matrix.js +358 -0
  11. package/es/src/charts/Network.js +787 -0
  12. package/es/src/charts/Pack.js +318 -0
  13. package/es/src/charts/Pie.js +242 -0
  14. package/es/src/charts/Plot.js +2212 -0
  15. package/es/src/charts/Priestley.js +312 -0
  16. package/es/src/charts/Radar.js +365 -0
  17. package/es/src/charts/RadialMatrix.js +393 -0
  18. package/es/src/charts/Rings.js +777 -0
  19. package/es/src/charts/Sankey.js +413 -0
  20. package/es/src/charts/StackedArea.js +80 -0
  21. package/es/src/charts/Tree.js +312 -0
  22. package/es/src/charts/Treemap.js +406 -0
  23. package/es/src/charts/Viz.js +2017 -0
  24. package/es/src/charts/drawSteps/drawAttribution.js +14 -0
  25. package/es/src/charts/drawSteps/drawBack.js +23 -0
  26. package/es/src/charts/drawSteps/drawColorScale.js +69 -0
  27. package/es/src/charts/drawSteps/drawLegend.js +120 -0
  28. package/es/src/charts/drawSteps/drawSubtitle.js +31 -0
  29. package/es/src/charts/drawSteps/drawTimeline.js +80 -0
  30. package/es/src/charts/drawSteps/drawTitle.js +31 -0
  31. package/es/src/charts/drawSteps/drawTotal.js +32 -0
  32. package/es/src/charts/drawSteps/zoomControls.js +254 -0
  33. package/es/src/charts/events/click.legend.js +76 -0
  34. package/es/src/charts/events/click.shape.js +26 -0
  35. package/es/src/charts/events/mouseenter.js +31 -0
  36. package/es/src/charts/events/mouseleave.js +21 -0
  37. package/es/src/charts/events/mousemove.legend.js +64 -0
  38. package/es/src/charts/events/mousemove.shape.js +42 -0
  39. package/es/src/charts/events/touchstart.body.js +7 -0
  40. package/es/src/charts/helpers/matrixData.js +104 -0
  41. package/es/src/charts/helpers/tileAttributions.js +34 -0
  42. package/es/src/charts/index.js +21 -0
  43. package/es/src/charts/plotBuffers/Bar.js +65 -0
  44. package/es/src/charts/plotBuffers/Box.js +60 -0
  45. package/es/src/charts/plotBuffers/Circle.js +39 -0
  46. package/es/src/charts/plotBuffers/Line.js +30 -0
  47. package/es/src/charts/plotBuffers/Rect.js +40 -0
  48. package/es/src/charts/plotBuffers/discreteBuffer.js +24 -0
  49. package/es/src/charts/plotBuffers/numericBuffer.js +111 -0
  50. package/es/src/components/Axis.js +1567 -0
  51. package/es/src/components/AxisBottom.js +77 -0
  52. package/es/src/components/AxisLeft.js +77 -0
  53. package/es/src/components/AxisRight.js +77 -0
  54. package/es/src/components/AxisTop.js +77 -0
  55. package/es/src/components/ColorScale.js +958 -0
  56. package/es/src/components/Legend.js +673 -0
  57. package/es/src/components/Message.js +95 -0
  58. package/es/src/components/TextBox.js +752 -0
  59. package/es/src/components/Timeline.js +760 -0
  60. package/es/src/components/Tooltip.js +726 -0
  61. package/es/src/components/index.js +11 -0
  62. package/es/src/shapes/Area.js +361 -0
  63. package/es/src/shapes/Bar.js +342 -0
  64. package/es/src/shapes/Box.js +482 -0
  65. package/es/src/shapes/Circle.js +201 -0
  66. package/es/src/shapes/Image.js +255 -0
  67. package/es/src/shapes/Line.js +289 -0
  68. package/es/src/shapes/Path.js +186 -0
  69. package/es/src/shapes/Rect.js +215 -0
  70. package/es/src/shapes/Shape.js +1156 -0
  71. package/es/src/shapes/Whisker.js +330 -0
  72. package/es/src/shapes/index.js +10 -0
  73. package/es/src/utils/BaseClass.js +204 -0
  74. package/es/src/utils/RESET.js +4 -0
  75. package/es/src/utils/accessor.js +19 -0
  76. package/es/src/utils/configPrep.js +76 -0
  77. package/es/src/utils/constant.js +15 -0
  78. package/es/src/utils/getProp.js +9 -0
  79. package/es/src/utils/index.js +7 -0
  80. package/es/src/utils/uuid.js +13 -0
  81. package/package.json +68 -0
  82. package/umd/d3plus-core.full.js +56459 -0
  83. package/umd/d3plus-core.full.js.map +1 -0
  84. package/umd/d3plus-core.full.min.js +7241 -0
  85. package/umd/d3plus-core.js +14422 -0
  86. package/umd/d3plus-core.js.map +1 -0
  87. package/umd/d3plus-core.min.js +4564 -0
@@ -0,0 +1,1156 @@
1
+ function _assert_this_initialized(self) {
2
+ if (self === void 0) {
3
+ throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
4
+ }
5
+ return self;
6
+ }
7
+ function _call_super(_this, derived, args) {
8
+ derived = _get_prototype_of(derived);
9
+ return _possible_constructor_return(_this, _is_native_reflect_construct() ? Reflect.construct(derived, args || [], _get_prototype_of(_this).constructor) : derived.apply(_this, args));
10
+ }
11
+ function _class_call_check(instance, Constructor) {
12
+ if (!(instance instanceof Constructor)) {
13
+ throw new TypeError("Cannot call a class as a function");
14
+ }
15
+ }
16
+ function _defineProperties(target, props) {
17
+ for(var i = 0; i < props.length; i++){
18
+ var descriptor = props[i];
19
+ descriptor.enumerable = descriptor.enumerable || false;
20
+ descriptor.configurable = true;
21
+ if ("value" in descriptor) descriptor.writable = true;
22
+ Object.defineProperty(target, descriptor.key, descriptor);
23
+ }
24
+ }
25
+ function _create_class(Constructor, protoProps, staticProps) {
26
+ if (protoProps) _defineProperties(Constructor.prototype, protoProps);
27
+ if (staticProps) _defineProperties(Constructor, staticProps);
28
+ return Constructor;
29
+ }
30
+ function _get_prototype_of(o) {
31
+ _get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
32
+ return o.__proto__ || Object.getPrototypeOf(o);
33
+ };
34
+ return _get_prototype_of(o);
35
+ }
36
+ function _inherits(subClass, superClass) {
37
+ if (typeof superClass !== "function" && superClass !== null) {
38
+ throw new TypeError("Super expression must either be null or a function");
39
+ }
40
+ subClass.prototype = Object.create(superClass && superClass.prototype, {
41
+ constructor: {
42
+ value: subClass,
43
+ writable: true,
44
+ configurable: true
45
+ }
46
+ });
47
+ if (superClass) _set_prototype_of(subClass, superClass);
48
+ }
49
+ function _instanceof(left, right) {
50
+ if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
51
+ return !!right[Symbol.hasInstance](left);
52
+ } else {
53
+ return left instanceof right;
54
+ }
55
+ }
56
+ function _possible_constructor_return(self, call) {
57
+ if (call && (_type_of(call) === "object" || typeof call === "function")) {
58
+ return call;
59
+ }
60
+ return _assert_this_initialized(self);
61
+ }
62
+ function _set_prototype_of(o, p) {
63
+ _set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
64
+ o.__proto__ = p;
65
+ return o;
66
+ };
67
+ return _set_prototype_of(o, p);
68
+ }
69
+ function _type_of(obj) {
70
+ "@swc/helpers - typeof";
71
+ return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
72
+ }
73
+ function _is_native_reflect_construct() {
74
+ try {
75
+ var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
76
+ } catch (_) {}
77
+ return (_is_native_reflect_construct = function() {
78
+ return !!result;
79
+ })();
80
+ }
81
+ import { min } from "d3-array";
82
+ import { color } from "d3-color";
83
+ import { pointer, select, selectAll } from "d3-selection";
84
+ import * as paths from "d3-shape";
85
+ import { transition } from "d3-transition";
86
+ import textures from "textures";
87
+ import { colorContrast } from "@d3plus/color";
88
+ import { unique } from "@d3plus/data";
89
+ import { assign, attrize, elem, isObject } from "@d3plus/dom";
90
+ import { pointDistance } from "@d3plus/math";
91
+ import { strip } from "@d3plus/text";
92
+ import { TextBox } from "../components/index.js";
93
+ import { accessor, BaseClass, configPrep, constant } from "../utils/index.js";
94
+ import Image from "./Image.js";
95
+ var Shape = /*#__PURE__*/ function(BaseClass) {
96
+ "use strict";
97
+ _inherits(Shape, BaseClass);
98
+ function Shape() {
99
+ var tagName = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "g";
100
+ _class_call_check(this, Shape);
101
+ var _this;
102
+ _this = _call_super(this, Shape);
103
+ _this._activeOpacity = 0.25;
104
+ _this._activeStyle = {
105
+ "stroke": function(d, i) {
106
+ var c = _this._fill(d, i);
107
+ if ([
108
+ "transparent",
109
+ "none"
110
+ ].includes(c)) c = _this._stroke(d, i);
111
+ return color(c).darker(1);
112
+ },
113
+ "stroke-width": function(d, i) {
114
+ var s = _this._strokeWidth(d, i) || 1;
115
+ return s * 3;
116
+ }
117
+ };
118
+ _this._ariaLabel = constant("");
119
+ _this._backgroundImage = constant(false);
120
+ _this._backgroundImageClass = new Image();
121
+ _this._data = [];
122
+ _this._duration = 600;
123
+ _this._fill = constant("black");
124
+ _this._fillOpacity = constant(1);
125
+ _this._hoverOpacity = 0.5;
126
+ _this._hoverStyle = {
127
+ "stroke": function(d, i) {
128
+ var c = _this._fill(d, i);
129
+ if ([
130
+ "transparent",
131
+ "none"
132
+ ].includes(c)) c = _this._stroke(d, i);
133
+ return color(c).darker(0.5);
134
+ },
135
+ "stroke-width": function(d, i) {
136
+ var s = _this._strokeWidth(d, i) || 1;
137
+ return s * 2;
138
+ }
139
+ };
140
+ _this._id = function(d, i) {
141
+ return d.id !== void 0 ? d.id : i;
142
+ };
143
+ _this._label = constant(false);
144
+ _this._labelClass = new TextBox();
145
+ _this._labelConfig = {
146
+ fontColor: function(d, i) {
147
+ return colorContrast(_this._fill(d, i));
148
+ },
149
+ fontSize: 12,
150
+ padding: 5
151
+ };
152
+ _this._name = "Shape";
153
+ _this._opacity = constant(1);
154
+ _this._pointerEvents = constant("visiblePainted");
155
+ _this._role = constant("presentation");
156
+ _this._rotate = constant(0);
157
+ _this._rx = constant(0);
158
+ _this._ry = constant(0);
159
+ _this._scale = constant(1);
160
+ _this._shapeRendering = constant("geometricPrecision");
161
+ _this._stroke = function(d, i) {
162
+ return color(_this._fill(d, i)).darker(1).formatHex();
163
+ };
164
+ _this._strokeDasharray = constant("0");
165
+ _this._strokeLinecap = constant("butt");
166
+ _this._strokeOpacity = constant(1);
167
+ _this._strokeWidth = constant(0);
168
+ _this._tagName = tagName;
169
+ _this._textAnchor = constant("start");
170
+ _this._texture = constant(false);
171
+ _this._textureDefault = {};
172
+ _this._textureDefs = {};
173
+ _this._vectorEffect = constant("non-scaling-stroke");
174
+ _this._verticalAlign = constant("top");
175
+ _this._x = accessor("x", 0);
176
+ _this._y = accessor("y", 0);
177
+ return _this;
178
+ }
179
+ _create_class(Shape, [
180
+ {
181
+ /**
182
+ @memberof Shape
183
+ @desc Given a specific data point and index, returns the aesthetic properties of the shape.
184
+ @param {Object} *data point*
185
+ @param {Number} *index*
186
+ @private
187
+ */ key: "_aes",
188
+ value: function _aes() {
189
+ return {};
190
+ }
191
+ },
192
+ {
193
+ /**
194
+ @memberof Shape
195
+ @desc Adds event listeners to each shape group or hit area.
196
+ @param {D3Selection} *update* The update cycle of the data binding.
197
+ @private
198
+ */ key: "_applyEvents",
199
+ value: function _applyEvents(handler) {
200
+ var _loop = function(e) {
201
+ handler.on(events[e], function(event, d, i) {
202
+ if (!_this._on[events[e]]) return;
203
+ if (d.i !== void 0) i = d.i;
204
+ if (d.nested && d.values) {
205
+ var calcPoint = function(d, i) {
206
+ if (_this._discrete === "x") return [
207
+ _this._x(d, i),
208
+ cursor[1]
209
+ ];
210
+ else if (_this._discrete === "y") return [
211
+ cursor[0],
212
+ _this._y(d, i)
213
+ ];
214
+ else return [
215
+ _this._x(d, i),
216
+ _this._y(d, i)
217
+ ];
218
+ };
219
+ var cursor = pointer(event, _this._select.node()), values = d.values.map(function(d) {
220
+ return pointDistance(cursor, calcPoint(d, i));
221
+ });
222
+ i = values.indexOf(min(values));
223
+ d = d.values[i];
224
+ }
225
+ _this._on[events[e]].bind(_this)(d, i, undefined, event);
226
+ });
227
+ };
228
+ var _this = this;
229
+ var events = Object.keys(this._on);
230
+ for(var e = 0; e < events.length; e++)_loop(e);
231
+ }
232
+ },
233
+ {
234
+ /**
235
+ @memberof Shape
236
+ @desc Provides the updated styling to the given shape elements.
237
+ @param {HTMLElement} *elem*
238
+ @param {Object} *style*
239
+ @private
240
+ */ key: "_updateStyle",
241
+ value: function _updateStyle(elem, style) {
242
+ var that = this;
243
+ if (elem.size() && elem.node().tagName === "g") elem = elem.selectAll("*");
244
+ /**
245
+ @desc Determines whether a shape is a nested collection of data points, and uses the appropriate data and index for the given function context.
246
+ @param {Object} *d* data point
247
+ @param {Number} *i* index
248
+ @private
249
+ */ function styleLogic(d, i) {
250
+ return typeof this !== "function" ? this : d.nested && d.key && d.values ? this(d.values[0], that._data.indexOf(d.values[0])) : this(d, i);
251
+ }
252
+ var styleObject = {};
253
+ for(var key in style){
254
+ if (({}).hasOwnProperty.call(style, key)) {
255
+ styleObject[key] = styleLogic.bind(style[key]);
256
+ }
257
+ }
258
+ elem.transition().duration(0).call(attrize, styleObject);
259
+ }
260
+ },
261
+ {
262
+ /**
263
+ @memberof Shape
264
+ @desc Provides the default styling to the shape elements.
265
+ @param {HTMLElement} *elem*
266
+ @private
267
+ */ key: "_applyStyle",
268
+ value: function _applyStyle(elem) {
269
+ var _this = this;
270
+ var that = this;
271
+ if (elem.size() && elem.node().tagName === "g") elem = elem.selectAll("*");
272
+ /**
273
+ @desc Determines whether a shape is a nested collection of data points, and uses the appropriate data and index for the given function context.
274
+ @param {Object} *d* data point
275
+ @param {Number} *i* index
276
+ @private
277
+ */ function styleLogic(d, i) {
278
+ return typeof this !== "function" ? this : d.nested && d.key && d.values ? this(d.values[0], that._data.indexOf(d.values[0])) : this(d, i);
279
+ }
280
+ elem.attr("fill", function(d, i) {
281
+ var texture = _this._getTextureKey.bind(_this)(d, i);
282
+ return texture ? _this._textureDefs[texture].url() : styleLogic.bind(_this._fill)(d, i);
283
+ }).attr("fill-opacity", styleLogic.bind(this._fillOpacity)).attr("rx", styleLogic.bind(this._rx)).attr("ry", styleLogic.bind(this._ry)).attr("stroke", styleLogic.bind(this._stroke)).attr("stroke-dasharray", styleLogic.bind(this._strokeDasharray)).attr("stroke-linecap", styleLogic.bind(this._strokeLinecap)).attr("stroke-opacity", styleLogic.bind(this._strokeOpacity)).attr("stroke-width", styleLogic.bind(this._strokeWidth)).attr("vector-effect", styleLogic.bind(this._vectorEffect));
284
+ }
285
+ },
286
+ {
287
+ /**
288
+ @memberof Shape
289
+ @desc Calculates the transform for the group elements.
290
+ @param {HTMLElement} *elem*
291
+ @private
292
+ */ key: "_applyTransform",
293
+ value: function _applyTransform(elem) {
294
+ var _this = this;
295
+ elem.attr("transform", function(d, i) {
296
+ return "\n translate(".concat(d.__d3plusShape__ ? d.translate ? d.translate : "".concat(_this._x(d.data, d.i), ",").concat(_this._y(d.data, d.i)) : "".concat(_this._x(d, i), ",").concat(_this._y(d, i)), ")\n scale(").concat(d.__d3plusShape__ ? d.scale || _this._scale(d.data, d.i) : _this._scale(d, i), ")\n rotate(").concat(d.__d3plusShape__ ? d.rotate ? d.rotate : _this._rotate(d.data || d, d.i) : _this._rotate(d.data || d, d.i), ")");
297
+ });
298
+ }
299
+ },
300
+ {
301
+ /**
302
+ @memberof Shape
303
+ @desc Returns a full JSON string of the texture config for a given data point.
304
+ @param {Object} *d*
305
+ @param {Number} *i*
306
+ @private
307
+ */ key: "_getTextureKey",
308
+ value: function _getTextureKey(d, i) {
309
+ var _this = this;
310
+ var texture = this._texture(d, i);
311
+ if (!texture) return false;
312
+ /**
313
+ @desc Determines whether a shape is a nested collection of data points, and uses the appropriate data and index for the given function context.
314
+ @private
315
+ */ var styleLogic = function(_) {
316
+ return typeof _ !== "function" ? _ : d.nested && d.key && d.values ? _(d.values[0], _this._data.indexOf(d.values[0])) : _(d, i);
317
+ };
318
+ var fallback = this._textureDefault;
319
+ if (!isObject(texture)) texture = {
320
+ texture: texture
321
+ };
322
+ if (!texture.background) texture.background = styleLogic(this._fill);
323
+ if (!texture.stroke && !fallback.stroke) texture.stroke = styleLogic(this._stroke);
324
+ var paths = [
325
+ "squares",
326
+ "nylon",
327
+ "waves",
328
+ "woven",
329
+ "crosses",
330
+ "caps",
331
+ "hexagons"
332
+ ];
333
+ if (paths.includes(texture.texture) || typeof texture.texture === "function") {
334
+ texture.d = texture.texture;
335
+ texture.texture = "paths";
336
+ } else if (texture.texture === "grid") {
337
+ if (!texture.orientation && !fallback.orientation) texture.orientation = [
338
+ "vertical",
339
+ "horizontal"
340
+ ];
341
+ texture.texture = "lines";
342
+ }
343
+ if (!texture.fill && texture.texture !== "paths") texture.fill = texture.stroke;
344
+ var retObj = assign({}, fallback, texture);
345
+ if (typeof retObj.d === "function") {
346
+ retObj.d = retObj.d(retObj.size || 20);
347
+ }
348
+ return JSON.stringify(retObj);
349
+ }
350
+ },
351
+ {
352
+ /**
353
+ @memberof Shape
354
+ @desc Checks for nested data and uses the appropriate variables for accessor functions.
355
+ @param {HTMLElement} *elem*
356
+ @private
357
+ */ key: "_nestWrapper",
358
+ value: function _nestWrapper(method) {
359
+ return function(d, i) {
360
+ return method(d.__d3plusShape__ ? d.data : d, d.__d3plusShape__ ? d.i : i);
361
+ };
362
+ }
363
+ },
364
+ {
365
+ /**
366
+ @memberof Shape
367
+ @desc Modifies existing shapes to show active status.
368
+ @private
369
+ */ key: "_renderActive",
370
+ value: function _renderActive() {
371
+ var that = this;
372
+ this._group.selectAll(".d3plus-Shape, .d3plus-Image, .d3plus-textBox").each(function(d, i) {
373
+ if (!d) d = {};
374
+ if (!d.parentNode) d.parentNode = this.parentNode;
375
+ var parent = d.parentNode;
376
+ if (select(this).classed("d3plus-textBox")) d = d.data;
377
+ if (d.__d3plusShape__ || d.__d3plus__) {
378
+ while(d && (d.__d3plusShape__ || d.__d3plus__)){
379
+ i = d.i;
380
+ d = d.data;
381
+ }
382
+ } else i = that._data.indexOf(d);
383
+ var group = !that._active || typeof that._active !== "function" || !that._active(d, i) ? parent : that._activeGroup.node();
384
+ if (group !== this.parentNode) {
385
+ group.appendChild(this);
386
+ if (this.className.baseVal.includes("d3plus-Shape")) {
387
+ if (parent === group) select(this).call(that._applyStyle.bind(that));
388
+ else select(this).call(that._updateStyle.bind(that, select(this), that._activeStyle));
389
+ }
390
+ }
391
+ });
392
+ // this._renderImage();
393
+ // this._renderLabels();
394
+ this._group.selectAll("g.d3plus-".concat(this._name, "-shape, g.d3plus-").concat(this._name, "-image, g.d3plus-").concat(this._name, "-text")).attr("opacity", this._hover ? this._hoverOpacity : this._active ? this._activeOpacity : 1);
395
+ }
396
+ },
397
+ {
398
+ /**
399
+ @memberof Shape
400
+ @desc Modifies existing shapes to show hover status.
401
+ @private
402
+ */ key: "_renderHover",
403
+ value: function _renderHover() {
404
+ var that = this;
405
+ this._group.selectAll("g.d3plus-".concat(this._name, "-shape, g.d3plus-").concat(this._name, "-image, g.d3plus-").concat(this._name, "-text, g.d3plus-").concat(this._name, "-hover")).selectAll(".d3plus-Shape, .d3plus-Image, .d3plus-textBox").each(function(d, i) {
406
+ if (!d) d = {};
407
+ if (!d.parentNode) d.parentNode = this.parentNode;
408
+ var parent = d.parentNode;
409
+ if (select(this).classed("d3plus-textBox")) d = d.data;
410
+ if (d.__d3plusShape__ || d.__d3plus__) {
411
+ while(d && (d.__d3plusShape__ || d.__d3plus__)){
412
+ i = d.i;
413
+ d = d.data;
414
+ }
415
+ } else i = that._data.indexOf(d);
416
+ var group = !that._hover || typeof that._hover !== "function" || !that._hover(d, i) ? parent : that._hoverGroup.node();
417
+ if (group !== this.parentNode) group.appendChild(this);
418
+ if (this.className.baseVal.includes("d3plus-Shape")) {
419
+ if (parent === group) select(this).call(that._applyStyle.bind(that));
420
+ else select(this).call(that._updateStyle.bind(that, select(this), that._hoverStyle));
421
+ }
422
+ });
423
+ // this._renderImage();
424
+ // this._renderLabels();
425
+ this._group.selectAll("g.d3plus-".concat(this._name, "-shape, g.d3plus-").concat(this._name, "-image, g.d3plus-").concat(this._name, "-text")).attr("opacity", this._hover ? this._hoverOpacity : this._active ? this._activeOpacity : 1);
426
+ }
427
+ },
428
+ {
429
+ /**
430
+ @memberof Shape
431
+ @desc Adds background image to each shape group.
432
+ @private
433
+ */ key: "_renderImage",
434
+ value: function _renderImage() {
435
+ var _this = this;
436
+ var imageData = [];
437
+ this._update.merge(this._enter).data().forEach(function(datum, i) {
438
+ var aes = _this._aes(datum, i);
439
+ if (aes.r || aes.width && aes.height) {
440
+ var d = datum;
441
+ if (datum.nested && datum.key && datum.values) {
442
+ d = datum.values[0];
443
+ i = _this._data.indexOf(d);
444
+ }
445
+ var height = aes.r ? aes.r * 2 : aes.height, url = _this._backgroundImage(d, i), width = aes.r ? aes.r * 2 : aes.width;
446
+ if (url) {
447
+ var x = d.__d3plusShape__ ? d.translate ? d.translate[0] : _this._x(d.data, d.i) : _this._x(d, i), y = d.__d3plusShape__ ? d.translate ? d.translate[1] : _this._y(d.data, d.i) : _this._y(d, i);
448
+ if (aes.x) x += aes.x;
449
+ if (aes.y) y += aes.y;
450
+ if (d.__d3plusShape__) {
451
+ d = d.data;
452
+ i = d.i;
453
+ }
454
+ imageData.push({
455
+ __d3plus__: true,
456
+ data: d,
457
+ height: height,
458
+ i: i,
459
+ id: _this._id(d, i),
460
+ url: url,
461
+ width: width,
462
+ x: x + -width / 2,
463
+ y: y + -height / 2
464
+ });
465
+ }
466
+ }
467
+ });
468
+ this._backgroundImageClass.data(imageData).duration(this._duration).opacity(this._nestWrapper(this._opacity)).pointerEvents("none").select(elem("g.d3plus-".concat(this._name, "-image"), {
469
+ parent: this._group,
470
+ update: {
471
+ opacity: this._active ? this._activeOpacity : 1
472
+ }
473
+ }).node()).render();
474
+ }
475
+ },
476
+ {
477
+ /**
478
+ @memberof Shape
479
+ @desc Adds labels to each shape group.
480
+ @private
481
+ */ key: "_renderLabels",
482
+ value: function _renderLabels() {
483
+ var _this = this;
484
+ var labelData = [];
485
+ this._update.merge(this._enter).data().forEach(function(datum, i) {
486
+ var d = datum;
487
+ if (datum.nested && datum.key && datum.values) {
488
+ d = datum.values[0];
489
+ i = _this._data.indexOf(d);
490
+ }
491
+ var labels = _this._label(d, i);
492
+ if (_this._labelBounds && labels !== false && labels !== undefined && labels !== null) {
493
+ var bounds = _this._labelBounds.bind(_this)(d, i, _this._aes(datum, i));
494
+ if (bounds) {
495
+ if (labels.constructor !== Array) labels = [
496
+ labels
497
+ ];
498
+ var x = d.__d3plusShape__ ? d.translate ? d.translate[0] : _this._x(d.data, d.i) : _this._x(d, i), y = d.__d3plusShape__ ? d.translate ? d.translate[1] : _this._y(d.data, d.i) : _this._y(d, i);
499
+ if (d.__d3plusShape__) {
500
+ d = d.data;
501
+ i = d.i;
502
+ }
503
+ for(var l = 0; l < labels.length; l++){
504
+ var b = bounds.constructor === Array ? bounds[l] : Object.assign({}, bounds);
505
+ var rotate = _this._rotate(d, i);
506
+ var r = d.labelConfig && d.labelConfig.rotate ? d.labelConfig.rotate : bounds.angle !== undefined ? bounds.angle : 0;
507
+ r += rotate;
508
+ var rotateAnchor = rotate !== 0 ? [
509
+ b.x * -1 || 0,
510
+ b.y * -1 || 0
511
+ ] : [
512
+ b.width / 2,
513
+ b.height / 2
514
+ ];
515
+ labelData.push({
516
+ __d3plus__: true,
517
+ data: d,
518
+ height: b.height,
519
+ l: l,
520
+ id: "".concat(_this._id(d, i), "_").concat(l),
521
+ r: r,
522
+ rotateAnchor: rotateAnchor,
523
+ text: labels[l],
524
+ width: b.width,
525
+ x: x + b.x,
526
+ y: y + b.y
527
+ });
528
+ }
529
+ }
530
+ }
531
+ });
532
+ this._labelClass.data(labelData).duration(this._duration).fontOpacity(this._nestWrapper(this._opacity)).pointerEvents("none").rotate(function(d) {
533
+ return d.__d3plus__ ? d.r : d.data.r;
534
+ }).rotateAnchor(function(d) {
535
+ return d.__d3plus__ ? d.rotateAnchor : d.data.rotateAnchor;
536
+ }).select(elem("g.d3plus-".concat(this._name, "-text"), {
537
+ parent: this._group,
538
+ update: {
539
+ opacity: this._active ? this._activeOpacity : 1
540
+ }
541
+ }).node()).config(configPrep.bind(this)(this._labelConfig)).render();
542
+ }
543
+ },
544
+ {
545
+ /**
546
+ @memberof Shape
547
+ @desc Renders the current Shape to the page. If a *callback* is specified, it will be called once the shapes are done drawing.
548
+ @param {Function} [*callback*]
549
+ @chainable
550
+ */ key: "render",
551
+ value: function render(callback) {
552
+ var _this = this;
553
+ if (this._select === void 0) {
554
+ this.select(select("body").append("svg").style("width", "".concat(window.innerWidth, "px")).style("height", "".concat(window.innerHeight, "px")).style("display", "block").node());
555
+ }
556
+ this._transition = transition(this._uuid).duration(this._duration);
557
+ var data = this._data, key = this._id;
558
+ if (this._dataFilter) {
559
+ data = this._dataFilter(data);
560
+ if (data.key) key = data.key;
561
+ }
562
+ if (this._sort) {
563
+ data = data.sort(function(a, b) {
564
+ while(a.__d3plusShape__ || a.__d3plus__)a = a.data;
565
+ while(b.__d3plusShape__ || b.__d3plus__)b = b.data;
566
+ return _this._sort(a, b);
567
+ });
568
+ }
569
+ var textureSet = unique(data.map(this._getTextureKey.bind(this))).filter(Boolean);
570
+ var existingTextureDefs = Object.keys(this._textureDefs);
571
+ existingTextureDefs.forEach(function(key) {
572
+ if (!textureSet.includes(key)) {
573
+ select(_this._select.select("pattern#".concat(_this._textureDefs[key].id())).node().parentNode).remove();
574
+ delete _this._textureDefs[key];
575
+ }
576
+ });
577
+ textureSet.forEach(function(key) {
578
+ if (!existingTextureDefs.includes(key)) {
579
+ var _loop = function(k) {
580
+ if (({}).hasOwnProperty.call(t, k) && k in t) {
581
+ if (k === "d") t[k](function() {
582
+ return config[k];
583
+ });
584
+ else _instanceof(config[k], Array) ? t[k].apply(null, config[k]) : t[k](config[k]);
585
+ }
586
+ };
587
+ var config = JSON.parse(key);
588
+ var textureClass = config.texture;
589
+ delete config.texture;
590
+ var t = textures[textureClass]();
591
+ for(var k in config)_loop(k);
592
+ _this._select.call(t);
593
+ _this._textureDefs[key] = t;
594
+ }
595
+ });
596
+ selectAll("g.d3plus-".concat(this._name, "-hover > *, g.d3plus-").concat(this._name, "-active > *")).each(function(d) {
597
+ if (d && d.parentNode) d.parentNode.appendChild(this);
598
+ else this.parentNode.removeChild(this);
599
+ });
600
+ // Makes the update state of the group selection accessible.
601
+ this._group = elem("g.d3plus-".concat(this._name, "-group"), {
602
+ parent: this._select
603
+ });
604
+ var update = this._update = elem("g.d3plus-".concat(this._name, "-shape"), {
605
+ parent: this._group,
606
+ update: {
607
+ opacity: this._active ? this._activeOpacity : 1
608
+ }
609
+ }).selectAll(".d3plus-".concat(this._name)).data(data, key);
610
+ // Orders and transforms the updating Shapes.
611
+ update.order();
612
+ if (this._duration) {
613
+ update.transition(this._transition).call(this._applyTransform.bind(this));
614
+ } else {
615
+ update.call(this._applyTransform.bind(this));
616
+ }
617
+ // Makes the enter state of the group selection accessible.
618
+ var enter = this._enter = update.enter().append(this._tagName).attr("class", function(d, i) {
619
+ return "d3plus-Shape d3plus-".concat(_this._name, " d3plus-id-").concat(strip(_this._nestWrapper(_this._id)(d, i)));
620
+ }).call(this._applyTransform.bind(this)).attr("aria-label", this._ariaLabel).attr("role", this._role).attr("opacity", this._nestWrapper(this._opacity));
621
+ var enterUpdate = enter.merge(update);
622
+ var enterUpdateRender = enterUpdate.attr("shape-rendering", this._nestWrapper(this._shapeRendering));
623
+ if (this._duration) {
624
+ enterUpdateRender = enterUpdateRender.attr("pointer-events", "none").transition(this._transition).transition().delay(100).attr("pointer-events", this._pointerEvents);
625
+ }
626
+ enterUpdateRender.attr("opacity", this._nestWrapper(this._opacity));
627
+ // Makes the exit state of the group selection accessible.
628
+ var exit = this._exit = update.exit();
629
+ if (this._duration) exit.transition().delay(this._duration).remove();
630
+ else exit.remove();
631
+ this._renderImage();
632
+ this._renderLabels();
633
+ this._hoverGroup = elem("g.d3plus-".concat(this._name, "-hover"), {
634
+ parent: this._group
635
+ });
636
+ this._activeGroup = elem("g.d3plus-".concat(this._name, "-active"), {
637
+ parent: this._group
638
+ });
639
+ var hitAreas = this._group.selectAll(".d3plus-HitArea").data(this._hitArea && Object.keys(this._on).length ? data : [], key);
640
+ hitAreas.order().call(this._applyTransform.bind(this));
641
+ var isLine = this._name === "Line";
642
+ if (isLine) {
643
+ var curve = this._curve.bind(this)(this.config());
644
+ isLine && this._path.curve(paths["curve".concat(curve.charAt(0).toUpperCase()).concat(curve.slice(1))]).defined(this._defined).x(this._x).y(this._y);
645
+ }
646
+ var hitEnter = hitAreas.enter().append(isLine ? "path" : "rect").attr("class", function(d, i) {
647
+ return "d3plus-HitArea d3plus-id-".concat(strip(_this._nestWrapper(_this._id)(d, i)));
648
+ }).attr("fill", "black").attr("stroke", "black").attr("pointer-events", "painted").attr("opacity", 0).call(this._applyTransform.bind(this));
649
+ var that = this;
650
+ var hitUpdates = hitAreas.merge(hitEnter).each(function(d) {
651
+ var i = that._data.indexOf(d);
652
+ var h = that._hitArea(d, i, that._aes(d, i));
653
+ return h && !(that._name === "Line" && parseFloat(that._strokeWidth(d, i)) > 10) ? select(this).call(attrize, h) : select(this).remove();
654
+ });
655
+ hitAreas.exit().remove();
656
+ this._applyEvents(this._hitArea ? hitUpdates : enterUpdate);
657
+ setTimeout(function() {
658
+ if (_this._active) _this._renderActive();
659
+ else if (_this._hover) _this._renderHover();
660
+ if (callback) callback();
661
+ }, this._duration + 100);
662
+ return this;
663
+ }
664
+ },
665
+ {
666
+ /**
667
+ @memberof Shape
668
+ @desc If *value* is specified, sets the highlight accessor to the specified function and returns the current class instance.
669
+ @param {Function} [*value*]
670
+ @chainable
671
+ */ key: "active",
672
+ value: function active(_) {
673
+ if (!arguments.length || _ === undefined) return this._active;
674
+ this._active = _;
675
+ if (this._group) {
676
+ // this._renderImage();
677
+ // this._renderLabels();
678
+ this._renderActive();
679
+ }
680
+ return this;
681
+ }
682
+ },
683
+ {
684
+ /**
685
+ @memberof Shape
686
+ @desc When shapes are active, this is the opacity of any shape that is not active.
687
+ @param {Number} *value* = 0.25
688
+ @chainable
689
+ */ key: "activeOpacity",
690
+ value: function activeOpacity(_) {
691
+ return arguments.length ? (this._activeOpacity = _, this) : this._activeOpacity;
692
+ }
693
+ },
694
+ {
695
+ /**
696
+ @memberof Shape
697
+ @desc The style to apply to active shapes.
698
+ @param {Object} *value*
699
+ @chainable
700
+ */ key: "activeStyle",
701
+ value: function activeStyle(_) {
702
+ return arguments.length ? (this._activeStyle = assign({}, this._activeStyle, _), this) : this._activeStyle;
703
+ }
704
+ },
705
+ {
706
+ /**
707
+ @memberof Shape
708
+ @desc If *value* is specified, sets the aria-label attribute to the specified function or string and returns the current class instance.
709
+ @param {Function|String} *value*
710
+ @chainable
711
+ */ key: "ariaLabel",
712
+ value: function ariaLabel(_) {
713
+ return _ !== undefined ? (this._ariaLabel = typeof _ === "function" ? _ : constant(_), this) : this._ariaLabel;
714
+ }
715
+ },
716
+ {
717
+ /**
718
+ @memberof Shape
719
+ @desc If *value* is specified, sets the background-image accessor to the specified function or string and returns the current class instance.
720
+ @param {Function|String} [*value* = false]
721
+ @chainable
722
+ */ key: "backgroundImage",
723
+ value: function backgroundImage(_) {
724
+ return arguments.length ? (this._backgroundImage = typeof _ === "function" ? _ : constant(_), this) : this._backgroundImage;
725
+ }
726
+ },
727
+ {
728
+ /**
729
+ @memberof Shape
730
+ @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 will be drawn for each object in the array.
731
+ @param {Array} [*data* = []]
732
+ @chainable
733
+ */ key: "data",
734
+ value: function data(_) {
735
+ return arguments.length ? (this._data = _, this) : this._data;
736
+ }
737
+ },
738
+ {
739
+ /**
740
+ @memberof Shape
741
+ @desc Determines if either the X or Y position is discrete along a Line, which helps in determining the nearest data point on a line for a hit area event.
742
+ @param {String} *value*
743
+ @chainable
744
+ */ key: "discrete",
745
+ value: function discrete(_) {
746
+ return arguments.length ? (this._discrete = _, this) : this._discrete;
747
+ }
748
+ },
749
+ {
750
+ /**
751
+ @memberof Shape
752
+ @desc If *ms* is specified, sets the animation duration to the specified number and returns the current class instance. If *ms* is not specified, returns the current animation duration.
753
+ @param {Number} [*ms* = 600]
754
+ @chainable
755
+ */ key: "duration",
756
+ value: function duration(_) {
757
+ return arguments.length ? (this._duration = _, this) : this._duration;
758
+ }
759
+ },
760
+ {
761
+ /**
762
+ @memberof Shape
763
+ @desc If *value* is specified, sets the fill accessor to the specified function or string and returns the current class instance.
764
+ @param {Function|String} [*value* = "black"]
765
+ @chainable
766
+ */ key: "fill",
767
+ value: function fill(_) {
768
+ return arguments.length ? (this._fill = typeof _ === "function" ? _ : constant(_), this) : this._fill;
769
+ }
770
+ },
771
+ {
772
+ /**
773
+ @memberof Shape
774
+ @desc Defines the "fill-opacity" attribute for the shapes.
775
+ @param {Function|Number} [*value* = 1]
776
+ @chainable
777
+ */ key: "fillOpacity",
778
+ value: function fillOpacity(_) {
779
+ return arguments.length ? (this._fillOpacity = typeof _ === "function" ? _ : constant(_), this) : this._fillOpacity;
780
+ }
781
+ },
782
+ {
783
+ /**
784
+ @memberof Shape
785
+ @desc If *value* is specified, sets the highlight accessor to the specified function and returns the current class instance.
786
+ @param {Function} [*value*]
787
+ @chainable
788
+ */ key: "hover",
789
+ value: function hover(_) {
790
+ if (!arguments.length || _ === void 0) return this._hover;
791
+ this._hover = _;
792
+ if (this._group) {
793
+ // this._renderImage();
794
+ // this._renderLabels();
795
+ this._renderHover();
796
+ }
797
+ return this;
798
+ }
799
+ },
800
+ {
801
+ /**
802
+ @memberof Shape
803
+ @desc The style to apply to hovered shapes.
804
+ @param {Object} *value*
805
+ @chainable
806
+ */ key: "hoverStyle",
807
+ value: function hoverStyle(_) {
808
+ return arguments.length ? (this._hoverStyle = assign({}, this._hoverStyle, _), this) : this._hoverStyle;
809
+ }
810
+ },
811
+ {
812
+ /**
813
+ @memberof Shape
814
+ @desc If *value* is specified, sets the hover opacity to the specified function and returns the current class instance.
815
+ @param {Number} [*value* = 0.5]
816
+ @chainable
817
+ */ key: "hoverOpacity",
818
+ value: function hoverOpacity(_) {
819
+ return arguments.length ? (this._hoverOpacity = _, this) : this._hoverOpacity;
820
+ }
821
+ },
822
+ {
823
+ /**
824
+ @memberof Shape
825
+ @desc If *bounds* is specified, sets the mouse hit area to the specified function and returns the current class instance. If *bounds* is not specified, returns the current mouse hit area accessor.
826
+ @param {Function} [*bounds*] The given function is passed the data point, index, and internally defined properties of the shape and should return an object containing the following values: `width`, `height`, `x`, `y`.
827
+ @chainable
828
+ @example
829
+ function(d, i, shape) {
830
+ return {
831
+ "width": shape.width,
832
+ "height": shape.height,
833
+ "x": -shape.width / 2,
834
+ "y": -shape.height / 2
835
+ };
836
+ }
837
+ */ key: "hitArea",
838
+ value: function hitArea(_) {
839
+ return arguments.length ? (this._hitArea = typeof _ === "function" ? _ : constant(_), this) : this._hitArea;
840
+ }
841
+ },
842
+ {
843
+ /**
844
+ @memberof Shape
845
+ @desc If *value* is specified, sets the id accessor to the specified function and returns the current class instance.
846
+ @param {Function} [*value*]
847
+ @chainable
848
+ */ key: "id",
849
+ value: function id(_) {
850
+ return arguments.length ? (this._id = _, this) : this._id;
851
+ }
852
+ },
853
+ {
854
+ /**
855
+ @memberof Shape
856
+ @desc If *value* is specified, sets the label accessor to the specified function or string and returns the current class instance.
857
+ @param {Function|String|Array} [*value*]
858
+ @chainable
859
+ */ key: "label",
860
+ value: function label(_) {
861
+ return arguments.length ? (this._label = typeof _ === "function" ? _ : constant(_), this) : this._label;
862
+ }
863
+ },
864
+ {
865
+ /**
866
+ @memberof Shape
867
+ @desc If *bounds* is specified, sets the label bounds to the specified function and returns the current class instance. If *bounds* is not specified, returns the current inner bounds accessor.
868
+ @param {Function} [*bounds*] The given function is passed the data point, index, and internally defined properties of the shape and should return an object containing the following values: `width`, `height`, `x`, `y`. If an array is returned from the function, each value will be used in conjunction with each label.
869
+ @chainable
870
+ @example
871
+ function(d, i, shape) {
872
+ return {
873
+ "width": shape.width,
874
+ "height": shape.height,
875
+ "x": -shape.width / 2,
876
+ "y": -shape.height / 2
877
+ };
878
+ }
879
+ */ key: "labelBounds",
880
+ value: function labelBounds(_) {
881
+ return arguments.length ? (this._labelBounds = typeof _ === "function" ? _ : constant(_), this) : this._labelBounds;
882
+ }
883
+ },
884
+ {
885
+ /**
886
+ @memberof Shape
887
+ @desc A pass-through to the config method of the TextBox class used to create a shape's labels.
888
+ @param {Object} [*value*]
889
+ @chainable
890
+ */ key: "labelConfig",
891
+ value: function labelConfig(_) {
892
+ return arguments.length ? (this._labelConfig = assign(this._labelConfig, _), this) : this._labelConfig;
893
+ }
894
+ },
895
+ {
896
+ /**
897
+ @memberof Shape
898
+ @desc If *value* is specified, sets the opacity accessor to the specified function or number and returns the current class instance.
899
+ @param {Number} [*value* = 1]
900
+ @chainable
901
+ */ key: "opacity",
902
+ value: function opacity(_) {
903
+ return arguments.length ? (this._opacity = typeof _ === "function" ? _ : constant(_), this) : this._opacity;
904
+ }
905
+ },
906
+ {
907
+ /**
908
+ @memberof Shape
909
+ @desc If *value* is specified, sets the pointerEvents accessor to the specified function or string and returns the current class instance.
910
+ @param {String} [*value*]
911
+ @chainable
912
+ */ key: "pointerEvents",
913
+ value: function pointerEvents(_) {
914
+ return arguments.length ? (this._pointerEvents = typeof _ === "function" ? _ : constant(_), this) : this._pointerEvents;
915
+ }
916
+ },
917
+ {
918
+ /**
919
+ @memberof Shape
920
+ @desc If *value* is specified, sets the role attribute to the specified function or string and returns the current class instance.
921
+ @param {Function|String} *value*
922
+ @chainable
923
+ */ key: "role",
924
+ value: function role(_) {
925
+ return _ !== undefined ? (this._role = typeof _ === "function" ? _ : constant(_), this) : this._role;
926
+ }
927
+ },
928
+ {
929
+ /**
930
+ @memberof Shape
931
+ @desc If *value* is specified, sets the rotate accessor to the specified function or number and returns the current class instance.
932
+ @param {Function|Number} [*value* = 0]
933
+ @chainable
934
+ */ key: "rotate",
935
+ value: function rotate(_) {
936
+ return arguments.length ? (this._rotate = typeof _ === "function" ? _ : constant(_), this) : this._rotate;
937
+ }
938
+ },
939
+ {
940
+ /**
941
+ @memberof Shape
942
+ @desc Defines the "rx" attribute for the shapes.
943
+ @param {Function|Number} [*value* = 0]
944
+ @chainable
945
+ */ key: "rx",
946
+ value: function rx(_) {
947
+ return arguments.length ? (this._rx = typeof _ === "function" ? _ : constant(_), this) : this._rx;
948
+ }
949
+ },
950
+ {
951
+ /**
952
+ @memberof Shape
953
+ @desc Defines the "rx" attribute for the shapes.
954
+ @param {Function|Number} [*value* = 0]
955
+ @chainable
956
+ */ key: "ry",
957
+ value: function ry(_) {
958
+ return arguments.length ? (this._ry = typeof _ === "function" ? _ : constant(_), this) : this._ry;
959
+ }
960
+ },
961
+ {
962
+ /**
963
+ @memberof Shape
964
+ @desc If *value* is specified, sets the scale accessor to the specified function or string and returns the current class instance.
965
+ @param {Function|Number} [*value* = 1]
966
+ @chainable
967
+ */ key: "scale",
968
+ value: function scale(_) {
969
+ return arguments.length ? (this._scale = typeof _ === "function" ? _ : constant(_), this) : this._scale;
970
+ }
971
+ },
972
+ {
973
+ /**
974
+ @memberof Shape
975
+ @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.
976
+ @param {String|HTMLElement} [*selector* = d3.select("body").append("svg")]
977
+ @chainable
978
+ */ key: "select",
979
+ value: function select1(_) {
980
+ return arguments.length ? (this._select = select(_), this) : this._select;
981
+ }
982
+ },
983
+ {
984
+ /**
985
+ @memberof Shape
986
+ @desc If *value* is specified, sets the shape-rendering accessor to the specified function or string and returns the current class instance.
987
+ @param {Function|String} [*value* = "geometricPrecision"]
988
+ @chainable
989
+ @example
990
+ function(d) {
991
+ return d.x;
992
+ }
993
+ */ key: "shapeRendering",
994
+ value: function shapeRendering(_) {
995
+ return arguments.length ? (this._shapeRendering = typeof _ === "function" ? _ : constant(_), this) : this._shapeRendering;
996
+ }
997
+ },
998
+ {
999
+ /**
1000
+ @memberof Shape
1001
+ @desc If *value* is specified, sets the sort comparator to the specified function and returns the current class instance.
1002
+ @param {false|Function} [*value* = []]
1003
+ @chainable
1004
+ */ key: "sort",
1005
+ value: function sort(_) {
1006
+ return arguments.length ? (this._sort = _, this) : this._sort;
1007
+ }
1008
+ },
1009
+ {
1010
+ /**
1011
+ @memberof Shape
1012
+ @desc If *value* is specified, sets the stroke accessor to the specified function or string and returns the current class instance.
1013
+ @param {Function|String} [*value* = "black"]
1014
+ @chainable
1015
+ */ key: "stroke",
1016
+ value: function stroke(_) {
1017
+ return arguments.length ? (this._stroke = typeof _ === "function" ? _ : constant(_), this) : this._stroke;
1018
+ }
1019
+ },
1020
+ {
1021
+ /**
1022
+ @memberof Shape
1023
+ @desc Defines the "stroke-dasharray" attribute for the shapes.
1024
+ @param {Function|String} [*value* = "1"]
1025
+ @chainable
1026
+ */ key: "strokeDasharray",
1027
+ value: function strokeDasharray(_) {
1028
+ return arguments.length ? (this._strokeDasharray = typeof _ === "function" ? _ : constant(_), this) : this._strokeDasharray;
1029
+ }
1030
+ },
1031
+ {
1032
+ /**
1033
+ @memberof Shape
1034
+ @desc Defines the "stroke-linecap" attribute for the shapes. Accepted values are `"butt"`, `"round"`, and `"square"`.
1035
+ @param {Function|String} [*value* = "butt"]
1036
+ @chainable
1037
+ */ key: "strokeLinecap",
1038
+ value: function strokeLinecap(_) {
1039
+ return arguments.length ? (this._strokeLinecap = typeof _ === "function" ? _ : constant(_), this) : this._strokeLinecap;
1040
+ }
1041
+ },
1042
+ {
1043
+ /**
1044
+ @memberof Shape
1045
+ @desc Defines the "stroke-opacity" attribute for the shapes.
1046
+ @param {Function|Number} [*value* = 1]
1047
+ @chainable
1048
+ */ key: "strokeOpacity",
1049
+ value: function strokeOpacity(_) {
1050
+ return arguments.length ? (this._strokeOpacity = typeof _ === "function" ? _ : constant(_), this) : this._strokeOpacity;
1051
+ }
1052
+ },
1053
+ {
1054
+ /**
1055
+ @memberof Shape
1056
+ @desc If *value* is specified, sets the stroke-width accessor to the specified function or string and returns the current class instance.
1057
+ @param {Function|Number} [*value* = 0]
1058
+ @chainable
1059
+ */ key: "strokeWidth",
1060
+ value: function strokeWidth(_) {
1061
+ return arguments.length ? (this._strokeWidth = typeof _ === "function" ? _ : constant(_), this) : this._strokeWidth;
1062
+ }
1063
+ },
1064
+ {
1065
+ /**
1066
+ @memberof Shape
1067
+ @desc If *value* is specified, sets the text-anchor accessor to the specified function or string and returns the current class instance.
1068
+ @param {Function|String|Array} [*value* = "start"]
1069
+ @chainable
1070
+ */ key: "textAnchor",
1071
+ value: function textAnchor(_) {
1072
+ return arguments.length ? (this._textAnchor = typeof _ === "function" ? _ : constant(_), this) : this._textAnchor;
1073
+ }
1074
+ },
1075
+ {
1076
+ /**
1077
+ @memberof Shape
1078
+ @desc Defines the texture used inside of each shape. This uses the [textures.js](https://riccardoscalco.it/textures/) package, and expects either a simple string (`"lines"` or `"circles"`) or a more complex Object containing the various properties of the texture (ie. `{texture: "lines", orientation: "3/8", stroke: "darkorange"}`). If multiple textures are necessary, provide an accsesor Function that returns the correct String/Object for each given data point and index.
1079
+ @param {String|Object|Function} [*value*]
1080
+ @chainable
1081
+ */ key: "texture",
1082
+ value: function texture(_) {
1083
+ return arguments.length ? (this._texture = typeof _ === "function" ? _ : constant(_), this) : this._texture;
1084
+ }
1085
+ },
1086
+ {
1087
+ /**
1088
+ @memberof Shape
1089
+ @desc A series of global texture methods to be used for all textures (ie. `{stroke: "darkorange", strokeWidth: 2}`).
1090
+ @param {Object} [*value*]
1091
+ @chainable
1092
+ */ key: "textureDefault",
1093
+ value: function textureDefault(_) {
1094
+ return arguments.length ? (this._textureDefault = assign(this._textureDefault, _), this) : this._textureDefault;
1095
+ }
1096
+ },
1097
+ {
1098
+ /**
1099
+ @memberof Shape
1100
+ @desc If *value* is specified, sets the vector-effect accessor to the specified function or string and returns the current class instance.
1101
+ @param {Function|String} [*value* = "non-scaling-stroke"]
1102
+ @chainable
1103
+ */ key: "vectorEffect",
1104
+ value: function vectorEffect(_) {
1105
+ return arguments.length ? (this._vectorEffect = typeof _ === "function" ? _ : constant(_), this) : this._vectorEffect;
1106
+ }
1107
+ },
1108
+ {
1109
+ /**
1110
+ @memberof Shape
1111
+ @desc If *value* is specified, sets the vertical alignment accessor to the specified function or string and returns the current class instance.
1112
+ @param {Function|String|Array} [*value* = "start"]
1113
+ @chainable
1114
+ */ key: "verticalAlign",
1115
+ value: function verticalAlign(_) {
1116
+ return arguments.length ? (this._verticalAlign = typeof _ === "function" ? _ : constant(_), this) : this._verticalAlign;
1117
+ }
1118
+ },
1119
+ {
1120
+ /**
1121
+ @memberof Shape
1122
+ @desc If *value* is specified, sets the x accessor to the specified function or number and returns the current class instance.
1123
+ @param {Function|Number} [*value*]
1124
+ @chainable
1125
+ @example
1126
+ function(d) {
1127
+ return d.x;
1128
+ }
1129
+ */ key: "x",
1130
+ value: function x(_) {
1131
+ return arguments.length ? (this._x = typeof _ === "function" ? _ : constant(_), this) : this._x;
1132
+ }
1133
+ },
1134
+ {
1135
+ /**
1136
+ @memberof Shape
1137
+ @desc If *value* is specified, sets the y accessor to the specified function or number and returns the current class instance.
1138
+ @param {Function|Number} [*value*]
1139
+ @chainable
1140
+ @example
1141
+ function(d) {
1142
+ return d.y;
1143
+ }
1144
+ */ key: "y",
1145
+ value: function y(_) {
1146
+ return arguments.length ? (this._y = typeof _ === "function" ? _ : constant(_), this) : this._y;
1147
+ }
1148
+ }
1149
+ ]);
1150
+ return Shape;
1151
+ }(BaseClass);
1152
+ /**
1153
+ @class Shape
1154
+ @extends BaseClass
1155
+ @desc An abstracted class for generating shapes.
1156
+ */ export { Shape as default };