@spider-analyzer/timeline 3.4.1 → 4.0.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 (41) hide show
  1. package/CHANGELOG.md +3 -0
  2. package/dist/Cursor.js +51 -81
  3. package/dist/TimeLine.js +214 -403
  4. package/dist/TimeLineResizer.js +6 -28
  5. package/dist/ToolTip.js +7 -16
  6. package/dist/cursorElements/CursorIcon.js +8 -29
  7. package/dist/cursorElements/CursorSelection.js +28 -61
  8. package/dist/cursorElements/DragOverlay.js +25 -57
  9. package/dist/cursorElements/LeftHandle.js +8 -24
  10. package/dist/cursorElements/LeftToolTip.js +4 -22
  11. package/dist/cursorElements/RightHandle.js +8 -24
  12. package/dist/cursorElements/RightToolTip.js +4 -22
  13. package/dist/cursorElements/ZoomIn.js +5 -24
  14. package/dist/cursorElements/ZoomOut.js +4 -16
  15. package/dist/cursorElements/commonStyles.js +0 -3
  16. package/dist/cursorElements/handleHistoHovering.js +25 -34
  17. package/dist/cursorElements/utils.js +0 -10
  18. package/dist/index.js +0 -4
  19. package/dist/theme.js +0 -3
  20. package/dist/timeLineElements/Button.js +12 -33
  21. package/dist/timeLineElements/HistoToolTip.js +7 -18
  22. package/dist/timeLineElements/Histogram.js +14 -29
  23. package/dist/timeLineElements/Legend.js +2 -22
  24. package/dist/timeLineElements/QualityLine.js +8 -23
  25. package/dist/timeLineElements/Tools.js +10 -18
  26. package/dist/timeLineElements/XAxis.js +12 -23
  27. package/dist/timeLineElements/XGrid.js +5 -15
  28. package/dist/timeLineElements/YAxis.js +6 -15
  29. package/dist/timeLineElements/YGrid.js +4 -13
  30. package/dist/timeLineElements/axesStyles.js +0 -4
  31. package/package.json +2 -2
  32. package/src/Cursor.jsx +1 -1
  33. package/src/TimeLine.jsx +1 -1
  34. package/src/cursorElements/CursorSelection.jsx +1 -1
  35. package/src/cursorElements/DragOverlay.jsx +1 -1
  36. package/src/timeLineElements/HistoToolTip.jsx +1 -1
  37. package/src/timeLineElements/Histogram.jsx +1 -2
  38. package/src/timeLineElements/QualityLine.jsx +1 -1
  39. package/src/timeLineElements/Tools.jsx +1 -1
  40. package/src/timeLineElements/XAxis.jsx +1 -1
  41. package/src/timeLineElements/XGrid.jsx +1 -1
package/dist/TimeLine.js CHANGED
@@ -1,104 +1,56 @@
1
1
  "use strict";
2
2
 
3
3
  function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports["default"] = void 0;
9
-
10
8
  var _react = _interopRequireWildcard(require("react"));
11
-
12
9
  var _propTypes = _interopRequireDefault(require("prop-types"));
13
-
14
- var _moment = _interopRequireDefault(require("moment"));
15
-
10
+ var _momentTimezone = _interopRequireDefault(require("moment-timezone"));
16
11
  var _d3Scale = require("d3-scale");
17
-
18
12
  var _merge2 = _interopRequireDefault(require("lodash-es/merge"));
19
-
20
13
  var _round2 = _interopRequireDefault(require("lodash-es/round"));
21
-
22
14
  var _max2 = _interopRequireDefault(require("lodash-es/max"));
23
-
24
15
  var _floor2 = _interopRequireDefault(require("lodash-es/floor"));
25
-
26
16
  var _isEqual = _interopRequireDefault(require("lodash-es/isEqual"));
27
-
28
17
  var _Cursor = _interopRequireDefault(require("./Cursor"));
29
-
30
18
  var _Histogram = _interopRequireDefault(require("./timeLineElements/Histogram"));
31
-
32
19
  var _XAxis = _interopRequireDefault(require("./timeLineElements/XAxis"));
33
-
34
20
  var _YAxis = _interopRequireDefault(require("./timeLineElements/YAxis"));
35
-
36
21
  var _Legend = _interopRequireDefault(require("./timeLineElements/Legend"));
37
-
38
22
  var _Tools = _interopRequireDefault(require("./timeLineElements/Tools"));
39
-
40
23
  var _HistoToolTip = _interopRequireDefault(require("./timeLineElements/HistoToolTip"));
41
-
42
24
  var _theme = _interopRequireWildcard(require("./theme"));
43
-
44
25
  var _QualityLine = _interopRequireDefault(require("./timeLineElements/QualityLine"));
45
-
46
26
  var _YGrid = _interopRequireDefault(require("./timeLineElements/YGrid"));
47
-
48
27
  var _XGrid = _interopRequireDefault(require("./timeLineElements/XGrid"));
49
-
50
28
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
51
-
52
29
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
53
-
54
30
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
55
-
56
31
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
57
-
58
32
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
59
-
60
33
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
61
-
62
34
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
63
-
64
35
  function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
65
-
66
36
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
67
-
68
37
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
69
-
70
38
  function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
71
-
72
39
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
73
-
74
40
  function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
75
-
76
41
  function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
77
-
78
42
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
79
-
80
43
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
81
-
82
44
  function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
83
-
84
45
  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
85
-
86
46
  function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
87
-
88
47
  function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
89
-
90
48
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
91
-
92
49
  function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
93
-
94
50
  function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
95
-
96
51
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
97
-
98
52
  function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
99
-
100
53
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
101
-
102
54
  var marginDefault = {
103
55
  left: 50,
104
56
  right: 45,
@@ -111,55 +63,46 @@ var xAxisDefault = {
111
63
  barsBetweenTicks: 8
112
64
  };
113
65
  var defaultZoomOutFactor = 1.25;
114
-
115
66
  var TimeLine = /*#__PURE__*/function (_Component) {
116
67
  _inherits(TimeLine, _Component);
117
-
118
68
  var _super = _createSuper(TimeLine);
119
-
120
69
  function TimeLine(props) {
121
70
  var _this;
122
-
123
71
  _classCallCheck(this, TimeLine);
124
-
125
72
  _this = _super.call(this, props);
126
-
127
73
  _defineProperty(_assertThisInitialized(_this), "shiftDomains", function (domains, _ref) {
128
74
  var min = _ref.min,
129
- max = _ref.max;
75
+ max = _ref.max;
130
76
  //update domains if selection is outside domains
131
77
  var toUpdate = false;
132
78
  var biggestVisibleDomain = _this.props.biggestVisibleDomain;
133
79
  var newDomains = domains.map(function (domain, index) {
134
80
  if (min && min.isBefore(domain.min) || max && max.isAfter(domain.max)) {
135
81
  toUpdate = true;
136
-
137
82
  if (index === domains.length - 1) {
138
83
  //if last domain, increase domain
139
84
  var newDomain = {
140
85
  min: min && min.isBefore(domain.min) ? min : domain.min,
141
86
  max: max && max.isAfter(domain.max) ? max : domain.max
142
87
  };
143
-
144
- if (biggestVisibleDomain && (0, _moment["default"])(newDomain.min).add(biggestVisibleDomain).isSameOrBefore(newDomain.max)) {
88
+ if (biggestVisibleDomain && (0, _momentTimezone["default"])(newDomain.min).add(biggestVisibleDomain).isSameOrBefore(newDomain.max)) {
145
89
  if (min.isBefore(domain.min)) {
146
- newDomain.max = (0, _moment["default"])(min).add(biggestVisibleDomain);
90
+ newDomain.max = (0, _momentTimezone["default"])(min).add(biggestVisibleDomain);
147
91
  } else {
148
- newDomain.min = (0, _moment["default"])(max).subtract(biggestVisibleDomain);
92
+ newDomain.min = (0, _momentTimezone["default"])(max).subtract(biggestVisibleDomain);
149
93
  }
150
94
  }
151
-
152
95
  return newDomain;
153
96
  } else {
154
97
  //if not last domain, shift domain
155
98
  if (min && min.isBefore(domain.min)) {
156
99
  return {
157
100
  min: min,
158
- max: (0, _moment["default"])(domain.max).subtract(domain.min.diff(min))
101
+ max: (0, _momentTimezone["default"])(domain.max).subtract(domain.min.diff(min))
159
102
  };
160
103
  } else {
161
104
  return {
162
- min: (0, _moment["default"])(domain.min).add(max.diff(domain.max)),
105
+ min: (0, _momentTimezone["default"])(domain.min).add(max.diff(domain.max)),
163
106
  max: max
164
107
  };
165
108
  }
@@ -170,27 +113,21 @@ var TimeLine = /*#__PURE__*/function (_Component) {
170
113
  });
171
114
  return toUpdate ? newDomains : domains;
172
115
  });
173
-
174
116
  _defineProperty(_assertThisInitialized(_this), "onResizeLeftCursor", function (delta, mouse) {
175
- var newStart = (0, _moment["default"])(_this.xAxis.invert(_this.xAxis(_this.state.start) + delta));
117
+ var newStart = (0, _momentTimezone["default"])(_this.xAxis.invert(_this.xAxis(_this.state.start) + delta));
176
118
  var newStop = _this.state.stop;
177
119
  var maxTimespan = false;
178
-
179
120
  if (newStart.isSameOrAfter(newStop)) {
180
- newStop = (0, _moment["default"])(_this.xAxis.invert(_this.xAxis(newStop) + delta));
121
+ newStop = (0, _momentTimezone["default"])(_this.xAxis.invert(_this.xAxis(newStop) + delta));
181
122
  }
182
-
183
123
  if (_this.props.biggestTimeSpan) {
184
- var min = (0, _moment["default"])(newStop).subtract(_this.props.biggestTimeSpan);
185
-
124
+ var min = (0, _momentTimezone["default"])(newStop).subtract(_this.props.biggestTimeSpan);
186
125
  if (min.isSameOrAfter(newStart)) {
187
126
  newStart = min;
188
127
  maxTimespan = true;
189
128
  }
190
129
  }
191
-
192
130
  _this.handleAutoSliding(mouse, _this.onResizeLeftCursor);
193
-
194
131
  if (newStop !== _this.state.stop && newStop.isSameOrBefore(_this.state.domain.max) || newStart.isSameOrAfter(_this.state.domain.min)) {
195
132
  _this.setState({
196
133
  start: newStart,
@@ -199,27 +136,21 @@ var TimeLine = /*#__PURE__*/function (_Component) {
199
136
  });
200
137
  }
201
138
  });
202
-
203
139
  _defineProperty(_assertThisInitialized(_this), "onResizeRightCursor", function (delta, mouse) {
204
- var newStop = (0, _moment["default"])(_this.xAxis.invert(_this.xAxis(_this.state.stop) + delta));
140
+ var newStop = (0, _momentTimezone["default"])(_this.xAxis.invert(_this.xAxis(_this.state.stop) + delta));
205
141
  var newStart = _this.state.start;
206
142
  var maxTimespan = false;
207
-
208
143
  if (newStop.isSameOrBefore(newStart)) {
209
- newStart = (0, _moment["default"])(_this.xAxis.invert(_this.xAxis(newStart) + delta));
144
+ newStart = (0, _momentTimezone["default"])(_this.xAxis.invert(_this.xAxis(newStart) + delta));
210
145
  }
211
-
212
146
  if (_this.props.biggestTimeSpan) {
213
- var max = (0, _moment["default"])(newStart).add(_this.props.biggestTimeSpan);
214
-
147
+ var max = (0, _momentTimezone["default"])(newStart).add(_this.props.biggestTimeSpan);
215
148
  if (max.isSameOrBefore(newStop)) {
216
149
  newStop = max;
217
150
  maxTimespan = true;
218
151
  }
219
152
  }
220
-
221
153
  _this.handleAutoSliding(mouse, _this.onResizeRightCursor);
222
-
223
154
  if (newStop.isSameOrBefore(_this.state.domain.max) && newStart.isSameOrAfter(_this.state.domain.min)) {
224
155
  _this.setState({
225
156
  start: newStart,
@@ -228,63 +159,47 @@ var TimeLine = /*#__PURE__*/function (_Component) {
228
159
  });
229
160
  }
230
161
  });
231
-
232
162
  _defineProperty(_assertThisInitialized(_this), "onDragCursor", function (delta, mouse) {
233
163
  _this.xAxis.clamp(false);
234
-
235
164
  var duration = _this.state.stop.diff(_this.state.start);
236
-
237
- var newStart = (0, _moment["default"])(_this.xAxis.invert(_this.xAxis(_this.state.start) + delta));
238
- var newStop = (0, _moment["default"])(newStart).add(duration, 'MILLISECONDS');
239
-
165
+ var newStart = (0, _momentTimezone["default"])(_this.xAxis.invert(_this.xAxis(_this.state.start) + delta));
166
+ var newStop = (0, _momentTimezone["default"])(newStart).add(duration, 'MILLISECONDS');
240
167
  _this.xAxis.clamp(true);
241
-
242
168
  var maxDomain = _this.props.maxDomain;
243
-
244
169
  if (maxDomain.min && newStart.isBefore(maxDomain.min)) {
245
- newStart = (0, _moment["default"])(maxDomain.min);
170
+ newStart = (0, _momentTimezone["default"])(maxDomain.min);
246
171
  }
247
-
248
172
  if (maxDomain.max && newStop.isAfter(maxDomain.max)) {
249
- newStop = (0, _moment["default"])(maxDomain.max);
173
+ newStop = (0, _momentTimezone["default"])(maxDomain.max);
250
174
  }
251
-
252
175
  _this.handleAutoSliding(mouse, _this.onDragCursor);
253
-
254
176
  _this.setState({
255
177
  start: newStart,
256
178
  stop: newStop
257
179
  });
258
180
  });
259
-
260
181
  _defineProperty(_assertThisInitialized(_this), "onStartDrawCursor", function (pos) {
261
182
  _this.setState({
262
- start: (0, _moment["default"])(_this.xAxis.invert(pos)),
263
- stop: (0, _moment["default"])(_this.xAxis.invert(pos + 1)),
183
+ start: (0, _momentTimezone["default"])(_this.xAxis.invert(pos)),
184
+ stop: (0, _momentTimezone["default"])(_this.xAxis.invert(pos + 1)),
264
185
  maxTimespan: false
265
186
  });
266
187
  });
267
-
268
188
  _defineProperty(_assertThisInitialized(_this), "onDrawCursor", function (delta, mouse) {
269
- var newStop = (0, _moment["default"])(_this.xAxis.invert(_this.xAxis(_this.state.stop) + delta));
189
+ var newStop = (0, _momentTimezone["default"])(_this.xAxis.invert(_this.xAxis(_this.state.stop) + delta));
270
190
  var newStart = _this.state.start;
271
191
  var maxTimespan = false;
272
-
273
192
  if (newStop.isSameOrBefore(newStart)) {
274
- newStart = (0, _moment["default"])(_this.xAxis.invert(_this.xAxis(newStart) + delta));
193
+ newStart = (0, _momentTimezone["default"])(_this.xAxis.invert(_this.xAxis(newStart) + delta));
275
194
  }
276
-
277
195
  if (_this.props.biggestTimeSpan) {
278
- var max = (0, _moment["default"])(newStart).add(_this.props.biggestTimeSpan);
279
-
196
+ var max = (0, _momentTimezone["default"])(newStart).add(_this.props.biggestTimeSpan);
280
197
  if (max.isSameOrBefore(newStop)) {
281
198
  newStop = max;
282
199
  maxTimespan = true;
283
200
  }
284
201
  }
285
-
286
202
  _this.handleAutoSliding(mouse, _this.onDrawCursor);
287
-
288
203
  if (newStop.isSameOrBefore(_this.state.domain.max) && newStart.isSameOrAfter(_this.state.domain.min)) {
289
204
  _this.setState({
290
205
  start: newStart,
@@ -293,62 +208,49 @@ var TimeLine = /*#__PURE__*/function (_Component) {
293
208
  });
294
209
  }
295
210
  });
296
-
297
211
  _defineProperty(_assertThisInitialized(_this), "stopAutoMove", function () {
298
212
  if (_this.autoMove) {
299
213
  _this.setAutoMove(false);
300
214
  }
301
-
302
215
  if (_this.isAutoMoving) {
303
216
  _this.isAutoMoving = false;
304
-
305
217
  _this.movedTimeLine();
306
218
  }
307
219
  });
308
-
309
220
  _defineProperty(_assertThisInitialized(_this), "onEndDrawCursor", function () {
310
221
  _this.stopAutoMove();
311
-
312
222
  var _this$props = _this.props,
313
- onCustomRange = _this$props.onCustomRange,
314
- selectBarOnClick = _this$props.selectBarOnClick;
223
+ onCustomRange = _this$props.onCustomRange,
224
+ selectBarOnClick = _this$props.selectBarOnClick;
315
225
  var _this$state = _this.state,
316
- start = _this$state.start,
317
- stop = _this$state.stop,
318
- barHovered = _this$state.barHovered;
319
-
226
+ start = _this$state.start,
227
+ stop = _this$state.stop,
228
+ barHovered = _this$state.barHovered;
320
229
  if (selectBarOnClick && _this.items && barHovered > -1) {
321
230
  var item = _this.items[barHovered];
322
-
323
231
  if (start.isSameOrAfter(item.start) && stop.isSameOrBefore(item.end)) {
324
- start = (0, _moment["default"])(item.start);
325
- stop = (0, _moment["default"])(item.end);
326
-
232
+ start = (0, _momentTimezone["default"])(item.start);
233
+ stop = (0, _momentTimezone["default"])(item.end);
327
234
  _this.setState({
328
235
  start: start,
329
236
  stop: stop
330
237
  });
331
238
  }
332
239
  }
333
-
334
240
  onCustomRange(start, stop);
335
241
  });
336
-
337
242
  _defineProperty(_assertThisInitialized(_this), "onEndChangeCursor", function () {
338
243
  _this.stopAutoMove();
339
-
340
244
  var onCustomRange = _this.props.onCustomRange;
341
245
  var _this$state2 = _this.state,
342
- start = _this$state2.start,
343
- stop = _this$state2.stop;
246
+ start = _this$state2.start,
247
+ stop = _this$state2.stop;
344
248
  onCustomRange(start, stop);
345
249
  });
346
-
347
250
  _defineProperty(_assertThisInitialized(_this), "handleAutoSliding", function (mouse, action) {
348
251
  //slide domain when dragging and mouse out of histo
349
252
  if (mouse) {
350
253
  var posX = mouse[0];
351
-
352
254
  if (posX < 0) {
353
255
  _this.setAutoMove(true, action, posX);
354
256
  } else if (posX >= 0 && posX <= _this.state.histoWidth) {
@@ -358,7 +260,6 @@ var TimeLine = /*#__PURE__*/function (_Component) {
358
260
  }
359
261
  }
360
262
  });
361
-
362
263
  _defineProperty(_assertThisInitialized(_this), "setAutoMove", function (active, action, delta) {
363
264
  if (active) {
364
265
  //prevent creating timer to often if mouse did not move so much
@@ -366,9 +267,7 @@ var TimeLine = /*#__PURE__*/function (_Component) {
366
267
  clearInterval(_this.autoMove);
367
268
  _this.autoMove = setInterval(function () {
368
269
  action(delta);
369
-
370
270
  _this.moveTimeLine(-delta);
371
-
372
271
  _this.isAutoMoving = true;
373
272
  _this.lastAutoMovingDelta = delta;
374
273
  }, 30);
@@ -378,21 +277,17 @@ var TimeLine = /*#__PURE__*/function (_Component) {
378
277
  _this.autoMove = null;
379
278
  }
380
279
  });
381
-
382
280
  _defineProperty(_assertThisInitialized(_this), "onWheel", function (event) {
383
281
  var _this$state3 = _this.state,
384
- waitForLoad = _this$state3.waitForLoad,
385
- maxZoom = _this$state3.maxZoom,
386
- minZoom = _this$state3.minZoom;
282
+ waitForLoad = _this$state3.waitForLoad,
283
+ maxZoom = _this$state3.maxZoom,
284
+ minZoom = _this$state3.minZoom;
387
285
  var _this$props2 = _this.props,
388
- onShowMessage = _this$props2.onShowMessage,
389
- domains = _this$props2.domains;
286
+ onShowMessage = _this$props2.onShowMessage,
287
+ domains = _this$props2.domains;
390
288
  event.stopPropagation();
391
-
392
289
  var baseX = _this.timelineElement.current.getBoundingClientRect().left;
393
-
394
290
  var x = event.clientX - baseX - _this.state.margin.left;
395
-
396
291
  if (!waitForLoad) {
397
292
  if (event.deltaY < -50) {
398
293
  if (maxZoom) {
@@ -411,74 +306,56 @@ var TimeLine = /*#__PURE__*/function (_Component) {
411
306
  }
412
307
  }
413
308
  });
414
-
415
309
  _defineProperty(_assertThisInitialized(_this), "onGotoCursor", function () {
416
- var middle = (0, _moment["default"])(_this.state.start).add(_this.state.stop.diff(_this.state.start) / 2);
417
-
310
+ var middle = (0, _momentTimezone["default"])(_this.state.start).add(_this.state.stop.diff(_this.state.start) / 2);
418
311
  _this.xAxis.clamp(false);
419
-
420
312
  var currentX = _this.state.histoWidth / 2;
421
-
422
313
  var newX = _this.xAxis(middle);
423
-
424
314
  var newDomain = _this.moveTimeLineCore(currentX - newX);
315
+ var domains = _toConsumableArray(_this.props.domains);
316
+ //Replace current domain
317
+ domains.splice(0, 1, newDomain);
425
318
 
426
- var domains = _toConsumableArray(_this.props.domains); //Replace current domain
427
-
428
-
429
- domains.splice(0, 1, newDomain); //Check if other domains should shift
430
-
319
+ //Check if other domains should shift
431
320
  var newDomains = _this.shiftDomains(domains, newDomain);
432
-
433
321
  _this.props.onUpdateDomains(newDomains);
434
-
435
322
  _this.xAxis.clamp(true);
436
323
  });
437
-
438
324
  _defineProperty(_assertThisInitialized(_this), "onGoto", function (d) {
439
325
  var halfTimeAgg = _this.state.stop.diff(_this.state.start) / 2;
440
- var when = d || (0, _moment["default"])();
441
- var newStop = (0, _moment["default"])(when).add(halfTimeAgg);
442
- var newStart = (0, _moment["default"])(when).subtract(halfTimeAgg);
443
-
326
+ var when = d || (0, _momentTimezone["default"])();
327
+ var newStop = (0, _momentTimezone["default"])(when).add(halfTimeAgg);
328
+ var newStart = (0, _momentTimezone["default"])(when).subtract(halfTimeAgg);
444
329
  _this.props.onCustomRange(newStart, newStop);
445
330
  });
446
-
447
331
  _defineProperty(_assertThisInitialized(_this), "zoomOnTarget", function (x) {
448
332
  var _this$xAxis$domain = _this.xAxis.domain(),
449
- _this$xAxis$domain2 = _slicedToArray(_this$xAxis$domain, 2),
450
- minOrigin = _this$xAxis$domain2[0],
451
- maxOrigin = _this$xAxis$domain2[1];
452
-
453
- var target = (0, _moment["default"])(_this.xAxis.invert(x));
454
- var min = (0, _moment["default"])(target).subtract(0.25 * target.diff((0, _moment["default"])(minOrigin)));
455
- var max = (0, _moment["default"])(target).add(0.25 * (0, _moment["default"])(maxOrigin).diff(target));
456
-
333
+ _this$xAxis$domain2 = _slicedToArray(_this$xAxis$domain, 2),
334
+ minOrigin = _this$xAxis$domain2[0],
335
+ maxOrigin = _this$xAxis$domain2[1];
336
+ var target = (0, _momentTimezone["default"])(_this.xAxis.invert(x));
337
+ var min = (0, _momentTimezone["default"])(target).subtract(0.25 * target.diff((0, _momentTimezone["default"])(minOrigin)));
338
+ var max = (0, _momentTimezone["default"])(target).add(0.25 * (0, _momentTimezone["default"])(maxOrigin).diff(target));
457
339
  _this.zoomOnDomain({
458
340
  min: min,
459
341
  max: max
460
342
  });
461
343
  });
462
-
463
344
  _defineProperty(_assertThisInitialized(_this), "zoomOutOfTarget", function (x) {
464
345
  var _this$xAxis$domain3 = _this.xAxis.domain(),
465
- _this$xAxis$domain4 = _slicedToArray(_this$xAxis$domain3, 2),
466
- minOrigin = _this$xAxis$domain4[0],
467
- maxOrigin = _this$xAxis$domain4[1];
468
-
469
- var target = (0, _moment["default"])(_this.xAxis.invert(x));
470
- var min = (0, _moment["default"])(target).subtract(1.25 * target.diff((0, _moment["default"])(minOrigin)));
471
- var max = (0, _moment["default"])(target).add(1.25 * (0, _moment["default"])(maxOrigin).diff(target));
472
-
346
+ _this$xAxis$domain4 = _slicedToArray(_this$xAxis$domain3, 2),
347
+ minOrigin = _this$xAxis$domain4[0],
348
+ maxOrigin = _this$xAxis$domain4[1];
349
+ var target = (0, _momentTimezone["default"])(_this.xAxis.invert(x));
350
+ var min = (0, _momentTimezone["default"])(target).subtract(1.25 * target.diff((0, _momentTimezone["default"])(minOrigin)));
351
+ var max = (0, _momentTimezone["default"])(target).add(1.25 * (0, _momentTimezone["default"])(maxOrigin).diff(target));
473
352
  _this.zoomOutTo([{
474
353
  min: min,
475
354
  max: max
476
355
  }]);
477
356
  });
478
-
479
357
  _defineProperty(_assertThisInitialized(_this), "checkAndCorrectDomain", function (_ref2) {
480
358
  var domain = _ref2.domain;
481
-
482
359
  if (!domain) {
483
360
  return {
484
361
  domain: domain,
@@ -487,50 +364,43 @@ var TimeLine = /*#__PURE__*/function (_Component) {
487
364
  domainHasChanged: false
488
365
  };
489
366
  }
490
-
491
367
  var newDomain = _objectSpread({}, domain);
492
-
493
368
  var _this$props3 = _this.props,
494
- biggestVisibleDomain = _this$props3.biggestVisibleDomain,
495
- maxDomain = _this$props3.maxDomain,
496
- smallestResolution = _this$props3.smallestResolution;
369
+ biggestVisibleDomain = _this$props3.biggestVisibleDomain,
370
+ maxDomain = _this$props3.maxDomain,
371
+ smallestResolution = _this$props3.smallestResolution;
497
372
  var histoWidth = _this.state.histoWidth;
498
- var domainHasChanged = false; //Maximum zoom?
373
+ var domainHasChanged = false;
499
374
 
375
+ //Maximum zoom?
500
376
  var duration = newDomain.max.diff(newDomain.min);
501
- var maxZoom = false; //We stop/recap zoom in when 15px = 1min
377
+ var maxZoom = false;
502
378
 
379
+ //We stop/recap zoom in when 15px = 1min
503
380
  var minRes = smallestResolution.asMilliseconds();
504
-
505
381
  if (duration <= histoWidth * minRes / 15) {
506
382
  maxZoom = true;
507
- newDomain.max = (0, _moment["default"])(newDomain.min).add(histoWidth * minRes / 15, 'ms');
508
- } //Minimum zoom?
509
-
383
+ newDomain.max = (0, _momentTimezone["default"])(newDomain.min).add(histoWidth * minRes / 15, 'ms');
384
+ }
510
385
 
386
+ //Minimum zoom?
511
387
  var minTime, maxTime;
512
-
513
388
  if (maxDomain.min && newDomain.min.isBefore(maxDomain.min)) {
514
- newDomain.min = (0, _moment["default"])(maxDomain.min);
389
+ newDomain.min = (0, _momentTimezone["default"])(maxDomain.min);
515
390
  minTime = true;
516
391
  }
517
-
518
392
  if (maxDomain.max && newDomain.max.isAfter(maxDomain.max)) {
519
- newDomain.max = (0, _moment["default"])(maxDomain.max);
393
+ newDomain.max = (0, _momentTimezone["default"])(maxDomain.max);
520
394
  maxTime = true;
521
395
  }
522
-
523
396
  var minZoom = false;
524
-
525
- if (biggestVisibleDomain && newDomain.max.isSameOrAfter((0, _moment["default"])(newDomain.min).add(biggestVisibleDomain))) {
397
+ if (biggestVisibleDomain && newDomain.max.isSameOrAfter((0, _momentTimezone["default"])(newDomain.min).add(biggestVisibleDomain))) {
526
398
  minZoom = true;
527
- newDomain.min = (0, _moment["default"])(newDomain.max).subtract(biggestVisibleDomain);
399
+ newDomain.min = (0, _momentTimezone["default"])(newDomain.max).subtract(biggestVisibleDomain);
528
400
  }
529
-
530
401
  if (!(newDomain.min.isSame(domain.min) && newDomain.max.isSame(domain.max))) {
531
402
  domainHasChanged = true;
532
403
  }
533
-
534
404
  return {
535
405
  domain: domainHasChanged ? newDomain : domain,
536
406
  maxZoom: maxZoom,
@@ -540,85 +410,68 @@ var TimeLine = /*#__PURE__*/function (_Component) {
540
410
  domainHasChanged: domainHasChanged
541
411
  };
542
412
  });
543
-
544
413
  _defineProperty(_assertThisInitialized(_this), "zoomOnDomain", function (targetDomain) {
545
414
  var _this$props4 = _this.props,
546
- onShowMessage = _this$props4.onShowMessage,
547
- onUpdateDomains = _this$props4.onUpdateDomains;
548
-
415
+ onShowMessage = _this$props4.onShowMessage,
416
+ onUpdateDomains = _this$props4.onUpdateDomains;
549
417
  if (!_this.state.waitForLoad) {
550
418
  if (!(targetDomain.min.isSame(_this.state.domain.min) && targetDomain.max.isSame(_this.state.domain.max))) {
551
419
  var _this$checkAndCorrect = _this.checkAndCorrectDomain({
552
- domain: targetDomain
553
- }),
554
- maxZoom = _this$checkAndCorrect.maxZoom,
555
- domain = _this$checkAndCorrect.domain;
556
-
420
+ domain: targetDomain
421
+ }),
422
+ maxZoom = _this$checkAndCorrect.maxZoom,
423
+ domain = _this$checkAndCorrect.domain;
557
424
  var currentMaxZoom = _this.state.maxZoom;
558
-
559
425
  if (maxZoom && maxZoom !== currentMaxZoom) {
560
426
  onShowMessage(_this.labels.zoomSelectionResolutionExtended);
561
427
  }
562
-
563
428
  var domains = [domain].concat(_toConsumableArray(_this.props.domains));
564
-
565
429
  _this.setState({
566
430
  maxZoom: maxZoom,
567
431
  minZoom: false,
568
432
  domain: domain
569
433
  });
570
-
571
434
  onUpdateDomains(domains);
572
435
  } else {
573
436
  onShowMessage(_this.labels.zoomInWithoutChangingSelectionMsg);
574
437
  }
575
438
  }
576
439
  });
577
-
578
440
  _defineProperty(_assertThisInitialized(_this), "zoomOutTo", function (domains) {
579
441
  var _this$checkAndCorrect2 = _this.checkAndCorrectDomain({
580
- domain: domains[0]
581
- }),
582
- minZoom = _this$checkAndCorrect2.minZoom,
583
- domain = _this$checkAndCorrect2.domain,
584
- domainHasChanged = _this$checkAndCorrect2.domainHasChanged,
585
- maxTime = _this$checkAndCorrect2.maxTime,
586
- minTime = _this$checkAndCorrect2.minTime;
587
-
442
+ domain: domains[0]
443
+ }),
444
+ minZoom = _this$checkAndCorrect2.minZoom,
445
+ domain = _this$checkAndCorrect2.domain,
446
+ domainHasChanged = _this$checkAndCorrect2.domainHasChanged,
447
+ maxTime = _this$checkAndCorrect2.maxTime,
448
+ minTime = _this$checkAndCorrect2.minTime;
588
449
  var _this$props5 = _this.props,
589
- onShowMessage = _this$props5.onShowMessage,
590
- onUpdateDomains = _this$props5.onUpdateDomains;
591
-
450
+ onShowMessage = _this$props5.onShowMessage,
451
+ onUpdateDomains = _this$props5.onUpdateDomains;
592
452
  if (minZoom) {
593
453
  onShowMessage(_this.labels.minZoomMsg);
594
454
  }
595
-
596
455
  if (minTime) {
597
456
  onShowMessage(_this.labels.minDomainMsg);
598
457
  }
599
-
600
458
  if (maxTime) {
601
459
  onShowMessage(_this.labels.maxDomainMsg);
602
460
  }
603
-
604
461
  var newDomains = domainHasChanged ? [domain].concat(_toConsumableArray(_this.props.domains.slice(1))) : domains;
605
-
606
462
  _this.setState({
607
463
  maxZoom: false,
608
464
  minZoom: minZoom,
609
465
  domain: domain
610
466
  });
611
-
612
467
  onUpdateDomains(newDomains);
613
468
  });
614
-
615
469
  _defineProperty(_assertThisInitialized(_this), "zoomIn", function () {
616
470
  var _this$state4 = _this.state,
617
- maxZoom = _this$state4.maxZoom,
618
- start = _this$state4.start,
619
- stop = _this$state4.stop;
471
+ maxZoom = _this$state4.maxZoom,
472
+ start = _this$state4.start,
473
+ stop = _this$state4.stop;
620
474
  var onShowMessage = _this.props.onShowMessage;
621
-
622
475
  if (!maxZoom) {
623
476
  _this.zoomOnDomain({
624
477
  min: start,
@@ -628,47 +481,40 @@ var TimeLine = /*#__PURE__*/function (_Component) {
628
481
  onShowMessage(_this.labels.doubleClickMaxZoomMsg);
629
482
  }
630
483
  });
631
-
632
484
  _defineProperty(_assertThisInitialized(_this), "zoomOut", function () {
633
485
  if (!_this.state.waitForLoad && !_this.state.minZoom) {
634
486
  var domains = _toConsumableArray(_this.props.domains);
635
-
636
487
  var zoomOutFactor = _this.props.zoomOutFactor;
637
-
638
488
  if (domains.length > 1) {
639
489
  domains.shift();
640
490
  } else {
641
491
  var _this$xAxis$domain5 = _this.xAxis.domain(),
642
- _this$xAxis$domain6 = _slicedToArray(_this$xAxis$domain5, 2),
643
- minOrigin = _this$xAxis$domain6[0],
644
- maxOrigin = _this$xAxis$domain6[1];
645
-
646
- var halfDuration = (0, _moment["default"])(maxOrigin).diff((0, _moment["default"])(minOrigin)) / 2;
647
- var target = (0, _moment["default"])(minOrigin).add(halfDuration);
648
- var min = (0, _moment["default"])(target).subtract(zoomOutFactor * halfDuration);
649
- var max = (0, _moment["default"])(target).add(zoomOutFactor * halfDuration);
492
+ _this$xAxis$domain6 = _slicedToArray(_this$xAxis$domain5, 2),
493
+ minOrigin = _this$xAxis$domain6[0],
494
+ maxOrigin = _this$xAxis$domain6[1];
495
+ var halfDuration = (0, _momentTimezone["default"])(maxOrigin).diff((0, _momentTimezone["default"])(minOrigin)) / 2;
496
+ var target = (0, _momentTimezone["default"])(minOrigin).add(halfDuration);
497
+ var min = (0, _momentTimezone["default"])(target).subtract(zoomOutFactor * halfDuration);
498
+ var max = (0, _momentTimezone["default"])(target).add(zoomOutFactor * halfDuration);
650
499
  domains[0] = {
651
500
  min: min,
652
501
  max: max
653
502
  };
654
503
  }
655
-
656
504
  _this.zoomOutTo(domains);
657
505
  }
658
506
  });
659
-
660
507
  _defineProperty(_assertThisInitialized(_this), "moveTimeLineCore", function (delta) {
661
508
  var _this$props6 = _this.props,
662
- maxDomain = _this$props6.maxDomain,
663
- onShowMessage = _this$props6.onShowMessage;
509
+ maxDomain = _this$props6.maxDomain,
510
+ onShowMessage = _this$props6.onShowMessage;
664
511
  var _this$state5 = _this.state,
665
- currentDomain = _this$state5.domain,
666
- _this$state5$minTime = _this$state5.minTime,
667
- minTime = _this$state5$minTime === void 0 ? false : _this$state5$minTime,
668
- _this$state5$maxTime = _this$state5.maxTime,
669
- maxTime = _this$state5$maxTime === void 0 ? false : _this$state5$maxTime;
512
+ currentDomain = _this$state5.domain,
513
+ _this$state5$minTime = _this$state5.minTime,
514
+ minTime = _this$state5$minTime === void 0 ? false : _this$state5$minTime,
515
+ _this$state5$maxTime = _this$state5.maxTime,
516
+ maxTime = _this$state5$maxTime === void 0 ? false : _this$state5$maxTime;
670
517
  var currentSpan = currentDomain.max.diff(currentDomain.min);
671
-
672
518
  if (minTime && delta > 0 || maxTime && delta < 0) {
673
519
  return _objectSpread(_objectSpread({}, currentDomain), {}, {
674
520
  moved: 0,
@@ -676,26 +522,23 @@ var TimeLine = /*#__PURE__*/function (_Component) {
676
522
  maxTime: maxTime
677
523
  });
678
524
  } else {
679
- var min = (0, _moment["default"])(_this.xAxis.invert(-delta));
680
- var max = (0, _moment["default"])(_this.xAxis.invert(_this.state.histoWidth - delta));
525
+ var min = (0, _momentTimezone["default"])(_this.xAxis.invert(-delta));
526
+ var max = (0, _momentTimezone["default"])(_this.xAxis.invert(_this.state.histoWidth - delta));
681
527
  var moved = delta;
682
-
683
528
  if (maxDomain.min && min.isBefore(maxDomain.min)) {
684
529
  moved = _this.xAxis(maxDomain.min);
685
- min = (0, _moment["default"])(maxDomain.min);
686
- max = (0, _moment["default"])(min).add(currentSpan);
530
+ min = (0, _momentTimezone["default"])(maxDomain.min);
531
+ max = (0, _momentTimezone["default"])(min).add(currentSpan);
687
532
  minTime = true;
688
533
  onShowMessage(_this.labels.minDomainMsg);
689
534
  }
690
-
691
535
  if (maxDomain.max && max.isAfter(maxDomain.max)) {
692
536
  moved = _this.xAxis(maxDomain.max);
693
- max = (0, _moment["default"])(maxDomain.max);
694
- min = (0, _moment["default"])(max).subtract(currentSpan);
537
+ max = (0, _momentTimezone["default"])(maxDomain.max);
538
+ min = (0, _momentTimezone["default"])(max).subtract(currentSpan);
695
539
  maxTime = true;
696
540
  onShowMessage(_this.labels.maxDomainMsg);
697
541
  }
698
-
699
542
  return {
700
543
  min: min,
701
544
  max: max,
@@ -705,35 +548,26 @@ var TimeLine = /*#__PURE__*/function (_Component) {
705
548
  };
706
549
  }
707
550
  });
708
-
709
551
  _defineProperty(_assertThisInitialized(_this), "moveTimeLine", function (delta) {
710
552
  _this.xAxis.clamp(false);
711
-
712
553
  var _this$moveTimeLineCor = _this.moveTimeLineCore(delta),
713
- min = _this$moveTimeLineCor.min,
714
- max = _this$moveTimeLineCor.max,
715
- moved = _this$moveTimeLineCor.moved,
716
- minTime = _this$moveTimeLineCor.minTime,
717
- maxTime = _this$moveTimeLineCor.maxTime;
718
-
554
+ min = _this$moveTimeLineCor.min,
555
+ max = _this$moveTimeLineCor.max,
556
+ moved = _this$moveTimeLineCor.moved,
557
+ minTime = _this$moveTimeLineCor.minTime,
558
+ maxTime = _this$moveTimeLineCor.maxTime;
719
559
  if (moved !== 0) {
720
560
  _this.xAxis.domain([min, max]);
721
-
722
561
  _this.xAxis.clamp(true);
723
-
724
562
  var ticks = _this.xAxis.ticks((0, _floor2["default"])(_this.state.histoWidth / _this.props.xAxis.spaceBetweenTicks));
725
-
726
563
  _this.movedSinceLastFetched += moved;
727
-
728
564
  if (Math.abs(_this.movedSinceLastFetched) > 75 && _this.props.fetchWhileSliding) {
729
565
  _this.movedSinceLastFetched = 0;
730
-
731
566
  _this.getItems(_this.props, {
732
567
  min: min,
733
568
  max: max
734
569
  });
735
570
  }
736
-
737
571
  _this.setState({
738
572
  domain: {
739
573
  min: min,
@@ -745,39 +579,34 @@ var TimeLine = /*#__PURE__*/function (_Component) {
745
579
  });
746
580
  }
747
581
  });
748
-
749
582
  _defineProperty(_assertThisInitialized(_this), "movedTimeLine", function () {
750
583
  _this.movedSinceLastFetched = 0;
751
584
  var domain = _this.state.domain;
752
585
  var _this$props7 = _this.props,
753
- originalDomains = _this$props7.domains,
754
- onUpdateDomains = _this$props7.onUpdateDomains; //Replace current domain
586
+ originalDomains = _this$props7.domains,
587
+ onUpdateDomains = _this$props7.onUpdateDomains;
755
588
 
756
- var domains = [domain].concat(_toConsumableArray(originalDomains.slice(1))); //Check if other domains should shift
589
+ //Replace current domain
590
+ var domains = [domain].concat(_toConsumableArray(originalDomains.slice(1)));
757
591
 
592
+ //Check if other domains should shift
758
593
  var newDomains = _this.shiftDomains(domains, domain);
759
-
760
594
  onUpdateDomains(newDomains);
761
595
  });
762
-
763
596
  _defineProperty(_assertThisInitialized(_this), "shiftTimeLine", function (delta) {
764
597
  var incr = delta / Math.abs(delta) * 8;
765
598
  var i = 0;
766
-
767
599
  function step() {
768
600
  this.moveTimeLine(incr);
769
601
  i += 8;
770
-
771
602
  if (i < Math.abs(delta)) {
772
603
  setTimeout(step.bind(this), 10);
773
604
  } else {
774
605
  this.movedTimeLine();
775
606
  }
776
607
  }
777
-
778
608
  step.bind(_assertThisInitialized(_this))();
779
609
  });
780
-
781
610
  _this.labels = (0, _merge2["default"])(_theme.defaultLabels, props.labels);
782
611
  _this.xAxis = null; //time axis computation function
783
612
 
@@ -797,15 +626,15 @@ var TimeLine = /*#__PURE__*/function (_Component) {
797
626
  domain: props.domains[0]
798
627
  }));
799
628
  _this.widthOfLastUpdate = null;
800
- _this.timelineElement = /*#__PURE__*/_react["default"].createRef(); //manage auto sliding
629
+ _this.timelineElement = /*#__PURE__*/_react["default"].createRef();
801
630
 
631
+ //manage auto sliding
802
632
  _this.autoMove = null;
803
633
  _this.isAutoMoving = false;
804
634
  _this.lastAutoMovingDelta = 0;
805
635
  _this.movedSinceLastFetched = 0;
806
636
  return _this;
807
637
  }
808
-
809
638
  _createClass(TimeLine, [{
810
639
  key: "componentDidMount",
811
640
  value: function componentDidMount() {
@@ -814,7 +643,6 @@ var TimeLine = /*#__PURE__*/function (_Component) {
814
643
  } else {
815
644
  this.props.onLoadDefaultDomain();
816
645
  }
817
-
818
646
  this.computeMarginAndWidth(this.props);
819
647
  }
820
648
  }, {
@@ -823,9 +651,9 @@ var TimeLine = /*#__PURE__*/function (_Component) {
823
651
  //reached max selection
824
652
  if (!prevState.maxTimespan && this.state.maxTimespan) {
825
653
  this.props.onShowMessage(this.labels.maxSelectionMsg);
826
- } //Change of width (big): update item
827
-
654
+ }
828
655
 
656
+ //Change of width (big): update item
829
657
  if (prevProps.width !== this.props.width || !(0, _isEqual["default"])(prevProps.margin, this.props.margin)) {
830
658
  if (this.state.isActive) {
831
659
  this.getItems(this.props, this.state.domain, this.widthOfLastUpdate && Math.abs(this.props.width - this.widthOfLastUpdate) > 30);
@@ -833,18 +661,16 @@ var TimeLine = /*#__PURE__*/function (_Component) {
833
661
  } else {
834
662
  this.setState(this.computeMarginAndWidth(this.props));
835
663
  }
836
-
837
664
  if (this.state.domain) {
838
665
  var _this$checkAndCorrect3 = this.checkAndCorrectDomain({
839
- domain: this.state.domain
840
- }),
841
- maxZoom = _this$checkAndCorrect3.maxZoom,
842
- minZoom = _this$checkAndCorrect3.minZoom,
843
- domain = _this$checkAndCorrect3.domain,
844
- domainHasChanged = _this$checkAndCorrect3.domainHasChanged,
845
- minTime = _this$checkAndCorrect3.minTime,
846
- maxTime = _this$checkAndCorrect3.maxTime;
847
-
666
+ domain: this.state.domain
667
+ }),
668
+ maxZoom = _this$checkAndCorrect3.maxZoom,
669
+ minZoom = _this$checkAndCorrect3.minZoom,
670
+ domain = _this$checkAndCorrect3.domain,
671
+ domainHasChanged = _this$checkAndCorrect3.domainHasChanged,
672
+ minTime = _this$checkAndCorrect3.minTime,
673
+ maxTime = _this$checkAndCorrect3.maxTime;
848
674
  if (maxZoom !== this.state.maxZoom || minZoom !== this.state.minZoom) {
849
675
  this.setState({
850
676
  maxZoom: maxZoom,
@@ -853,72 +679,69 @@ var TimeLine = /*#__PURE__*/function (_Component) {
853
679
  maxTime: maxTime,
854
680
  domain: domainHasChanged ? domain : this.state.domain
855
681
  });
856
-
857
682
  if (domainHasChanged) {
858
683
  var domains = [domain].concat(_toConsumableArray(this.props.domains.slice(1)));
859
684
  this.props.onUpdateDomains(domains);
860
685
  }
861
686
  }
862
687
  }
863
- } //If selection changed
864
-
688
+ }
865
689
 
690
+ //If selection changed
866
691
  if (!prevProps.timeSpan.start.isSame(this.props.timeSpan.start) || !prevProps.timeSpan.stop.isSame(this.props.timeSpan.stop)) {
867
692
  var newDomains = this.shiftDomains(this.props.domains, {
868
693
  min: this.props.timeSpan.start,
869
694
  max: this.props.timeSpan.stop
870
695
  });
871
-
872
696
  if (newDomains !== this.props.domains) {
873
697
  this.props.onUpdateDomains(newDomains);
874
- } //Update cursor
875
-
698
+ }
876
699
 
700
+ //Update cursor
877
701
  this.setState({
878
702
  start: this.props.timeSpan.start,
879
703
  stop: this.props.timeSpan.stop
880
704
  });
881
- } //If change in current domain, update items and state
882
-
705
+ }
883
706
 
707
+ //If change in current domain, update items and state
884
708
  if (!prevProps.domains[0] && this.props.domains[0] || prevProps.domains[0] && (!prevProps.domains[0].min.isSame(this.props.domains[0].min) || !prevProps.domains[0].max.isSame(this.props.domains[0].max))) {
885
709
  //If current zoom changes and is changing min/max zoom attribute
886
710
  //then update min/maxZoom and crop domain
887
711
  var _this$checkAndCorrect4 = this.checkAndCorrectDomain({
888
- domain: this.props.domains[0]
889
- }),
890
- _maxZoom = _this$checkAndCorrect4.maxZoom,
891
- _minZoom = _this$checkAndCorrect4.minZoom,
892
- _domain = _this$checkAndCorrect4.domain,
893
- _domainHasChanged = _this$checkAndCorrect4.domainHasChanged,
894
- _minTime = _this$checkAndCorrect4.minTime,
895
- _maxTime = _this$checkAndCorrect4.maxTime;
896
-
712
+ domain: this.props.domains[0]
713
+ }),
714
+ _maxZoom = _this$checkAndCorrect4.maxZoom,
715
+ _minZoom = _this$checkAndCorrect4.minZoom,
716
+ _domain = _this$checkAndCorrect4.domain,
717
+ _domainHasChanged = _this$checkAndCorrect4.domainHasChanged,
718
+ _minTime = _this$checkAndCorrect4.minTime,
719
+ _maxTime = _this$checkAndCorrect4.maxTime;
897
720
  this.setState({
898
721
  maxZoom: _maxZoom,
899
722
  minZoom: _minZoom,
900
723
  minTime: _minTime,
901
724
  maxTime: _maxTime,
902
725
  domain: _domain
903
- }); //if domain changed, update domain, and getItems will be done later
726
+ });
904
727
 
728
+ //if domain changed, update domain, and getItems will be done later
905
729
  if (_domainHasChanged) {
906
730
  var _domains = [_domain].concat(_toConsumableArray(this.props.domains.slice(1)));
907
-
908
731
  this.props.onUpdateDomains(_domains);
909
732
  } else {
910
733
  this.getItems(this.props, _domain);
911
734
  }
912
- } //If we got new histo change indicator
913
-
735
+ }
914
736
 
737
+ //If we got new histo change indicator
915
738
  if (prevProps.histo !== this.props.histo) {
916
739
  this.setState({
917
740
  waitForLoad: false
918
741
  });
919
- } //Recompute margin on legend change
920
-
742
+ }
921
743
 
744
+ //Recompute margin on legend change
922
745
  if (prevProps.metricsDefinition.legends !== this.props.metricsDefinition.legends) {
923
746
  this.computeMarginAndWidth(this.props);
924
747
  }
@@ -927,20 +750,17 @@ var TimeLine = /*#__PURE__*/function (_Component) {
927
750
  key: "computeMarginAndWidth",
928
751
  value: function computeMarginAndWidth(props) {
929
752
  var _this$props8 = this.props,
930
- margin = _this$props8.margin,
931
- showLegend = _this$props8.showLegend,
932
- metricsDefinition = _this$props8.metricsDefinition,
933
- width = _this$props8.width;
934
-
753
+ margin = _this$props8.margin,
754
+ showLegend = _this$props8.showLegend,
755
+ metricsDefinition = _this$props8.metricsDefinition,
756
+ width = _this$props8.width;
935
757
  var localMargin = _objectSpread(_objectSpread({}, marginDefault), margin);
936
-
937
758
  if (showLegend) {
938
759
  var maxLength = (0, _max2["default"])(metricsDefinition.legends.map(function (s) {
939
760
  return s.length;
940
761
  }));
941
762
  localMargin.left = (0, _max2["default"])([5 + maxLength * 9, localMargin.left]);
942
763
  }
943
-
944
764
  return {
945
765
  margin: localMargin,
946
766
  histoWidth: width - localMargin.left - localMargin.right
@@ -954,13 +774,12 @@ var TimeLine = /*#__PURE__*/function (_Component) {
954
774
  this.xAxis = (0, _d3Scale.scaleTime)().domain([domain.min, domain.max]).range([0, histoWidth]);
955
775
  this.xAxis.clamp(true);
956
776
  var ticks = this.xAxis.ticks((0, _floor2["default"])(histoWidth / props.xAxis.spaceBetweenTicks));
957
- var intervalMs = (0, _max2["default"])([(0, _round2["default"])((0, _moment["default"])(ticks[1]).diff((0, _moment["default"])(ticks[0])) / props.xAxis.barsBetweenTicks), this.props.smallestResolution.asMilliseconds()]);
777
+ var intervalMs = (0, _max2["default"])([(0, _round2["default"])((0, _momentTimezone["default"])(ticks[1]).diff((0, _momentTimezone["default"])(ticks[0])) / props.xAxis.barsBetweenTicks), this.props.smallestResolution.asMilliseconds()]);
958
778
  this.setState({
959
779
  histoWidth: histoWidth,
960
780
  isActive: true,
961
781
  ticks: ticks
962
782
  });
963
-
964
783
  if (shouldReload && intervalMs) {
965
784
  this.widthOfLastUpdate = props.width;
966
785
  this.setState({
@@ -973,13 +792,14 @@ var TimeLine = /*#__PURE__*/function (_Component) {
973
792
  key: "prepareVerticalScale",
974
793
  value: function prepareVerticalScale(_ref3) {
975
794
  var yAxis = _ref3.yAxis,
976
- xAxis = _ref3.xAxis,
977
- height = _ref3.height,
978
- histo = _ref3.histo,
979
- margin = _ref3.margin;
795
+ xAxis = _ref3.xAxis,
796
+ height = _ref3.height,
797
+ histo = _ref3.histo,
798
+ margin = _ref3.margin;
980
799
  var items = histo && histo.items;
981
- var maxHeight = height - margin.bottom - margin.top - (xAxis.height || xAxisDefault.height); //Y Axis computation
800
+ var maxHeight = height - margin.bottom - margin.top - (xAxis.height || xAxisDefault.height);
982
801
 
802
+ //Y Axis computation
983
803
  var maxScale = items ? (0, _max2["default"])(items.map(function (i) {
984
804
  return i.total;
985
805
  })) || 0 : 0;
@@ -995,19 +815,17 @@ var TimeLine = /*#__PURE__*/function (_Component) {
995
815
  key: "prepareHistogram",
996
816
  value: function prepareHistogram(_ref4) {
997
817
  var _this2 = this;
998
-
999
818
  var histo = _ref4.histo,
1000
- domain = _ref4.domain,
1001
- verticalScale = _ref4.verticalScale;
1002
-
819
+ domain = _ref4.domain,
820
+ verticalScale = _ref4.verticalScale;
1003
821
  if (histo && histo.items && domain) {
1004
822
  var min = domain.min,
1005
- max = domain.max;
823
+ max = domain.max;
1006
824
  return histo.items.filter(function (item) {
1007
825
  return item.total > 0 && item.time.isSameOrAfter(min) && item.time.isBefore(max);
1008
826
  }).map(function (item) {
1009
- var start = (0, _moment["default"])(item.time);
1010
- var end = (0, _moment["default"])(item.time).add(histo.intervalMs);
827
+ var start = (0, _momentTimezone["default"])(item.time);
828
+ var end = (0, _momentTimezone["default"])(item.time).add(histo.intervalMs);
1011
829
  return {
1012
830
  x1: _this2.xAxis(start),
1013
831
  x2: _this2.xAxis(end),
@@ -1026,40 +844,39 @@ var TimeLine = /*#__PURE__*/function (_Component) {
1026
844
  key: "render",
1027
845
  value: function render() {
1028
846
  var _this3 = this;
1029
-
1030
847
  var _this$props9 = this.props,
1031
- width = _this$props9.width,
1032
- height = _this$props9.height,
1033
- histo = _this$props9.histo,
1034
- tools = _this$props9.tools,
1035
- quality = _this$props9.quality,
1036
- qualityScale = _this$props9.qualityScale,
1037
- metricsDefinition = _this$props9.metricsDefinition,
1038
- classes = _this$props9.classes,
1039
- rcToolTipPrefixCls = _this$props9.rcToolTipPrefixCls,
1040
- showLegend = _this$props9.showLegend,
1041
- onFormatTimeLegend = _this$props9.onFormatTimeLegend,
1042
- onFormatMetricLegend = _this$props9.onFormatMetricLegend,
1043
- onResetTime = _this$props9.onResetTime,
1044
- onFormatTimeToolTips = _this$props9.onFormatTimeToolTips,
1045
- xAxis = _this$props9.xAxis,
1046
- yAxis = _this$props9.yAxis,
1047
- showHistoToolTip = _this$props9.showHistoToolTip,
1048
- HistoToolTip = _this$props9.HistoToolTip;
848
+ width = _this$props9.width,
849
+ height = _this$props9.height,
850
+ histo = _this$props9.histo,
851
+ tools = _this$props9.tools,
852
+ quality = _this$props9.quality,
853
+ qualityScale = _this$props9.qualityScale,
854
+ metricsDefinition = _this$props9.metricsDefinition,
855
+ classes = _this$props9.classes,
856
+ rcToolTipPrefixCls = _this$props9.rcToolTipPrefixCls,
857
+ showLegend = _this$props9.showLegend,
858
+ onFormatTimeLegend = _this$props9.onFormatTimeLegend,
859
+ onFormatMetricLegend = _this$props9.onFormatMetricLegend,
860
+ onResetTime = _this$props9.onResetTime,
861
+ onFormatTimeToolTips = _this$props9.onFormatTimeToolTips,
862
+ xAxis = _this$props9.xAxis,
863
+ yAxis = _this$props9.yAxis,
864
+ showHistoToolTip = _this$props9.showHistoToolTip,
865
+ HistoToolTip = _this$props9.HistoToolTip;
1049
866
  var _this$state6 = this.state,
1050
- isActive = _this$state6.isActive,
1051
- domain = _this$state6.domain,
1052
- histoWidth = _this$state6.histoWidth,
1053
- margin = _this$state6.margin,
1054
- start = _this$state6.start,
1055
- stop = _this$state6.stop,
1056
- maxZoom = _this$state6.maxZoom,
1057
- minZoom = _this$state6.minZoom,
1058
- maxTimespan = _this$state6.maxTimespan,
1059
- barHovered = _this$state6.barHovered,
1060
- tooltipVisible = _this$state6.tooltipVisible,
1061
- ticks = _this$state6.ticks,
1062
- dragging = _this$state6.dragging;
867
+ isActive = _this$state6.isActive,
868
+ domain = _this$state6.domain,
869
+ histoWidth = _this$state6.histoWidth,
870
+ margin = _this$state6.margin,
871
+ start = _this$state6.start,
872
+ stop = _this$state6.stop,
873
+ maxZoom = _this$state6.maxZoom,
874
+ minZoom = _this$state6.minZoom,
875
+ maxTimespan = _this$state6.maxTimespan,
876
+ barHovered = _this$state6.barHovered,
877
+ tooltipVisible = _this$state6.tooltipVisible,
878
+ ticks = _this$state6.ticks,
879
+ dragging = _this$state6.dragging;
1063
880
  var xAxisHeight = xAxis.height || xAxisDefault.height;
1064
881
  var pointZero = {
1065
882
  x: 0,
@@ -1069,18 +886,16 @@ var TimeLine = /*#__PURE__*/function (_Component) {
1069
886
  x: 0,
1070
887
  y: margin.top - 5
1071
888
  };
1072
-
1073
889
  var _this$prepareVertical = this.prepareVerticalScale({
1074
- yAxis: yAxis,
1075
- xAxis: xAxis,
1076
- height: height,
1077
- histo: histo,
1078
- margin: margin
1079
- }),
1080
- verticalScale = _this$prepareVertical.verticalScale,
1081
- verticalMarks = _this$prepareVertical.verticalMarks,
1082
- maxHeight = _this$prepareVertical.maxHeight;
1083
-
890
+ yAxis: yAxis,
891
+ xAxis: xAxis,
892
+ height: height,
893
+ histo: histo,
894
+ margin: margin
895
+ }),
896
+ verticalScale = _this$prepareVertical.verticalScale,
897
+ verticalMarks = _this$prepareVertical.verticalMarks,
898
+ maxHeight = _this$prepareVertical.maxHeight;
1084
899
  var items = this.prepareHistogram({
1085
900
  histo: histo,
1086
901
  domain: domain,
@@ -1225,34 +1040,31 @@ var TimeLine = /*#__PURE__*/function (_Component) {
1225
1040
  })));
1226
1041
  }
1227
1042
  }]);
1228
-
1229
1043
  return TimeLine;
1230
1044
  }(_react.Component);
1231
-
1232
1045
  exports["default"] = TimeLine;
1233
-
1234
1046
  _defineProperty(TimeLine, "propTypes", {
1235
1047
  className: _propTypes["default"].string,
1236
1048
  classes: _propTypes["default"].object,
1237
1049
  rcToolTipPrefixCls: _propTypes["default"].string,
1238
1050
  timeSpan: _propTypes["default"].shape({
1239
- start: _propTypes["default"].instanceOf(_moment["default"]).isRequired,
1240
- stop: _propTypes["default"].instanceOf(_moment["default"]).isRequired
1051
+ start: _propTypes["default"].instanceOf(_momentTimezone["default"]).isRequired,
1052
+ stop: _propTypes["default"].instanceOf(_momentTimezone["default"]).isRequired
1241
1053
  }).isRequired,
1242
1054
  domains: _propTypes["default"].arrayOf(_propTypes["default"].shape({
1243
- min: _propTypes["default"].instanceOf(_moment["default"]).isRequired,
1244
- max: _propTypes["default"].instanceOf(_moment["default"]).isRequired
1055
+ min: _propTypes["default"].instanceOf(_momentTimezone["default"]).isRequired,
1056
+ max: _propTypes["default"].instanceOf(_momentTimezone["default"]).isRequired
1245
1057
  })).isRequired,
1246
1058
  maxDomain: _propTypes["default"].shape({
1247
- min: _propTypes["default"].instanceOf(_moment["default"]),
1248
- max: _propTypes["default"].instanceOf(_moment["default"])
1059
+ min: _propTypes["default"].instanceOf(_momentTimezone["default"]),
1060
+ max: _propTypes["default"].instanceOf(_momentTimezone["default"])
1249
1061
  }),
1250
1062
  biggestVisibleDomain: _propTypes["default"].object,
1251
1063
  smallestResolution: _propTypes["default"].object.isRequired,
1252
1064
  biggestTimeSpan: _propTypes["default"].object,
1253
1065
  histo: _propTypes["default"].shape({
1254
1066
  items: _propTypes["default"].arrayOf(_propTypes["default"].shape({
1255
- time: _propTypes["default"].instanceOf(_moment["default"]).isRequired,
1067
+ time: _propTypes["default"].instanceOf(_momentTimezone["default"]).isRequired,
1256
1068
  metrics: _propTypes["default"].arrayOf(_propTypes["default"].number).isRequired,
1257
1069
  total: _propTypes["default"].number.isRequired
1258
1070
  })),
@@ -1262,7 +1074,7 @@ _defineProperty(TimeLine, "propTypes", {
1262
1074
  HistoToolTip: _propTypes["default"].elementType,
1263
1075
  quality: _propTypes["default"].shape({
1264
1076
  items: _propTypes["default"].arrayOf(_propTypes["default"].shape({
1265
- time: _propTypes["default"].instanceOf(_moment["default"]).isRequired,
1077
+ time: _propTypes["default"].instanceOf(_momentTimezone["default"]).isRequired,
1266
1078
  quality: _propTypes["default"].number.isRequired,
1267
1079
  tip: _propTypes["default"].node
1268
1080
  })),
@@ -1338,7 +1150,6 @@ _defineProperty(TimeLine, "propTypes", {
1338
1150
  onFormatTimeLegend: _propTypes["default"].func.isRequired,
1339
1151
  onFormatMetricLegend: _propTypes["default"].func.isRequired
1340
1152
  });
1341
-
1342
1153
  _defineProperty(TimeLine, "defaultProps", {
1343
1154
  classes: {},
1344
1155
  rcToolTipPrefixCls: _theme["default"].rcToolTipPrefixCls,