@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
|
@@ -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;
|
|
@@ -63,6 +76,7 @@ function _inherits(subClass, superClass) {
|
|
|
63
76
|
if (superClass) _set_prototype_of(subClass, superClass);
|
|
64
77
|
}
|
|
65
78
|
function _instanceof(left, right) {
|
|
79
|
+
"@swc/helpers - instanceof";
|
|
66
80
|
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
|
|
67
81
|
return !!right[Symbol.hasInstance](left);
|
|
68
82
|
} else {
|
|
@@ -105,8 +119,8 @@ import { extent, max, min } from "d3-array";
|
|
|
105
119
|
import { brushX } from "d3-brush";
|
|
106
120
|
import { scaleTime } from "d3-scale";
|
|
107
121
|
import { pointers } from "d3-selection";
|
|
108
|
-
import { colorDefaults } from "@d3plus/color";
|
|
109
|
-
import { assign, attrize, date, elem, textWidth } from "@d3plus/dom";
|
|
122
|
+
import { colorContrast, colorDefaults } from "@d3plus/color";
|
|
123
|
+
import { assign, attrize, backgroundColor, date, elem, textWidth } from "@d3plus/dom";
|
|
110
124
|
import { formatDate } from "@d3plus/format";
|
|
111
125
|
import { locale } from "@d3plus/locales";
|
|
112
126
|
import { closest } from "@d3plus/math";
|
|
@@ -120,9 +134,11 @@ var Timeline = /*#__PURE__*/ function(Axis) {
|
|
|
120
134
|
function Timeline() {
|
|
121
135
|
_class_call_check(this, Timeline);
|
|
122
136
|
var _this;
|
|
123
|
-
_this = _call_super(this, Timeline)
|
|
137
|
+
_this = _call_super(this, Timeline), _define_property(_this, "_brushing", void 0), _define_property(_this, "_brushFilter", void 0), _define_property(_this, "_brushMin", void 0), _define_property(_this, "_buttonAlign", void 0), _define_property(_this, "_buttonBehavior", void 0), _define_property(_this, "_buttonBehaviorCurrent", void 0), _define_property(_this, "_buttonPadding", void 0), _define_property(_this, "_buttonHeight", void 0), _define_property(_this, "_handleConfig", void 0), _define_property(_this, "_handleSize", void 0), _define_property(_this, "_hiddenHandles", void 0), _define_property(_this, "_playButton", void 0), _define_property(_this, "_playButtonClass", void 0), _define_property(_this, "_playButtonConfig", void 0), _define_property(_this, "_playButtonInterval", void 0), _define_property(_this, "_playTimer", void 0), _define_property(_this, "_selection", void 0), _define_property(_this, "_selectionConfig", void 0), _define_property(_this, "_snapping", void 0), // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
138
|
+
_define_property(_this, "_brush", void 0), // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
139
|
+
_define_property(_this, "_brushGroup", void 0), _define_property(_this, "_paddingLeft", void 0), _define_property(_this, "_ticksWidth", void 0);
|
|
124
140
|
_this._barConfig = assign({}, _this._barConfig, {
|
|
125
|
-
stroke: function() {
|
|
141
|
+
stroke: function stroke() {
|
|
126
142
|
return _this._buttonBehaviorCurrent === "buttons" ? "transparent" : colorMid;
|
|
127
143
|
},
|
|
128
144
|
"stroke-width": function() {
|
|
@@ -131,7 +147,8 @@ var Timeline = /*#__PURE__*/ function(Axis) {
|
|
|
131
147
|
});
|
|
132
148
|
_this._brushing = true;
|
|
133
149
|
_this._brushFilter = function(event) {
|
|
134
|
-
|
|
150
|
+
var e = event;
|
|
151
|
+
return !e.button && e.detail < 2;
|
|
135
152
|
};
|
|
136
153
|
_this._brushMin = constant(1);
|
|
137
154
|
_this._buttonAlign = "middle";
|
|
@@ -159,12 +176,12 @@ var Timeline = /*#__PURE__*/ function(Axis) {
|
|
|
159
176
|
_this._playButtonClass = new TextBox().on("click", function() {
|
|
160
177
|
// if playing, pause
|
|
161
178
|
if (_this._playTimer) {
|
|
162
|
-
clearInterval(_this._playTimer);
|
|
179
|
+
if (_this._playTimer) clearInterval(_this._playTimer);
|
|
163
180
|
_this._playTimer = false;
|
|
164
181
|
_this._playButtonClass.render();
|
|
165
182
|
} else {
|
|
166
183
|
var firstTime = true;
|
|
167
|
-
var nextYear = function() {
|
|
184
|
+
var nextYear = function nextYear() {
|
|
168
185
|
var selection = _this._selection || [
|
|
169
186
|
_this._domain[_this._domain.length - 1]
|
|
170
187
|
];
|
|
@@ -178,7 +195,7 @@ var Timeline = /*#__PURE__*/ function(Axis) {
|
|
|
178
195
|
var lastIndex = ticks.indexOf(selection[selection.length - 1]);
|
|
179
196
|
if (lastIndex === ticks.length - 1) {
|
|
180
197
|
if (!firstTime) {
|
|
181
|
-
clearInterval(_this._playTimer);
|
|
198
|
+
if (_this._playTimer) clearInterval(_this._playTimer);
|
|
182
199
|
_this._playTimer = false;
|
|
183
200
|
_this._playButtonClass.render();
|
|
184
201
|
} else {
|
|
@@ -189,7 +206,7 @@ var Timeline = /*#__PURE__*/ function(Axis) {
|
|
|
189
206
|
}
|
|
190
207
|
} else {
|
|
191
208
|
if (lastIndex + 1 === ticks.length - 1) {
|
|
192
|
-
clearInterval(_this._playTimer);
|
|
209
|
+
if (_this._playTimer) clearInterval(_this._playTimer);
|
|
193
210
|
_this._playTimer = false;
|
|
194
211
|
}
|
|
195
212
|
_this.selection([
|
|
@@ -208,8 +225,8 @@ var Timeline = /*#__PURE__*/ function(Axis) {
|
|
|
208
225
|
_this._playButtonConfig = {
|
|
209
226
|
fontColor: colorDefaults.dark,
|
|
210
227
|
fontSize: 15,
|
|
211
|
-
text: function() {
|
|
212
|
-
return _this._playTimer ? "
|
|
228
|
+
text: function text() {
|
|
229
|
+
return _this._playTimer ? "\u23F8" : "\u23F5";
|
|
213
230
|
},
|
|
214
231
|
textAnchor: "middle",
|
|
215
232
|
verticalAlign: "middle"
|
|
@@ -224,7 +241,7 @@ var Timeline = /*#__PURE__*/ function(Axis) {
|
|
|
224
241
|
};
|
|
225
242
|
_this._shape = "Rect";
|
|
226
243
|
_this._shapeConfig = assign({}, _this._shapeConfig, {
|
|
227
|
-
labelBounds: function(d) {
|
|
244
|
+
labelBounds: function labelBounds(d) {
|
|
228
245
|
return _this._buttonBehaviorCurrent === "buttons" ? {
|
|
229
246
|
x: d.labelBounds.x,
|
|
230
247
|
y: -_this._buttonHeight / 2 + 1,
|
|
@@ -233,49 +250,55 @@ var Timeline = /*#__PURE__*/ function(Axis) {
|
|
|
233
250
|
} : d.labelBounds;
|
|
234
251
|
},
|
|
235
252
|
labelConfig: {
|
|
236
|
-
fontColor:
|
|
237
|
-
|
|
253
|
+
fontColor: function fontColor() {
|
|
254
|
+
var bg = _this._select ? backgroundColor(_this._select.node()) : "rgb(255, 255, 255)";
|
|
255
|
+
return colorContrast(bg);
|
|
256
|
+
},
|
|
257
|
+
fontSize: function fontSize() {
|
|
238
258
|
return 12;
|
|
239
259
|
},
|
|
240
|
-
verticalAlign: function() {
|
|
260
|
+
verticalAlign: function verticalAlign() {
|
|
241
261
|
return _this._buttonBehaviorCurrent === "buttons" ? "middle" : "top";
|
|
242
262
|
}
|
|
243
263
|
},
|
|
244
|
-
fill: function() {
|
|
264
|
+
fill: function fill() {
|
|
245
265
|
return _this._buttonBehaviorCurrent === "buttons" ? "#fff" : colorMid;
|
|
246
266
|
},
|
|
247
|
-
stroke: function() {
|
|
267
|
+
stroke: function stroke() {
|
|
248
268
|
return _this._buttonBehaviorCurrent === "buttons" ? colorMid : "transparent";
|
|
249
269
|
},
|
|
250
|
-
height: function(d) {
|
|
270
|
+
height: function height(d) {
|
|
251
271
|
return _this._buttonBehaviorCurrent === "buttons" ? _this._buttonHeight : d.tick ? _this._handleSize : 0;
|
|
252
272
|
},
|
|
253
|
-
width: function(d) {
|
|
273
|
+
width: function width(d) {
|
|
254
274
|
return _this._buttonBehaviorCurrent === "buttons" ? _this._ticksWidth / _this._availableTicks.length : d.tick ? _this._domain.map(Number).includes(d.id) ? 2 : 1 : 0;
|
|
255
275
|
},
|
|
256
|
-
y: function(d) {
|
|
276
|
+
y: function y(d) {
|
|
257
277
|
return _this._buttonBehaviorCurrent === "buttons" ? _this._align === "middle" ? _this._height / 2 : _this._align === "start" ? _this._margin.top + _this._buttonHeight / 2 : _this._height - _this._buttonHeight / 2 - _this._margin.bottom : d.y;
|
|
258
278
|
},
|
|
259
|
-
rx: function(d) {
|
|
279
|
+
rx: function rx(d) {
|
|
260
280
|
return _this._buttonBehaviorCurrent === "buttons" ? 0 : _this._domain.map(Number).includes(d.id) ? 1 : 0;
|
|
261
281
|
},
|
|
262
|
-
ry: function(d) {
|
|
282
|
+
ry: function ry(d) {
|
|
263
283
|
return _this._buttonBehaviorCurrent === "buttons" ? 0 : _this._domain.map(Number).includes(d.id) ? 1 : 0;
|
|
264
284
|
}
|
|
265
285
|
});
|
|
266
286
|
_this._snapping = true;
|
|
287
|
+
_this._buttonBehaviorCurrent = "auto";
|
|
288
|
+
_this._hiddenHandles = false;
|
|
289
|
+
_this._paddingLeft = 0;
|
|
290
|
+
_this._ticksWidth = 0;
|
|
267
291
|
return _this;
|
|
268
292
|
}
|
|
269
293
|
_create_class(Timeline, [
|
|
270
294
|
{
|
|
271
295
|
/**
|
|
272
|
-
|
|
273
|
-
@desc Triggered on brush "brush".
|
|
296
|
+
Triggered on brush "brush".
|
|
274
297
|
@private
|
|
275
|
-
|
|
298
|
+
*/ key: "_brushBrush",
|
|
276
299
|
value: function _brushBrush(event) {
|
|
277
300
|
if (event.sourceEvent && event.sourceEvent.offsetX && event.selection !== null && (!this._brushing || this._snapping)) {
|
|
278
|
-
clearInterval(this._playTimer);
|
|
301
|
+
if (this._playTimer) clearInterval(this._playTimer);
|
|
279
302
|
this._playTimer = false;
|
|
280
303
|
this._playButtonClass.render();
|
|
281
304
|
var domain = this._updateDomain(event);
|
|
@@ -287,10 +310,9 @@ var Timeline = /*#__PURE__*/ function(Axis) {
|
|
|
287
310
|
},
|
|
288
311
|
{
|
|
289
312
|
/**
|
|
290
|
-
|
|
291
|
-
@desc Triggered on brush "end".
|
|
313
|
+
Triggered on brush "end".
|
|
292
314
|
@private
|
|
293
|
-
|
|
315
|
+
*/ key: "_brushEnd",
|
|
294
316
|
value: function _brushEnd(event) {
|
|
295
317
|
if (!event.sourceEvent) return; // Only transition after input.
|
|
296
318
|
var domain = this._updateDomain(event);
|
|
@@ -301,13 +323,12 @@ var Timeline = /*#__PURE__*/ function(Axis) {
|
|
|
301
323
|
},
|
|
302
324
|
{
|
|
303
325
|
/**
|
|
304
|
-
|
|
305
|
-
@desc Triggered on brush "start".
|
|
326
|
+
Triggered on brush "start".
|
|
306
327
|
@private
|
|
307
|
-
|
|
328
|
+
*/ key: "_brushStart",
|
|
308
329
|
value: function _brushStart(event) {
|
|
309
330
|
if (event.sourceEvent !== null && (!this._brushing || this._snapping)) {
|
|
310
|
-
clearInterval(this._playTimer);
|
|
331
|
+
if (this._playTimer) clearInterval(this._playTimer);
|
|
311
332
|
this._playTimer = false;
|
|
312
333
|
this._playButtonClass.render();
|
|
313
334
|
var domain = this._updateDomain(event);
|
|
@@ -319,10 +340,9 @@ var Timeline = /*#__PURE__*/ function(Axis) {
|
|
|
319
340
|
},
|
|
320
341
|
{
|
|
321
342
|
/**
|
|
322
|
-
|
|
323
|
-
@desc Overrides the default brush styles.
|
|
343
|
+
Overrides the default brush styles.
|
|
324
344
|
@private
|
|
325
|
-
|
|
345
|
+
*/ key: "_brushStyle",
|
|
326
346
|
value: function _brushStyle() {
|
|
327
347
|
var _this = this;
|
|
328
348
|
var height = this._position.height;
|
|
@@ -345,10 +365,9 @@ var Timeline = /*#__PURE__*/ function(Axis) {
|
|
|
345
365
|
},
|
|
346
366
|
{
|
|
347
367
|
/**
|
|
348
|
-
|
|
349
|
-
@desc Updates domain of the timeline used in brush functions.
|
|
368
|
+
Updates domain of the timeline used in brush functions.
|
|
350
369
|
@private
|
|
351
|
-
|
|
370
|
+
*/ key: "_updateDomain",
|
|
352
371
|
value: function _updateDomain(event) {
|
|
353
372
|
var x = pointers(event, this._select.node());
|
|
354
373
|
var domain = event.selection && this._brushing || !x.length ? event.selection : [
|
|
@@ -361,14 +380,16 @@ var Timeline = /*#__PURE__*/ function(Axis) {
|
|
|
361
380
|
var diffs = event.selection.map(function(d) {
|
|
362
381
|
return Math.abs(d - event.sourceEvent.offsetX);
|
|
363
382
|
});
|
|
383
|
+
var sel = event.selection;
|
|
384
|
+
var offsetX = event.sourceEvent.offsetX;
|
|
364
385
|
domain = diffs[1] <= diffs[0] ? [
|
|
365
|
-
|
|
366
|
-
|
|
386
|
+
sel[0],
|
|
387
|
+
offsetX
|
|
367
388
|
].sort(function(a, b) {
|
|
368
389
|
return a - b;
|
|
369
390
|
}) : [
|
|
370
|
-
|
|
371
|
-
|
|
391
|
+
offsetX,
|
|
392
|
+
sel[1]
|
|
372
393
|
].sort(function(a, b) {
|
|
373
394
|
return a - b;
|
|
374
395
|
});
|
|
@@ -427,10 +448,9 @@ var Timeline = /*#__PURE__*/ function(Axis) {
|
|
|
427
448
|
},
|
|
428
449
|
{
|
|
429
450
|
/**
|
|
430
|
-
|
|
431
|
-
@desc Updates limits of the brush.
|
|
451
|
+
Updates limits of the brush.
|
|
432
452
|
@private
|
|
433
|
-
|
|
453
|
+
*/ key: "_updateBrushLimit",
|
|
434
454
|
value: function _updateBrushLimit(domain) {
|
|
435
455
|
var selection = this._buttonBehaviorCurrent === "ticks" ? domain.map(date).map(this._d3Scale) : domain;
|
|
436
456
|
if (selection[0] === selection[1]) {
|
|
@@ -448,11 +468,9 @@ var Timeline = /*#__PURE__*/ function(Axis) {
|
|
|
448
468
|
},
|
|
449
469
|
{
|
|
450
470
|
/**
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
@chainable
|
|
455
|
-
*/ key: "render",
|
|
471
|
+
Draws the timeline.
|
|
472
|
+
@param callback Optional callback invoked after rendering completes.
|
|
473
|
+
*/ key: "render",
|
|
456
474
|
value: function render(callback) {
|
|
457
475
|
var _this = this;
|
|
458
476
|
var _this__position = this._position, height = _this__position.height, y = _this__position.y;
|
|
@@ -566,187 +584,103 @@ var Timeline = /*#__PURE__*/ function(Axis) {
|
|
|
566
584
|
width: playButtonWidth,
|
|
567
585
|
height: this._buttonHeight
|
|
568
586
|
}
|
|
569
|
-
] : []).select(playButtonGroup.node())
|
|
587
|
+
] : []).select(playButtonGroup.node())// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
588
|
+
.config(configPrep.bind(this)(this._playButtonConfig)).render();
|
|
570
589
|
return this;
|
|
571
590
|
}
|
|
572
591
|
},
|
|
573
592
|
{
|
|
574
|
-
|
|
575
|
-
@memberof Timeline
|
|
576
|
-
@desc If *value* is specified, sets the button padding and returns the current class instance. If *value* is not specified, returns the current button padding.
|
|
577
|
-
@param {Number} [*value* = 10]
|
|
578
|
-
@chainable
|
|
579
|
-
*/ key: "buttonPadding",
|
|
593
|
+
key: "buttonPadding",
|
|
580
594
|
value: function buttonPadding(_) {
|
|
581
595
|
return arguments.length ? (this._buttonPadding = _, this) : this._buttonPadding;
|
|
582
596
|
}
|
|
583
597
|
},
|
|
584
598
|
{
|
|
585
|
-
|
|
586
|
-
@memberof Timeline
|
|
587
|
-
@desc If *value* is specified, toggles the brushing value and returns the current class instance. If *value* is not specified, returns the current brushing value.
|
|
588
|
-
@param {Boolean} [*value* = true]
|
|
589
|
-
@chainable
|
|
590
|
-
*/ key: "brushing",
|
|
599
|
+
key: "brushing",
|
|
591
600
|
value: function brushing(_) {
|
|
592
601
|
return arguments.length ? (this._brushing = _, this) : this._brushing;
|
|
593
602
|
}
|
|
594
603
|
},
|
|
595
604
|
{
|
|
596
|
-
|
|
597
|
-
@memberof Timeline
|
|
598
|
-
@desc If *value* is specified, sets the brush event filter and returns the current class instance. If *value* is not specified, returns the current brush event filter.
|
|
599
|
-
@param {Function} [*value*]
|
|
600
|
-
@chainable
|
|
601
|
-
@example
|
|
602
|
-
function() {
|
|
603
|
-
return !event.button && event.detail < 2;
|
|
604
|
-
}
|
|
605
|
-
*/ key: "brushFilter",
|
|
605
|
+
key: "brushFilter",
|
|
606
606
|
value: function brushFilter(_) {
|
|
607
607
|
return arguments.length ? (this._brushFilter = _, this) : this._brushFilter;
|
|
608
608
|
}
|
|
609
609
|
},
|
|
610
610
|
{
|
|
611
|
-
|
|
612
|
-
@memberof Timeline
|
|
613
|
-
@desc Sets the minimum number of "ticks" to allow to be highlighted when using "ticks" buttonBehavior. Helpful when using x/y plots where you don't want the user to select less than 2 time periods. Value passed can either be a static Number, or a function that is expected to return a Number.
|
|
614
|
-
@param {Number|Function} [*value* = 1]
|
|
615
|
-
@chainable
|
|
616
|
-
*/ key: "brushMin",
|
|
611
|
+
key: "brushMin",
|
|
617
612
|
value: function brushMin(_) {
|
|
618
613
|
return arguments.length ? (this._brushMin = typeof _ === "function" ? _ : constant(_), this) : this._brushMin;
|
|
619
614
|
}
|
|
620
615
|
},
|
|
621
616
|
{
|
|
622
|
-
|
|
623
|
-
@memberof Timeline
|
|
624
|
-
@desc If *value* is specified, toggles the horizontal alignment of the button timeline. Accepted values are `"start"`, `"middle"` and `"end"`. If *value* is not specified, returns the current button value.
|
|
625
|
-
@param {String} [*value* = "middle"]
|
|
626
|
-
@chainable
|
|
627
|
-
*/ key: "buttonAlign",
|
|
617
|
+
key: "buttonAlign",
|
|
628
618
|
value: function buttonAlign(_) {
|
|
629
619
|
return arguments.length ? (this._buttonAlign = _, this) : this._buttonAlign;
|
|
630
620
|
}
|
|
631
621
|
},
|
|
632
622
|
{
|
|
633
|
-
|
|
634
|
-
@memberof Timeline
|
|
635
|
-
@desc If *value* is specified, toggles the style of the timeline. Accepted values are `"auto"`, `"buttons"` and `"ticks"`. If *value* is not specified, returns the current button value.
|
|
636
|
-
@param {String} [*value* = "auto"]
|
|
637
|
-
@chainable
|
|
638
|
-
*/ key: "buttonBehavior",
|
|
623
|
+
key: "buttonBehavior",
|
|
639
624
|
value: function buttonBehavior(_) {
|
|
640
625
|
return arguments.length ? (this._buttonBehavior = _, this) : this._buttonBehavior;
|
|
641
626
|
}
|
|
642
627
|
},
|
|
643
628
|
{
|
|
644
|
-
|
|
645
|
-
@memberof Timeline
|
|
646
|
-
@desc If *value* is specified, sets the button height and returns the current class instance. If *value* is not specified, returns the current button height.
|
|
647
|
-
@param {Number} [*value* = 30]
|
|
648
|
-
@chainable
|
|
649
|
-
*/ key: "buttonHeight",
|
|
629
|
+
key: "buttonHeight",
|
|
650
630
|
value: function buttonHeight(_) {
|
|
651
631
|
return arguments.length ? (this._buttonHeight = _, this) : this._buttonHeight;
|
|
652
632
|
}
|
|
653
633
|
},
|
|
654
634
|
{
|
|
655
|
-
|
|
656
|
-
@memberof Timeline
|
|
657
|
-
@desc If *value* is specified, sets the handle style and returns the current class instance. If *value* is not specified, returns the current handle style.
|
|
658
|
-
@param {Object} [*value*]
|
|
659
|
-
@chainable
|
|
660
|
-
*/ key: "handleConfig",
|
|
635
|
+
key: "handleConfig",
|
|
661
636
|
value: function handleConfig(_) {
|
|
662
637
|
return arguments.length ? (this._handleConfig = assign(this._handleConfig, _), this) : this._handleConfig;
|
|
663
638
|
}
|
|
664
639
|
},
|
|
665
640
|
{
|
|
666
|
-
|
|
667
|
-
@memberof Timeline
|
|
668
|
-
@desc If *value* is specified, sets the handle size and returns the current class instance. If *value* is not specified, returns the current handle size.
|
|
669
|
-
@param {Number} [*value* = 6]
|
|
670
|
-
@chainable
|
|
671
|
-
*/ key: "handleSize",
|
|
641
|
+
key: "handleSize",
|
|
672
642
|
value: function handleSize(_) {
|
|
673
643
|
return arguments.length ? (this._handleSize = _, this) : this._handleSize;
|
|
674
644
|
}
|
|
675
645
|
},
|
|
676
646
|
{
|
|
677
|
-
|
|
678
|
-
@memberof Timeline
|
|
679
|
-
@desc Adds or removes a *listener* for the specified brush event *typename*. If a *listener* is not specified, returns the currently-assigned listener for the specified event *typename*. Mirrors the core [d3-brush](https://github.com/d3/d3-brush#brush_on) behavior.
|
|
680
|
-
@param {String|Object} [*typename*]
|
|
681
|
-
@param {Function} [*listener*]
|
|
682
|
-
@chainable
|
|
683
|
-
*/ key: "on",
|
|
647
|
+
key: "on",
|
|
684
648
|
value: function on(_, f) {
|
|
685
649
|
return arguments.length === 2 ? (this._on[_] = f, this) : arguments.length ? typeof _ === "string" ? this._on[_] : (this._on = assign({}, this._on, _), this) : this._on;
|
|
686
650
|
}
|
|
687
651
|
},
|
|
688
652
|
{
|
|
689
|
-
|
|
690
|
-
@memberof Timeline
|
|
691
|
-
@desc Determines the visibility of the play button to the left the of timeline, which will cycle through the available periods at a rate defined by the playButtonInterval method.
|
|
692
|
-
@param {Boolean} [*value* = true]
|
|
693
|
-
@chainable
|
|
694
|
-
*/ key: "playButton",
|
|
653
|
+
key: "playButton",
|
|
695
654
|
value: function playButton(_) {
|
|
696
655
|
return arguments.length ? (this._playButton = _, this) : this._playButton;
|
|
697
656
|
}
|
|
698
657
|
},
|
|
699
658
|
{
|
|
700
|
-
|
|
701
|
-
@memberof Timeline
|
|
702
|
-
@desc The config Object for the Rect class used to create the playButton.
|
|
703
|
-
@param {Object} [*value*]
|
|
704
|
-
@chainable
|
|
705
|
-
*/ key: "playButtonConfig",
|
|
659
|
+
key: "playButtonConfig",
|
|
706
660
|
value: function playButtonConfig(_) {
|
|
707
661
|
return arguments.length ? (this._playButtonConfig = assign(this._playButtonConfig, _), this) : this._playButtonConfig;
|
|
708
662
|
}
|
|
709
663
|
},
|
|
710
664
|
{
|
|
711
|
-
|
|
712
|
-
@memberof Timeline
|
|
713
|
-
@desc The value, in milliseconds, to use when cycling through the available time periods when the user clicks the playButton.
|
|
714
|
-
@param {Number} [*value* = 1000]
|
|
715
|
-
@chainable
|
|
716
|
-
*/ key: "playButtonInterval",
|
|
665
|
+
key: "playButtonInterval",
|
|
717
666
|
value: function playButtonInterval(_) {
|
|
718
667
|
return arguments.length ? (this._playButtonInterval = _, this) : this._playButtonInterval;
|
|
719
668
|
}
|
|
720
669
|
},
|
|
721
670
|
{
|
|
722
|
-
|
|
723
|
-
@memberof Timeline
|
|
724
|
-
@desc If *value* is specified, sets the selection style and returns the current class instance. If *value* is not specified, returns the current selection style.
|
|
725
|
-
@param {Object} [*value*]
|
|
726
|
-
@chainable
|
|
727
|
-
*/ key: "selectionConfig",
|
|
671
|
+
key: "selectionConfig",
|
|
728
672
|
value: function selectionConfig(_) {
|
|
729
673
|
return arguments.length ? (this._selectionConfig = assign(this._selectionConfig, _), this) : this._selectionConfig;
|
|
730
674
|
}
|
|
731
675
|
},
|
|
732
676
|
{
|
|
733
|
-
|
|
734
|
-
@memberof Timeline
|
|
735
|
-
@desc If *value* is specified, sets the selection and returns the current class instance. If *value* is not specified, returns the current selection. Defaults to the most recent year in the timeline.
|
|
736
|
-
@param {Array|Date|Number|String} [*value*]
|
|
737
|
-
@chainable
|
|
738
|
-
*/ key: "selection",
|
|
677
|
+
key: "selection",
|
|
739
678
|
value: function selection(_) {
|
|
740
679
|
return arguments.length ? (this._selection = _, this) : this._selection;
|
|
741
680
|
}
|
|
742
681
|
},
|
|
743
682
|
{
|
|
744
|
-
|
|
745
|
-
@memberof Timeline
|
|
746
|
-
@desc If *value* is specified, toggles the snapping value and returns the current class instance. If *value* is not specified, returns the current snapping value.
|
|
747
|
-
@param {Boolean} [*value* = true]
|
|
748
|
-
@chainable
|
|
749
|
-
*/ key: "snapping",
|
|
683
|
+
key: "snapping",
|
|
750
684
|
value: function snapping(_) {
|
|
751
685
|
return arguments.length ? (this._snapping = _, this) : this._snapping;
|
|
752
686
|
}
|
|
@@ -755,6 +689,5 @@ function() {
|
|
|
755
689
|
return Timeline;
|
|
756
690
|
}(Axis);
|
|
757
691
|
/**
|
|
758
|
-
|
|
759
|
-
@extends Axis
|
|
692
|
+
Creates an interactive timeline brush component for selecting time periods within a visualization.
|
|
760
693
|
*/ export { Timeline as default };
|