@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,255 @@
1
+ function _class_call_check(instance, Constructor) {
2
+ if (!(instance instanceof Constructor)) {
3
+ throw new TypeError("Cannot call a class as a function");
4
+ }
5
+ }
6
+ function _defineProperties(target, props) {
7
+ for(var i = 0; i < props.length; i++){
8
+ var descriptor = props[i];
9
+ descriptor.enumerable = descriptor.enumerable || false;
10
+ descriptor.configurable = true;
11
+ if ("value" in descriptor) descriptor.writable = true;
12
+ Object.defineProperty(target, descriptor.key, descriptor);
13
+ }
14
+ }
15
+ function _create_class(Constructor, protoProps, staticProps) {
16
+ if (protoProps) _defineProperties(Constructor.prototype, protoProps);
17
+ if (staticProps) _defineProperties(Constructor, staticProps);
18
+ return Constructor;
19
+ }
20
+ import { select } from "d3-selection";
21
+ import { transition } from "d3-transition";
22
+ import { accessor, constant } from "../utils/index.js";
23
+ var Image = /*#__PURE__*/ function() {
24
+ "use strict";
25
+ function Image() {
26
+ _class_call_check(this, Image);
27
+ this._duration = 600;
28
+ this._height = accessor("height");
29
+ this._id = accessor("id");
30
+ this._opacity = constant(1);
31
+ this._pointerEvents = constant("auto");
32
+ this._select;
33
+ this._url = accessor("url");
34
+ this._width = accessor("width");
35
+ this._x = accessor("x", 0);
36
+ this._y = accessor("y", 0);
37
+ }
38
+ _create_class(Image, [
39
+ {
40
+ /**
41
+ @memberof Image
42
+ @desc Renders the current Image to the page. If a *callback* is specified, it will be called once the images are done drawing.
43
+ @param {Function} [*callback*]
44
+ @chainable
45
+ */ key: "render",
46
+ value: function render(callback) {
47
+ var _this = this;
48
+ if (this._select === void 0) this.select(select("body").append("svg").style("width", "".concat(window.innerWidth, "px")).style("height", "".concat(window.innerHeight, "px")).style("display", "block").node());
49
+ var images = this._select.selectAll(".d3plus-Image").data(this._data, this._id);
50
+ var enter = images.enter().append("image").attr("class", "d3plus-Image").attr("opacity", 0).attr("width", 0).attr("height", 0).attr("x", function(d, i) {
51
+ return _this._x(d, i) + _this._width(d, i) / 2;
52
+ }).attr("y", function(d, i) {
53
+ return _this._y(d, i) + _this._height(d, i) / 2;
54
+ });
55
+ var t = transition().duration(this._duration), that = this, update = enter.merge(images);
56
+ update.attr("xlink:href", this._url).style("pointer-events", this._pointerEvents).transition(t).attr("opacity", this._opacity).attr("width", function(d, i) {
57
+ return _this._width(d, i);
58
+ }).attr("height", function(d, i) {
59
+ return _this._height(d, i);
60
+ }).attr("x", function(d, i) {
61
+ return _this._x(d, i);
62
+ }).attr("y", function(d, i) {
63
+ return _this._y(d, i);
64
+ }).each(function(d, i) {
65
+ var image = select(this), link = that._url(d, i);
66
+ var fullAddress = link.indexOf("http://") === 0 || link.indexOf("https://") === 0;
67
+ if (!fullAddress || link.indexOf(window.location.hostname) === 0) {
68
+ var img = new Image();
69
+ img.src = link;
70
+ img.crossOrigin = "Anonymous";
71
+ img.onload = function() {
72
+ var canvas = document.createElement("canvas");
73
+ canvas.width = this.width;
74
+ canvas.height = this.height;
75
+ var context = canvas.getContext("2d");
76
+ context.drawImage(this, 0, 0);
77
+ image.attr("xlink:href", canvas.toDataURL("image/png"));
78
+ };
79
+ }
80
+ });
81
+ images.exit().transition(t).attr("width", function(d, i) {
82
+ return _this._width(d, i);
83
+ }).attr("height", function(d, i) {
84
+ return _this._height(d, i);
85
+ }).attr("x", function(d, i) {
86
+ return _this._x(d, i);
87
+ }).attr("y", function(d, i) {
88
+ return _this._y(d, i);
89
+ }).attr("opacity", 0).remove();
90
+ if (callback) setTimeout(callback, this._duration + 100);
91
+ return this;
92
+ }
93
+ },
94
+ {
95
+ /**
96
+ @memberof Image
97
+ @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. An <image> tag will be drawn for each object in the array.
98
+ @param {Array} [*data* = []]
99
+ @chainable
100
+ */ key: "data",
101
+ value: function data(_) {
102
+ return arguments.length ? (this._data = _, this) : this._data;
103
+ }
104
+ },
105
+ {
106
+ /**
107
+ @memberof Image
108
+ @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.
109
+ @param {Number} [*ms* = 600]
110
+ @chainable
111
+ */ key: "duration",
112
+ value: function duration(_) {
113
+ return arguments.length ? (this._duration = _, this) : this._duration;
114
+ }
115
+ },
116
+ {
117
+ /**
118
+ @memberof Image
119
+ @desc If *value* is specified, sets the height accessor to the specified function or number and returns the current class instance.
120
+ @param {Function|Number} [*value*]
121
+ @chainable
122
+ @example
123
+ function(d) {
124
+ return d.height;
125
+ }
126
+ */ key: "height",
127
+ value: function height(_) {
128
+ return arguments.length ? (this._height = typeof _ === "function" ? _ : constant(_), this) : this._height;
129
+ }
130
+ },
131
+ {
132
+ /**
133
+ @memberof Image
134
+ @desc If *value* is specified, sets the id accessor to the specified function and returns the current class instance.
135
+ @param {Function} [*value*]
136
+ @chainable
137
+ @example
138
+ function(d) {
139
+ return d.id;
140
+ }
141
+ */ key: "id",
142
+ value: function id(_) {
143
+ return arguments.length ? (this._id = _, this) : this._id;
144
+ }
145
+ },
146
+ {
147
+ /**
148
+ @memberof Image
149
+ @desc Sets the opacity of the image.
150
+ @param {Number} [*value* = 1]
151
+ @chainable
152
+ */ key: "opacity",
153
+ value: function opacity(_) {
154
+ return arguments.length ? (this._opacity = typeof _ === "function" ? _ : constant(_), this) : this._opacity;
155
+ }
156
+ },
157
+ {
158
+ /**
159
+ @memberof Image
160
+ @desc If *value* is specified, sets the pointer-events accessor to the specified function or string and returns the current class instance.
161
+ @param {Function|String} [*value* = "auto"]
162
+ @chainable
163
+ */ key: "pointerEvents",
164
+ value: function pointerEvents(_) {
165
+ return arguments.length ? (this._pointerEvents = typeof _ === "function" ? _ : constant(_), this) : this._pointerEvents;
166
+ }
167
+ },
168
+ {
169
+ /**
170
+ @memberof Image
171
+ @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.
172
+ @param {String|HTMLElement} [*selector* = d3.select("body").append("svg")]
173
+ @chainable
174
+ */ key: "select",
175
+ value: function select1(_) {
176
+ return arguments.length ? (this._select = select(_), this) : this._select;
177
+ }
178
+ },
179
+ {
180
+ /**
181
+ @memberof Image
182
+ @desc If *value* is specified, sets the URL accessor to the specified function and returns the current class instance.
183
+ @param {Function} [*value*]
184
+ @chainable
185
+ @example
186
+ function(d) {
187
+ return d.url;
188
+ }
189
+ */ key: "url",
190
+ value: function url(_) {
191
+ return arguments.length ? (this._url = _, this) : this._url;
192
+ }
193
+ },
194
+ {
195
+ /**
196
+ @memberof Image
197
+ @desc If *value* is specified, sets the width accessor to the specified function or number and returns the current class instance.
198
+ @param {Function|Number} [*value*]
199
+ @chainable
200
+ @example
201
+ function(d) {
202
+ return d.width;
203
+ }
204
+ */ key: "width",
205
+ value: function width(_) {
206
+ return arguments.length ? (this._width = typeof _ === "function" ? _ : constant(_), this) : this._width;
207
+ }
208
+ },
209
+ {
210
+ /**
211
+ @memberof Image
212
+ @desc If *value* is specified, sets the x accessor to the specified function or number and returns the current class instance.
213
+ @param {Function|Number} [*value*]
214
+ @chainable
215
+ @example
216
+ function(d) {
217
+ return d.x || 0;
218
+ }
219
+ */ key: "x",
220
+ value: function x(_) {
221
+ return arguments.length ? (this._x = typeof _ === "function" ? _ : constant(_), this) : this._x;
222
+ }
223
+ },
224
+ {
225
+ /**
226
+ @memberof Image
227
+ @desc If *value* is specified, sets the y accessor to the specified function or number and returns the current class instance.
228
+ @param {Function|Number} [*value*]
229
+ @chainable
230
+ @example
231
+ function(d) {
232
+ return d.y || 0;
233
+ }
234
+ */ key: "y",
235
+ value: function y(_) {
236
+ return arguments.length ? (this._y = typeof _ === "function" ? _ : constant(_), this) : this._y;
237
+ }
238
+ }
239
+ ]);
240
+ return Image;
241
+ }();
242
+ /**
243
+ @class Image
244
+ @desc Creates SVG images based on an array of data.
245
+ @example <caption>a sample row of data</caption>
246
+ var data = {"url": "file.png", "width": "100", "height": "50"};
247
+ @example <caption>passed to the generator</caption>
248
+ new Image().data([data]).render();
249
+ @example <caption>creates the following</caption>
250
+ <image class="d3plus-Image" opacity="1" href="file.png" width="100" height="50" x="0" y="0"></image>
251
+ @example <caption>this is shorthand for the following</caption>
252
+ image().data([data])();
253
+ @example <caption>which also allows a post-draw callback function</caption>
254
+ image().data([data])(function() { alert("draw complete!"); })
255
+ */ export { Image as default };
@@ -0,0 +1,289 @@
1
+ function _assert_this_initialized(self) {
2
+ if (self === void 0) {
3
+ throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
4
+ }
5
+ return self;
6
+ }
7
+ function _call_super(_this, derived, args) {
8
+ derived = _get_prototype_of(derived);
9
+ return _possible_constructor_return(_this, _is_native_reflect_construct() ? Reflect.construct(derived, args || [], _get_prototype_of(_this).constructor) : derived.apply(_this, args));
10
+ }
11
+ function _class_call_check(instance, Constructor) {
12
+ if (!(instance instanceof Constructor)) {
13
+ throw new TypeError("Cannot call a class as a function");
14
+ }
15
+ }
16
+ function _defineProperties(target, props) {
17
+ for(var i = 0; i < props.length; i++){
18
+ var descriptor = props[i];
19
+ descriptor.enumerable = descriptor.enumerable || false;
20
+ descriptor.configurable = true;
21
+ if ("value" in descriptor) descriptor.writable = true;
22
+ Object.defineProperty(target, descriptor.key, descriptor);
23
+ }
24
+ }
25
+ function _create_class(Constructor, protoProps, staticProps) {
26
+ if (protoProps) _defineProperties(Constructor.prototype, protoProps);
27
+ if (staticProps) _defineProperties(Constructor, staticProps);
28
+ return Constructor;
29
+ }
30
+ function _get(target, property, receiver) {
31
+ if (typeof Reflect !== "undefined" && Reflect.get) {
32
+ _get = Reflect.get;
33
+ } else {
34
+ _get = function get(target, property, receiver) {
35
+ var base = _super_prop_base(target, property);
36
+ if (!base) return;
37
+ var desc = Object.getOwnPropertyDescriptor(base, property);
38
+ if (desc.get) {
39
+ return desc.get.call(receiver || target);
40
+ }
41
+ return desc.value;
42
+ };
43
+ }
44
+ return _get(target, property, receiver || target);
45
+ }
46
+ function _get_prototype_of(o) {
47
+ _get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
48
+ return o.__proto__ || Object.getPrototypeOf(o);
49
+ };
50
+ return _get_prototype_of(o);
51
+ }
52
+ function _inherits(subClass, superClass) {
53
+ if (typeof superClass !== "function" && superClass !== null) {
54
+ throw new TypeError("Super expression must either be null or a function");
55
+ }
56
+ subClass.prototype = Object.create(superClass && superClass.prototype, {
57
+ constructor: {
58
+ value: subClass,
59
+ writable: true,
60
+ configurable: true
61
+ }
62
+ });
63
+ if (superClass) _set_prototype_of(subClass, superClass);
64
+ }
65
+ function _possible_constructor_return(self, call) {
66
+ if (call && (_type_of(call) === "object" || typeof call === "function")) {
67
+ return call;
68
+ }
69
+ return _assert_this_initialized(self);
70
+ }
71
+ function _set_prototype_of(o, p) {
72
+ _set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
73
+ o.__proto__ = p;
74
+ return o;
75
+ };
76
+ return _set_prototype_of(o, p);
77
+ }
78
+ function _super_prop_base(object, property) {
79
+ while(!Object.prototype.hasOwnProperty.call(object, property)){
80
+ object = _get_prototype_of(object);
81
+ if (object === null) break;
82
+ }
83
+ return object;
84
+ }
85
+ function _type_of(obj) {
86
+ "@swc/helpers - typeof";
87
+ return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
88
+ }
89
+ function _is_native_reflect_construct() {
90
+ try {
91
+ var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
92
+ } catch (_) {}
93
+ return (_is_native_reflect_construct = function() {
94
+ return !!result;
95
+ })();
96
+ }
97
+ import { extent, sum } from "d3-array";
98
+ import { nest } from "d3-collection";
99
+ import { interpolatePath } from "d3-interpolate-path";
100
+ import { select } from "d3-selection";
101
+ import * as paths from "d3-shape";
102
+ import { merge } from "@d3plus/data";
103
+ import { constant } from "../utils/index.js";
104
+ import Shape from "./Shape.js";
105
+ var Line = /*#__PURE__*/ function(Shape) {
106
+ "use strict";
107
+ _inherits(Line, Shape);
108
+ function Line() {
109
+ _class_call_check(this, Line);
110
+ var _this;
111
+ _this = _call_super(this, Line);
112
+ _this._curve = constant("linear");
113
+ _this._defined = function(d) {
114
+ return d;
115
+ };
116
+ _this._fill = constant("none");
117
+ _this._hitArea = constant({
118
+ "d": function(d) {
119
+ return _this._path(d.values);
120
+ },
121
+ "fill": "none",
122
+ "stroke-width": 10,
123
+ "transform": null
124
+ });
125
+ _this._name = "Line";
126
+ _this._path = paths.line();
127
+ _this._stroke = constant("black");
128
+ _this._strokeWidth = constant(1);
129
+ return _this;
130
+ }
131
+ _create_class(Line, [
132
+ {
133
+ /**
134
+ @memberof Line
135
+ @desc Filters/manipulates the data array before binding each point to an SVG group.
136
+ @param {Array} [*data* = the data array to be filtered]
137
+ @private
138
+ */ key: "_dataFilter",
139
+ value: function _dataFilter(data) {
140
+ var _this = this;
141
+ var lines = nest().key(this._id).entries(data).map(function(d) {
142
+ d.data = merge(d.values);
143
+ d.i = data.indexOf(d.values[0]);
144
+ var x = extent(d.values, _this._x);
145
+ d.xR = x;
146
+ d.width = x[1] - x[0];
147
+ d.x = x[0] + d.width / 2;
148
+ var y = extent(d.values, _this._y);
149
+ d.yR = y;
150
+ d.height = y[1] - y[0];
151
+ d.y = y[0] + d.height / 2;
152
+ d.nested = true;
153
+ d.translate = [
154
+ d.x,
155
+ d.y
156
+ ];
157
+ d.__d3plusShape__ = true;
158
+ return d;
159
+ });
160
+ lines.key = function(d) {
161
+ return d.key;
162
+ };
163
+ return lines;
164
+ }
165
+ },
166
+ {
167
+ /**
168
+ @memberof Line
169
+ @desc Draws the lines.
170
+ @param {Function} [*callback*]
171
+ @chainable
172
+ */ key: "render",
173
+ value: function render(callback) {
174
+ var _this = this;
175
+ _get(_get_prototype_of(Line.prototype), "render", this).call(this, callback);
176
+ var that = this;
177
+ /**
178
+ @desc Calculates the stroke-dasharray used for animations
179
+ @param {Object} *d* data point
180
+ @private
181
+ */ function calculateStrokeDashArray(d) {
182
+ d.initialLength = this.getTotalLength();
183
+ var strokeArray = that._strokeDasharray(d.values[0], that._data.indexOf(d.values[0])).split(" ").map(Number);
184
+ if (strokeArray.length === 1 && strokeArray[0] === 0) strokeArray = [
185
+ d.initialLength
186
+ ];
187
+ else if (strokeArray.length === 1) strokeArray.push(strokeArray[0]);
188
+ else if (strokeArray.length % 2) strokeArray = strokeArray.concat(strokeArray);
189
+ var newStrokeArray = [];
190
+ var strokeLength = 0;
191
+ while(strokeLength < d.initialLength){
192
+ for(var i = 0; i < strokeArray.length; i++){
193
+ var num = strokeArray[i];
194
+ strokeLength += num;
195
+ newStrokeArray.push(num);
196
+ if (strokeLength >= d.initialLength) break;
197
+ }
198
+ }
199
+ if (newStrokeArray.length > 1 && newStrokeArray.length % 2) newStrokeArray.pop();
200
+ newStrokeArray[newStrokeArray.length - 1] += d.initialLength - sum(newStrokeArray);
201
+ if (newStrokeArray.length % 2 === 0) newStrokeArray.push(0);
202
+ d.initialStrokeArray = newStrokeArray.join(" ");
203
+ }
204
+ var userCurve = this._curve.bind(this)(this.config());
205
+ var curve = paths["curve".concat(userCurve.charAt(0).toUpperCase()).concat(userCurve.slice(1))];
206
+ this._path.curve(curve).defined(this._defined).x(this._x).y(this._y);
207
+ var enter = this._enter.append("path").attr("transform", function(d) {
208
+ return "translate(".concat(-d.xR[0] - d.width / 2, ", ").concat(-d.yR[0] - d.height / 2, ")");
209
+ }).attr("d", function(d) {
210
+ return _this._path(d.values);
211
+ }).call(this._applyStyle.bind(this));
212
+ var update = this._update.select("path").attr("stroke-dasharray", function(d) {
213
+ return that._strokeDasharray(d.values[0], that._data.indexOf(d.values[0]));
214
+ });
215
+ if (this._duration) {
216
+ enter.each(calculateStrokeDashArray).attr("stroke-dasharray", function(d) {
217
+ return "".concat(d.initialStrokeArray, " ").concat(d.initialLength);
218
+ }).attr("stroke-dashoffset", function(d) {
219
+ return d.initialLength;
220
+ }).transition(this._transition).attr("stroke-dashoffset", 0);
221
+ update = update.transition(this._transition).attrTween("d", function(d) {
222
+ return interpolatePath(select(this).attr("d"), that._path(d.values));
223
+ });
224
+ this._exit.selectAll("path").each(calculateStrokeDashArray).attr("stroke-dasharray", function(d) {
225
+ return "".concat(d.initialStrokeArray, " ").concat(d.initialLength);
226
+ }).transition(this._transition).attr("stroke-dashoffset", function(d) {
227
+ return -d.initialLength;
228
+ });
229
+ } else {
230
+ update = update.attr("d", function(d) {
231
+ return that._path(d.values);
232
+ });
233
+ }
234
+ update.attr("transform", function(d) {
235
+ return "translate(".concat(-d.xR[0] - d.width / 2, ", ").concat(-d.yR[0] - d.height / 2, ")");
236
+ }).call(this._applyStyle.bind(this));
237
+ return this;
238
+ }
239
+ },
240
+ {
241
+ /**
242
+ @memberof Line
243
+ @desc Given a specific data point and index, returns the aesthetic properties of the shape.
244
+ @param {Object} *data point*
245
+ @param {Number} *index*
246
+ @private
247
+ */ key: "_aes",
248
+ value: function _aes(d, i) {
249
+ var _this = this;
250
+ return {
251
+ points: d.values.map(function(p) {
252
+ return [
253
+ _this._x(p, i),
254
+ _this._y(p, i)
255
+ ];
256
+ })
257
+ };
258
+ }
259
+ },
260
+ {
261
+ /**
262
+ @memberof Line
263
+ @desc If *value* is specified, sets the area curve to the specified string and returns the current class instance. If *value* is not specified, returns the current area curve.
264
+ @param {Function|String} [*value* = "linear"]
265
+ @chainable
266
+ */ key: "curve",
267
+ value: function curve(_) {
268
+ return arguments.length ? (this._curve = typeof _ === "function" ? _ : constant(_), this) : this._curve;
269
+ }
270
+ },
271
+ {
272
+ /**
273
+ @memberof Line
274
+ @desc If *value* is specified, sets the defined accessor to the specified function and returns the current class instance. If *value* is not specified, returns the current defined accessor.
275
+ @param {Function} [*value*]
276
+ @chainable
277
+ */ key: "defined",
278
+ value: function defined(_) {
279
+ return arguments.length ? (this._defined = _, this) : this._defined;
280
+ }
281
+ }
282
+ ]);
283
+ return Line;
284
+ }(Shape);
285
+ /**
286
+ @class Line
287
+ @extends Shape
288
+ @desc Creates SVG lines based on an array of data.
289
+ */ export { Line as default };