@d3plus/core 3.0.16 → 3.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +88485 -2998
- package/es/index.js +1 -1
- package/es/src/charts/AreaPlot.js +1 -3
- package/es/src/charts/BarChart.js +1 -3
- package/es/src/charts/BoxWhisker.js +2 -4
- package/es/src/charts/BumpChart.js +4 -5
- package/es/src/charts/Donut.js +1 -3
- package/es/src/charts/Geomap.js +47 -88
- package/es/src/charts/LinePlot.js +1 -3
- package/es/src/charts/Matrix.js +27 -46
- package/es/src/charts/Network.js +87 -81
- package/es/src/charts/Pack.js +21 -34
- package/es/src/charts/Pie.js +12 -24
- package/es/src/charts/Plot.js +226 -321
- package/es/src/charts/Priestley.js +18 -36
- package/es/src/charts/Radar.js +100 -47
- package/es/src/charts/RadialMatrix.js +35 -47
- package/es/src/charts/Rings.js +99 -90
- package/es/src/charts/Sankey.js +85 -75
- package/es/src/charts/StackedArea.js +1 -3
- package/es/src/charts/Tree.js +27 -28
- package/es/src/charts/Treemap.js +117 -71
- package/es/src/charts/Viz.js +296 -492
- package/es/src/charts/drawSteps/drawAttribution.js +1 -1
- package/es/src/charts/drawSteps/drawBack.js +1 -2
- package/es/src/charts/drawSteps/drawColorScale.js +1 -2
- package/es/src/charts/drawSteps/drawLegend.js +8 -10
- package/es/src/charts/drawSteps/drawSubtitle.js +1 -3
- package/es/src/charts/drawSteps/drawTimeline.js +12 -9
- package/es/src/charts/drawSteps/drawTitle.js +1 -3
- package/es/src/charts/drawSteps/drawTotal.js +1 -3
- package/es/src/charts/drawSteps/zoomControls.js +19 -21
- package/es/src/charts/events/click.legend.js +2 -3
- package/es/src/charts/events/click.shape.js +2 -4
- package/es/src/charts/events/mouseenter.js +7 -8
- package/es/src/charts/events/mouseleave.js +1 -3
- package/es/src/charts/events/mousemove.legend.js +3 -4
- package/es/src/charts/events/mousemove.shape.js +2 -4
- package/es/src/charts/events/touchstart.body.js +1 -1
- package/es/src/charts/helpers/matrixData.js +11 -4
- package/es/src/charts/helpers/tileAttributions.js +2 -1
- package/es/src/charts/plotBuffers/Bar.js +55 -12
- package/es/src/charts/plotBuffers/Box.js +55 -12
- package/es/src/charts/plotBuffers/Circle.js +9 -11
- package/es/src/charts/plotBuffers/Line.js +4 -6
- package/es/src/charts/plotBuffers/Rect.js +10 -12
- package/es/src/charts/plotBuffers/discreteBuffer.js +4 -2
- package/es/src/charts/plotBuffers/numericBuffer.js +7 -6
- package/es/src/components/Axis.js +298 -426
- package/es/src/components/AxisBottom.js +1 -3
- package/es/src/components/AxisLeft.js +1 -3
- package/es/src/components/AxisRight.js +1 -3
- package/es/src/components/AxisTop.js +1 -3
- package/es/src/components/ColorScale.js +80 -197
- package/es/src/components/Legend.js +82 -135
- package/es/src/components/Message.js +27 -19
- package/es/src/components/TextBox.js +106 -262
- package/es/src/components/Timeline.js +88 -155
- package/es/src/components/Tooltip.js +301 -330
- package/es/src/shapes/Area.js +95 -74
- package/es/src/shapes/Bar.js +46 -86
- package/es/src/shapes/Box.js +104 -118
- package/es/src/shapes/Circle.js +29 -30
- package/es/src/shapes/Image.js +44 -102
- package/es/src/shapes/Line.js +74 -40
- package/es/src/shapes/Path.js +23 -25
- package/es/src/shapes/Rect.js +29 -41
- package/es/src/shapes/Shape.js +146 -363
- package/es/src/shapes/Whisker.js +89 -90
- package/es/src/utils/AccessorFn.js +4 -0
- package/es/src/utils/BaseClass.js +53 -82
- package/es/src/utils/D3plusConfig.js +1 -0
- package/es/src/utils/RESET.js +2 -4
- package/es/src/utils/accessor.js +4 -5
- package/es/src/utils/configPrep.js +13 -12
- package/es/src/utils/constant.js +2 -3
- package/es/src/utils/getProp.js +4 -4
- package/es/src/utils/index.js +0 -1
- package/package.json +30 -22
- package/types/index.d.ts +5 -0
- package/types/src/charts/AreaPlot.d.ts +16 -0
- package/types/src/charts/BarChart.d.ts +16 -0
- package/types/src/charts/BoxWhisker.d.ts +11 -0
- package/types/src/charts/BumpChart.d.ts +36 -0
- package/types/src/charts/Donut.d.ts +11 -0
- package/types/src/charts/Geomap.d.ts +120 -0
- package/types/src/charts/LinePlot.d.ts +15 -0
- package/types/src/charts/Matrix.d.ts +74 -0
- package/types/src/charts/Network.d.ts +78 -0
- package/types/src/charts/Pack.d.ts +47 -0
- package/types/src/charts/Pie.d.ts +44 -0
- package/types/src/charts/Plot.d.ts +199 -0
- package/types/src/charts/Priestley.d.ts +37 -0
- package/types/src/charts/Radar.d.ts +38 -0
- package/types/src/charts/RadialMatrix.d.ts +78 -0
- package/types/src/charts/Rings.d.ts +74 -0
- package/types/src/charts/Sankey.d.ts +81 -0
- package/types/src/charts/StackedArea.d.ts +14 -0
- package/types/src/charts/Tree.d.ts +33 -0
- package/types/src/charts/Treemap.d.ts +51 -0
- package/types/src/charts/Viz.d.ts +402 -0
- package/types/src/charts/drawSteps/drawAttribution.d.ts +7 -0
- package/types/src/charts/drawSteps/drawBack.d.ts +6 -0
- package/types/src/charts/drawSteps/drawColorScale.d.ts +6 -0
- package/types/src/charts/drawSteps/drawLegend.d.ts +12 -0
- package/types/src/charts/drawSteps/drawSubtitle.d.ts +7 -0
- package/types/src/charts/drawSteps/drawTimeline.d.ts +7 -0
- package/types/src/charts/drawSteps/drawTitle.d.ts +7 -0
- package/types/src/charts/drawSteps/drawTotal.d.ts +7 -0
- package/types/src/charts/drawSteps/zoomControls.d.ts +7 -0
- package/types/src/charts/events/click.legend.d.ts +8 -0
- package/types/src/charts/events/click.shape.d.ts +8 -0
- package/types/src/charts/events/mouseenter.d.ts +8 -0
- package/types/src/charts/events/mouseleave.d.ts +8 -0
- package/types/src/charts/events/mousemove.legend.d.ts +9 -0
- package/types/src/charts/events/mousemove.shape.d.ts +9 -0
- package/types/src/charts/events/touchstart.body.d.ts +7 -0
- package/types/src/charts/helpers/matrixData.d.ts +11 -0
- package/types/src/charts/helpers/tileAttributions.d.ts +6 -0
- package/types/src/charts/index.d.ts +21 -0
- package/types/src/charts/plotBuffers/Bar.d.ts +16 -0
- package/types/src/charts/plotBuffers/Box.d.ts +16 -0
- package/types/src/charts/plotBuffers/Circle.d.ts +20 -0
- package/types/src/charts/plotBuffers/Line.d.ts +16 -0
- package/types/src/charts/plotBuffers/Rect.d.ts +19 -0
- package/types/src/charts/plotBuffers/discreteBuffer.d.ts +7 -0
- package/types/src/charts/plotBuffers/numericBuffer.d.ts +5 -0
- package/types/src/components/Axis.d.ts +309 -0
- package/types/src/components/AxisBottom.d.ts +11 -0
- package/types/src/components/AxisLeft.d.ts +11 -0
- package/types/src/components/AxisRight.d.ts +11 -0
- package/types/src/components/AxisTop.d.ts +11 -0
- package/types/src/components/ColorScale.d.ts +208 -0
- package/types/src/components/Legend.d.ts +157 -0
- package/types/src/components/Message.d.ts +40 -0
- package/types/src/components/TextBox.d.ts +278 -0
- package/types/src/components/Timeline.d.ts +157 -0
- package/types/src/components/Tooltip.d.ts +297 -0
- package/types/src/components/index.d.ts +11 -0
- package/types/src/shapes/Area.d.ts +81 -0
- package/types/src/shapes/Bar.d.ts +104 -0
- package/types/src/shapes/Box.d.ts +121 -0
- package/types/src/shapes/Circle.d.ts +44 -0
- package/types/src/shapes/Image.d.ts +124 -0
- package/types/src/shapes/Line.d.ts +48 -0
- package/types/src/shapes/Path.d.ts +38 -0
- package/types/src/shapes/Rect.d.ts +54 -0
- package/types/src/shapes/Shape.d.ts +378 -0
- package/types/src/shapes/Whisker.d.ts +96 -0
- package/types/src/shapes/index.d.ts +10 -0
- package/types/src/utils/AccessorFn.d.ts +6 -0
- package/types/src/utils/BaseClass.d.ts +76 -0
- package/types/src/utils/D3plusConfig.d.ts +164 -0
- package/types/src/utils/RESET.d.ts +3 -0
- package/types/src/utils/accessor.d.ts +13 -0
- package/types/src/utils/configPrep.d.ts +28 -0
- package/types/src/utils/constant.d.ts +11 -0
- package/types/src/utils/getProp.d.ts +9 -0
- package/types/src/utils/index.d.ts +8 -0
- package/umd/d3plus-core.full.js +20127 -18701
- package/umd/d3plus-core.full.js.map +1 -1
- package/umd/d3plus-core.full.min.js +2920 -5394
- package/umd/d3plus-core.js +1920 -4074
- package/umd/d3plus-core.js.map +1 -1
- package/umd/d3plus-core.min.js +1605 -3937
- package/es/src/utils/uuid.js +0 -13
package/es/src/shapes/Image.js
CHANGED
|
@@ -17,6 +17,19 @@ 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 { transition } from "d3-transition";
|
|
22
35
|
import { accessor, constant } from "../utils/index.js";
|
|
@@ -24,12 +37,22 @@ var Image = /*#__PURE__*/ function() {
|
|
|
24
37
|
"use strict";
|
|
25
38
|
function Image() {
|
|
26
39
|
_class_call_check(this, Image);
|
|
40
|
+
_define_property(this, "_duration", void 0);
|
|
41
|
+
_define_property(this, "_height", void 0);
|
|
42
|
+
_define_property(this, "_id", void 0);
|
|
43
|
+
_define_property(this, "_opacity", void 0);
|
|
44
|
+
_define_property(this, "_pointerEvents", void 0);
|
|
45
|
+
_define_property(this, "_select", void 0);
|
|
46
|
+
_define_property(this, "_url", void 0);
|
|
47
|
+
_define_property(this, "_width", void 0);
|
|
48
|
+
_define_property(this, "_x", void 0);
|
|
49
|
+
_define_property(this, "_y", void 0);
|
|
50
|
+
_define_property(this, "_data", void 0);
|
|
27
51
|
this._duration = 600;
|
|
28
52
|
this._height = accessor("height");
|
|
29
53
|
this._id = accessor("id");
|
|
30
54
|
this._opacity = constant(1);
|
|
31
55
|
this._pointerEvents = constant("auto");
|
|
32
|
-
this._select;
|
|
33
56
|
this._url = accessor("url");
|
|
34
57
|
this._width = accessor("width");
|
|
35
58
|
this._x = accessor("x", 0);
|
|
@@ -38,14 +61,13 @@ var Image = /*#__PURE__*/ function() {
|
|
|
38
61
|
_create_class(Image, [
|
|
39
62
|
{
|
|
40
63
|
/**
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
@chainable
|
|
45
|
-
*/ key: "render",
|
|
64
|
+
Renders the current Image to the page. If a *callback* is specified, it will be called once the images are done drawing.
|
|
65
|
+
@param callback Optional callback invoked after rendering completes.
|
|
66
|
+
*/ key: "render",
|
|
46
67
|
value: function render(callback) {
|
|
47
68
|
var _this = this;
|
|
48
69
|
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());
|
|
70
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
49
71
|
var images = this._select.selectAll(".d3plus-Image").data(this._data, this._id);
|
|
50
72
|
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
73
|
return _this._x(d, i) + _this._width(d, i) / 2;
|
|
@@ -65,15 +87,15 @@ var Image = /*#__PURE__*/ function() {
|
|
|
65
87
|
var image = select(this), link = that._url(d, i);
|
|
66
88
|
var fullAddress = link.indexOf("http://") === 0 || link.indexOf("https://") === 0;
|
|
67
89
|
if (!fullAddress || link.indexOf(window.location.hostname) === 0) {
|
|
68
|
-
var img = new Image();
|
|
90
|
+
var img = new window.Image();
|
|
69
91
|
img.src = link;
|
|
70
92
|
img.crossOrigin = "Anonymous";
|
|
71
93
|
img.onload = function() {
|
|
72
94
|
var canvas = document.createElement("canvas");
|
|
73
|
-
canvas.width =
|
|
74
|
-
canvas.height =
|
|
95
|
+
canvas.width = img.width;
|
|
96
|
+
canvas.height = img.height;
|
|
75
97
|
var context = canvas.getContext("2d");
|
|
76
|
-
context.drawImage(
|
|
98
|
+
context.drawImage(img, 0, 0);
|
|
77
99
|
image.attr("xlink:href", canvas.toDataURL("image/png"));
|
|
78
100
|
};
|
|
79
101
|
}
|
|
@@ -92,146 +114,67 @@ var Image = /*#__PURE__*/ function() {
|
|
|
92
114
|
}
|
|
93
115
|
},
|
|
94
116
|
{
|
|
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",
|
|
117
|
+
key: "data",
|
|
101
118
|
value: function data(_) {
|
|
102
119
|
return arguments.length ? (this._data = _, this) : this._data;
|
|
103
120
|
}
|
|
104
121
|
},
|
|
105
122
|
{
|
|
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",
|
|
123
|
+
key: "duration",
|
|
112
124
|
value: function duration(_) {
|
|
113
125
|
return arguments.length ? (this._duration = _, this) : this._duration;
|
|
114
126
|
}
|
|
115
127
|
},
|
|
116
128
|
{
|
|
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",
|
|
129
|
+
key: "height",
|
|
127
130
|
value: function height(_) {
|
|
128
131
|
return arguments.length ? (this._height = typeof _ === "function" ? _ : constant(_), this) : this._height;
|
|
129
132
|
}
|
|
130
133
|
},
|
|
131
134
|
{
|
|
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",
|
|
135
|
+
key: "id",
|
|
142
136
|
value: function id(_) {
|
|
143
137
|
return arguments.length ? (this._id = _, this) : this._id;
|
|
144
138
|
}
|
|
145
139
|
},
|
|
146
140
|
{
|
|
147
|
-
|
|
148
|
-
@memberof Image
|
|
149
|
-
@desc Sets the opacity of the image.
|
|
150
|
-
@param {Number} [*value* = 1]
|
|
151
|
-
@chainable
|
|
152
|
-
*/ key: "opacity",
|
|
141
|
+
key: "opacity",
|
|
153
142
|
value: function opacity(_) {
|
|
154
143
|
return arguments.length ? (this._opacity = typeof _ === "function" ? _ : constant(_), this) : this._opacity;
|
|
155
144
|
}
|
|
156
145
|
},
|
|
157
146
|
{
|
|
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",
|
|
147
|
+
key: "pointerEvents",
|
|
164
148
|
value: function pointerEvents(_) {
|
|
165
149
|
return arguments.length ? (this._pointerEvents = typeof _ === "function" ? _ : constant(_), this) : this._pointerEvents;
|
|
166
150
|
}
|
|
167
151
|
},
|
|
168
152
|
{
|
|
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",
|
|
153
|
+
key: "select",
|
|
175
154
|
value: function select1(_) {
|
|
176
155
|
return arguments.length ? (this._select = select(_), this) : this._select;
|
|
177
156
|
}
|
|
178
157
|
},
|
|
179
158
|
{
|
|
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",
|
|
159
|
+
key: "url",
|
|
190
160
|
value: function url(_) {
|
|
191
161
|
return arguments.length ? (this._url = _, this) : this._url;
|
|
192
162
|
}
|
|
193
163
|
},
|
|
194
164
|
{
|
|
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",
|
|
165
|
+
key: "width",
|
|
205
166
|
value: function width(_) {
|
|
206
167
|
return arguments.length ? (this._width = typeof _ === "function" ? _ : constant(_), this) : this._width;
|
|
207
168
|
}
|
|
208
169
|
},
|
|
209
170
|
{
|
|
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",
|
|
171
|
+
key: "x",
|
|
220
172
|
value: function x(_) {
|
|
221
173
|
return arguments.length ? (this._x = typeof _ === "function" ? _ : constant(_), this) : this._x;
|
|
222
174
|
}
|
|
223
175
|
},
|
|
224
176
|
{
|
|
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",
|
|
177
|
+
key: "y",
|
|
235
178
|
value: function y(_) {
|
|
236
179
|
return arguments.length ? (this._y = typeof _ === "function" ? _ : constant(_), this) : this._y;
|
|
237
180
|
}
|
|
@@ -240,8 +183,7 @@ function(d) {
|
|
|
240
183
|
return Image;
|
|
241
184
|
}();
|
|
242
185
|
/**
|
|
243
|
-
|
|
244
|
-
@desc Creates SVG images based on an array of data.
|
|
186
|
+
Creates SVG images based on an array of data.
|
|
245
187
|
@example <caption>a sample row of data</caption>
|
|
246
188
|
var data = {"url": "file.png", "width": "100", "height": "50"};
|
|
247
189
|
@example <caption>passed to the generator</caption>
|
package/es/src/shapes/Line.js
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
function _array_like_to_array(arr, len) {
|
|
2
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
3
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
4
|
+
return arr2;
|
|
5
|
+
}
|
|
6
|
+
function _array_with_holes(arr) {
|
|
7
|
+
if (Array.isArray(arr)) return arr;
|
|
8
|
+
}
|
|
1
9
|
function _assert_this_initialized(self) {
|
|
2
10
|
if (self === void 0) {
|
|
3
11
|
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
@@ -62,6 +70,33 @@ function _inherits(subClass, superClass) {
|
|
|
62
70
|
});
|
|
63
71
|
if (superClass) _set_prototype_of(subClass, superClass);
|
|
64
72
|
}
|
|
73
|
+
function _iterable_to_array_limit(arr, i) {
|
|
74
|
+
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
75
|
+
if (_i == null) return;
|
|
76
|
+
var _arr = [];
|
|
77
|
+
var _n = true;
|
|
78
|
+
var _d = false;
|
|
79
|
+
var _s, _e;
|
|
80
|
+
try {
|
|
81
|
+
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
|
|
82
|
+
_arr.push(_s.value);
|
|
83
|
+
if (i && _arr.length === i) break;
|
|
84
|
+
}
|
|
85
|
+
} catch (err) {
|
|
86
|
+
_d = true;
|
|
87
|
+
_e = err;
|
|
88
|
+
} finally{
|
|
89
|
+
try {
|
|
90
|
+
if (!_n && _i["return"] != null) _i["return"]();
|
|
91
|
+
} finally{
|
|
92
|
+
if (_d) throw _e;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return _arr;
|
|
96
|
+
}
|
|
97
|
+
function _non_iterable_rest() {
|
|
98
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
99
|
+
}
|
|
65
100
|
function _possible_constructor_return(self, call) {
|
|
66
101
|
if (call && (_type_of(call) === "object" || typeof call === "function")) {
|
|
67
102
|
return call;
|
|
@@ -75,6 +110,9 @@ function _set_prototype_of(o, p) {
|
|
|
75
110
|
};
|
|
76
111
|
return _set_prototype_of(o, p);
|
|
77
112
|
}
|
|
113
|
+
function _sliced_to_array(arr, i) {
|
|
114
|
+
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
115
|
+
}
|
|
78
116
|
function _super_prop_base(object, property) {
|
|
79
117
|
while(!Object.prototype.hasOwnProperty.call(object, property)){
|
|
80
118
|
object = _get_prototype_of(object);
|
|
@@ -86,6 +124,14 @@ function _type_of(obj) {
|
|
|
86
124
|
"@swc/helpers - typeof";
|
|
87
125
|
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
88
126
|
}
|
|
127
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
128
|
+
if (!o) return;
|
|
129
|
+
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
130
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
131
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
132
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
133
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
134
|
+
}
|
|
89
135
|
function _is_native_reflect_construct() {
|
|
90
136
|
try {
|
|
91
137
|
var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
|
|
@@ -94,8 +140,7 @@ function _is_native_reflect_construct() {
|
|
|
94
140
|
return !!result;
|
|
95
141
|
})();
|
|
96
142
|
}
|
|
97
|
-
import { extent, sum } from "d3-array";
|
|
98
|
-
import { nest } from "d3-collection";
|
|
143
|
+
import { extent, groups, sum } from "d3-array";
|
|
99
144
|
import { interpolatePath } from "d3-interpolate-path";
|
|
100
145
|
import { select } from "d3-selection";
|
|
101
146
|
import * as paths from "d3-shape";
|
|
@@ -115,12 +160,12 @@ var Line = /*#__PURE__*/ function(Shape) {
|
|
|
115
160
|
};
|
|
116
161
|
_this._fill = constant("none");
|
|
117
162
|
_this._hitArea = constant({
|
|
118
|
-
|
|
163
|
+
d: function d(d) {
|
|
119
164
|
return _this._path(d.values);
|
|
120
165
|
},
|
|
121
|
-
|
|
166
|
+
fill: "none",
|
|
122
167
|
"stroke-width": 10,
|
|
123
|
-
|
|
168
|
+
transform: null
|
|
124
169
|
});
|
|
125
170
|
_this._name = "Line";
|
|
126
171
|
_this._path = paths.line();
|
|
@@ -131,14 +176,17 @@ var Line = /*#__PURE__*/ function(Shape) {
|
|
|
131
176
|
_create_class(Line, [
|
|
132
177
|
{
|
|
133
178
|
/**
|
|
134
|
-
|
|
135
|
-
@
|
|
136
|
-
|
|
137
|
-
@private
|
|
138
|
-
*/ key: "_dataFilter",
|
|
179
|
+
Filters/manipulates the data array before binding each point to an SVG group.
|
|
180
|
+
@param data @private
|
|
181
|
+
*/ key: "_dataFilter",
|
|
139
182
|
value: function _dataFilter(data) {
|
|
140
183
|
var _this = this;
|
|
141
|
-
var lines =
|
|
184
|
+
var lines = groups(data, this._id).map(function(param) {
|
|
185
|
+
var _param = _sliced_to_array(param, 2), key = _param[0], values = _param[1];
|
|
186
|
+
var d = {
|
|
187
|
+
key: key,
|
|
188
|
+
values: values
|
|
189
|
+
};
|
|
142
190
|
d.data = merge(d.values);
|
|
143
191
|
d.i = data.indexOf(d.values[0]);
|
|
144
192
|
var x = extent(d.values, _this._x);
|
|
@@ -165,20 +213,18 @@ var Line = /*#__PURE__*/ function(Shape) {
|
|
|
165
213
|
},
|
|
166
214
|
{
|
|
167
215
|
/**
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
@chainable
|
|
172
|
-
*/ key: "render",
|
|
216
|
+
Draws the lines.
|
|
217
|
+
@param callback Optional callback invoked after rendering completes.
|
|
218
|
+
*/ key: "render",
|
|
173
219
|
value: function render(callback) {
|
|
174
220
|
var _this = this;
|
|
175
221
|
_get(_get_prototype_of(Line.prototype), "render", this).call(this, callback);
|
|
176
222
|
var that = this;
|
|
177
223
|
/**
|
|
178
|
-
|
|
179
|
-
@param
|
|
224
|
+
Calculates the stroke-dasharray used for animations
|
|
225
|
+
@param d data point
|
|
180
226
|
@private
|
|
181
|
-
|
|
227
|
+
*/ function calculateStrokeDashArray(d) {
|
|
182
228
|
d.initialLength = this.getTotalLength();
|
|
183
229
|
var strokeArray = that._strokeDasharray(d.values[0], that._data.indexOf(d.values[0])).split(" ").map(Number);
|
|
184
230
|
if (strokeArray.length === 1 && strokeArray[0] === 0) strokeArray = [
|
|
@@ -203,6 +249,7 @@ var Line = /*#__PURE__*/ function(Shape) {
|
|
|
203
249
|
}
|
|
204
250
|
var userCurve = this._curve.bind(this)(this.config());
|
|
205
251
|
var curve = paths["curve".concat(userCurve.charAt(0).toUpperCase()).concat(userCurve.slice(1))];
|
|
252
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
206
253
|
this._path.curve(curve).defined(this._defined).x(this._x).y(this._y);
|
|
207
254
|
var enter = this._enter.append("path").attr("transform", function(d) {
|
|
208
255
|
return "translate(".concat(-d.xR[0] - d.width / 2, ", ").concat(-d.yR[0] - d.height / 2, ")");
|
|
@@ -221,6 +268,7 @@ var Line = /*#__PURE__*/ function(Shape) {
|
|
|
221
268
|
update = update.transition(this._transition).attrTween("d", function(d) {
|
|
222
269
|
return interpolatePath(select(this).attr("d"), that._path(d.values));
|
|
223
270
|
});
|
|
271
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
224
272
|
this._exit.selectAll("path").each(calculateStrokeDashArray).attr("stroke-dasharray", function(d) {
|
|
225
273
|
return "".concat(d.initialStrokeArray, " ").concat(d.initialLength);
|
|
226
274
|
}).transition(this._transition).attr("stroke-dashoffset", function(d) {
|
|
@@ -239,12 +287,10 @@ var Line = /*#__PURE__*/ function(Shape) {
|
|
|
239
287
|
},
|
|
240
288
|
{
|
|
241
289
|
/**
|
|
242
|
-
|
|
243
|
-
@
|
|
244
|
-
@param
|
|
245
|
-
|
|
246
|
-
@private
|
|
247
|
-
*/ key: "_aes",
|
|
290
|
+
Given a specific data point and index, returns the aesthetic properties of the shape.
|
|
291
|
+
@param data point*
|
|
292
|
+
@param index @private
|
|
293
|
+
*/ key: "_aes",
|
|
248
294
|
value: function _aes(d, i) {
|
|
249
295
|
var _this = this;
|
|
250
296
|
return {
|
|
@@ -258,23 +304,13 @@ var Line = /*#__PURE__*/ function(Shape) {
|
|
|
258
304
|
}
|
|
259
305
|
},
|
|
260
306
|
{
|
|
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",
|
|
307
|
+
key: "curve",
|
|
267
308
|
value: function curve(_) {
|
|
268
309
|
return arguments.length ? (this._curve = typeof _ === "function" ? _ : constant(_), this) : this._curve;
|
|
269
310
|
}
|
|
270
311
|
},
|
|
271
312
|
{
|
|
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",
|
|
313
|
+
key: "defined",
|
|
278
314
|
value: function defined(_) {
|
|
279
315
|
return arguments.length ? (this._defined = _, this) : this._defined;
|
|
280
316
|
}
|
|
@@ -283,7 +319,5 @@ var Line = /*#__PURE__*/ function(Shape) {
|
|
|
283
319
|
return Line;
|
|
284
320
|
}(Shape);
|
|
285
321
|
/**
|
|
286
|
-
|
|
287
|
-
@extends Shape
|
|
288
|
-
@desc Creates SVG lines based on an array of data.
|
|
322
|
+
Creates SVG lines based on an array of data.
|
|
289
323
|
*/ export { Line as default };
|
package/es/src/shapes/Path.js
CHANGED
|
@@ -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(target, property, receiver) {
|
|
31
44
|
if (typeof Reflect !== "undefined" && Reflect.get) {
|
|
32
45
|
_get = Reflect.get;
|
|
@@ -105,7 +118,7 @@ var Path = /*#__PURE__*/ function(Shape) {
|
|
|
105
118
|
var _this;
|
|
106
119
|
_this = _call_super(this, Path, [
|
|
107
120
|
"path"
|
|
108
|
-
]);
|
|
121
|
+
]), _define_property(_this, "_d", void 0);
|
|
109
122
|
_this._d = accessor("path");
|
|
110
123
|
_this._labelBounds = function(d, i, aes) {
|
|
111
124
|
var r = largestRect(aes.points, {
|
|
@@ -129,12 +142,10 @@ var Path = /*#__PURE__*/ function(Shape) {
|
|
|
129
142
|
_create_class(Path, [
|
|
130
143
|
{
|
|
131
144
|
/**
|
|
132
|
-
|
|
133
|
-
@
|
|
134
|
-
@param
|
|
135
|
-
|
|
136
|
-
@private
|
|
137
|
-
*/ key: "_aes",
|
|
145
|
+
Given a specific data point and index, returns the aesthetic properties of the shape.
|
|
146
|
+
@param data point*
|
|
147
|
+
@param index @private
|
|
148
|
+
*/ key: "_aes",
|
|
138
149
|
value: function _aes(d, i) {
|
|
139
150
|
return {
|
|
140
151
|
points: path2polygon(this._d(d, i))
|
|
@@ -143,11 +154,9 @@ var Path = /*#__PURE__*/ function(Shape) {
|
|
|
143
154
|
},
|
|
144
155
|
{
|
|
145
156
|
/**
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
@chainable
|
|
150
|
-
*/ key: "render",
|
|
157
|
+
Draws the paths.
|
|
158
|
+
@param callback Optional callback invoked after rendering completes.
|
|
159
|
+
*/ key: "render",
|
|
151
160
|
value: function render(callback) {
|
|
152
161
|
_get(_get_prototype_of(Path.prototype), "render", this).call(this, callback);
|
|
153
162
|
var enter = this._enter.attr("d", this._d).call(this._applyStyle.bind(this));
|
|
@@ -162,16 +171,7 @@ var Path = /*#__PURE__*/ function(Shape) {
|
|
|
162
171
|
}
|
|
163
172
|
},
|
|
164
173
|
{
|
|
165
|
-
|
|
166
|
-
@memberof Path
|
|
167
|
-
@desc If *value* is specified, sets the "d" attribute accessor to the specified function or number and returns the current class instance.
|
|
168
|
-
@param {Function|String} [*value*]
|
|
169
|
-
@chainable
|
|
170
|
-
@example
|
|
171
|
-
function(d) {
|
|
172
|
-
return d.path;
|
|
173
|
-
}
|
|
174
|
-
*/ key: "d",
|
|
174
|
+
key: "d",
|
|
175
175
|
value: function d(_) {
|
|
176
176
|
return arguments.length ? (this._d = typeof _ === "function" ? _ : constant(_), this) : this._d;
|
|
177
177
|
}
|
|
@@ -180,7 +180,5 @@ function(d) {
|
|
|
180
180
|
return Path;
|
|
181
181
|
}(Shape);
|
|
182
182
|
/**
|
|
183
|
-
|
|
184
|
-
@extends Shape
|
|
185
|
-
@desc Creates SVG Paths based on an array of data.
|
|
183
|
+
Creates SVG Paths based on an array of data.
|
|
186
184
|
*/ export { Path as default };
|
package/es/src/shapes/Rect.js
CHANGED
|
@@ -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(target, property, receiver) {
|
|
31
44
|
if (typeof Reflect !== "undefined" && Reflect.get) {
|
|
32
45
|
_get = Reflect.get;
|
|
@@ -104,9 +117,9 @@ var Rect = /*#__PURE__*/ function(Shape) {
|
|
|
104
117
|
var _this;
|
|
105
118
|
_this = _call_super(this, Rect, [
|
|
106
119
|
"rect"
|
|
107
|
-
]);
|
|
120
|
+
]), _define_property(_this, "_height", void 0), _define_property(_this, "_width", void 0);
|
|
108
121
|
_this._height = accessor("height");
|
|
109
|
-
_this._labelBounds = function(
|
|
122
|
+
_this._labelBounds = function(_d, _i, s) {
|
|
110
123
|
return {
|
|
111
124
|
width: s.width,
|
|
112
125
|
height: s.height,
|
|
@@ -121,11 +134,9 @@ var Rect = /*#__PURE__*/ function(Shape) {
|
|
|
121
134
|
_create_class(Rect, [
|
|
122
135
|
{
|
|
123
136
|
/**
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
@chainable
|
|
128
|
-
*/ key: "render",
|
|
137
|
+
Draws the rectangles.
|
|
138
|
+
@param callback Optional callback invoked after rendering completes.
|
|
139
|
+
*/ key: "render",
|
|
129
140
|
value: function render(callback) {
|
|
130
141
|
_get(_get_prototype_of(Rect.prototype), "render", this).call(this, callback);
|
|
131
142
|
var enter = this._enter.attr("width", 0).attr("height", 0).attr("x", 0).attr("y", 0).call(this._applyStyle.bind(this));
|
|
@@ -142,12 +153,10 @@ var Rect = /*#__PURE__*/ function(Shape) {
|
|
|
142
153
|
},
|
|
143
154
|
{
|
|
144
155
|
/**
|
|
145
|
-
|
|
146
|
-
@
|
|
147
|
-
@param
|
|
148
|
-
|
|
149
|
-
@private
|
|
150
|
-
*/ key: "_aes",
|
|
156
|
+
Given a specific data point and index, returns the aesthetic properties of the shape.
|
|
157
|
+
@param data point*
|
|
158
|
+
@param index @private
|
|
159
|
+
*/ key: "_aes",
|
|
151
160
|
value: function _aes(d, i) {
|
|
152
161
|
return {
|
|
153
162
|
width: this._width(d, i),
|
|
@@ -157,13 +166,12 @@ var Rect = /*#__PURE__*/ function(Shape) {
|
|
|
157
166
|
},
|
|
158
167
|
{
|
|
159
168
|
/**
|
|
160
|
-
|
|
161
|
-
@
|
|
162
|
-
|
|
163
|
-
@private
|
|
164
|
-
*/ key: "_applyPosition",
|
|
169
|
+
Provides the default positioning to the <rect> elements.
|
|
170
|
+
@param elem @private
|
|
171
|
+
*/ key: "_applyPosition",
|
|
165
172
|
value: function _applyPosition(elem) {
|
|
166
173
|
var _this = this;
|
|
174
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
167
175
|
elem.attr("width", function(d, i) {
|
|
168
176
|
return _this._width(d, i);
|
|
169
177
|
}).attr("height", function(d, i) {
|
|
@@ -176,31 +184,13 @@ var Rect = /*#__PURE__*/ function(Shape) {
|
|
|
176
184
|
}
|
|
177
185
|
},
|
|
178
186
|
{
|
|
179
|
-
|
|
180
|
-
@memberof Rect
|
|
181
|
-
@desc If *value* is specified, sets the height accessor to the specified function or number and returns the current class instance.
|
|
182
|
-
@param {Function|Number} [*value*]
|
|
183
|
-
@chainable
|
|
184
|
-
@example
|
|
185
|
-
function(d) {
|
|
186
|
-
return d.height;
|
|
187
|
-
}
|
|
188
|
-
*/ key: "height",
|
|
187
|
+
key: "height",
|
|
189
188
|
value: function height(_) {
|
|
190
189
|
return arguments.length ? (this._height = typeof _ === "function" ? _ : constant(_), this) : this._height;
|
|
191
190
|
}
|
|
192
191
|
},
|
|
193
192
|
{
|
|
194
|
-
|
|
195
|
-
@memberof Rect
|
|
196
|
-
@desc If *value* is specified, sets the width accessor to the specified function or number and returns the current class instance.
|
|
197
|
-
@param {Function|Number} [*value*]
|
|
198
|
-
@chainable
|
|
199
|
-
@example
|
|
200
|
-
function(d) {
|
|
201
|
-
return d.width;
|
|
202
|
-
}
|
|
203
|
-
*/ key: "width",
|
|
193
|
+
key: "width",
|
|
204
194
|
value: function width(_) {
|
|
205
195
|
return arguments.length ? (this._width = typeof _ === "function" ? _ : constant(_), this) : this._width;
|
|
206
196
|
}
|
|
@@ -209,7 +199,5 @@ function(d) {
|
|
|
209
199
|
return Rect;
|
|
210
200
|
}(Shape);
|
|
211
201
|
/**
|
|
212
|
-
|
|
213
|
-
@extends Shape
|
|
214
|
-
@desc Creates SVG rectangles based on an array of data. See [this example](https://d3plus.org/examples/d3plus-shape/getting-started/) for help getting started using the rectangle generator.
|
|
202
|
+
Creates SVG rectangles based on an array of data. See [this example](https://d3plus.org/examples/d3plus-shape/getting-started/) for help getting started using the rectangle generator.
|
|
215
203
|
*/ export { Rect as default };
|