@osrd-project/ui-charts 0.0.82 → 0.0.83
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/dist/chronogram/components/Chronogram.d.ts +1 -1
- package/dist/chronogram/components/ChronogramCanvas.d.ts +3 -0
- package/dist/chronogram/components/ChronogramManchette.d.ts +9 -0
- package/dist/chronogram/components/OccupancyBlocksLayer.d.ts +1 -0
- package/dist/chronogram/hooks/useChronogram.d.ts +35 -0
- package/dist/chronogram/index.d.ts +6 -1
- package/dist/chronogram/lib/const.d.ts +5 -0
- package/dist/chronogram/lib/types.d.ts +15 -6
- package/dist/chronogram/utils/format.d.ts +1 -0
- package/dist/common/helpers/colors.d.ts +8 -3
- package/dist/{spaceTimeChart → common}/hooks/useMouseInteractions.d.ts +1 -1
- package/dist/{spaceTimeChart → common}/hooks/useMouseTracking.d.ts +1 -1
- package/dist/common/types.d.ts +1 -1
- package/dist/index.esm.js +828 -529
- package/dist/index.esm.js.map +1 -1
- package/dist/manchette/components/ManchetteWithSpaceTimeChart.d.ts +1 -1
- package/dist/spaceTimeChart/lib/context.d.ts +1 -1
- package/dist/speedSpaceChart/components/utils.d.ts +1 -1
- package/dist/theme.css +963 -279
- package/dist/theme.css.map +1 -1
- package/dist/trackOccupancyDiagram/lib/types.d.ts +1 -1
- package/package.json +8 -7
package/dist/index.esm.js
CHANGED
|
@@ -1,12 +1,269 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, { useMemo, useState, useCallback, useEffect, createContext, useContext, useRef, Fragment } from 'react';
|
|
2
|
+
import { Slider, Checkbox, CheckboxesTree } from '@osrd-project/ui-core';
|
|
3
|
+
import { clamp as clamp$1, isEqual, inRange, last, flatten, sortBy, sum } from 'lodash';
|
|
2
4
|
import cx from 'classnames';
|
|
3
|
-
import { isEqual, inRange, clamp as clamp$1, last, flatten, sortBy, sum } from 'lodash';
|
|
4
5
|
import chroma from 'chroma-js';
|
|
5
|
-
import { ZoomOut, ZoomIn, Iterations, Sliders, X, KebabHorizontal } from '@osrd-project/ui-icons';
|
|
6
|
-
import { Checkbox, CheckboxesTree, Slider } from '@osrd-project/ui-core';
|
|
6
|
+
import { Note, XCircle, ZoomOut, ZoomIn, Iterations, Sliders, X, KebabHorizontal } from '@osrd-project/ui-icons';
|
|
7
7
|
import * as d3selection from 'd3-selection';
|
|
8
8
|
import * as d3zoom from 'd3-zoom';
|
|
9
9
|
|
|
10
|
+
const INITIAL_OP_LIST_HEIGHT = 521;
|
|
11
|
+
const BASE_WAYPOINT_HEIGHT = 32;
|
|
12
|
+
const INITIAL_SPACE_TIME_CHART_HEIGHT = INITIAL_OP_LIST_HEIGHT + 40;
|
|
13
|
+
const MIN_ZOOM_MS_PER_PX = 600_000;
|
|
14
|
+
const MAX_ZOOM_MS_PER_PX = 625;
|
|
15
|
+
const DEFAULT_ZOOM_MS_PER_PX = 7_500;
|
|
16
|
+
const MIN_ZOOM_X = 0;
|
|
17
|
+
const MAX_ZOOM_X = 100;
|
|
18
|
+
const MIN_ZOOM_Y = 1;
|
|
19
|
+
const MAX_ZOOM_Y = 10.5;
|
|
20
|
+
const ZOOM_Y_DELTA = 0.5;
|
|
21
|
+
const MAX_ZOOM_MANCHETTE_HEIGHT_MILLIMETER = 500_000;
|
|
22
|
+
const FOOTER_HEIGHT = 40; // height of the manchette footer
|
|
23
|
+
const WAYPOINT_LINE_HEIGHT = 16;
|
|
24
|
+
const PATH_COLOR_DEFAULT = '#8A714B';
|
|
25
|
+
|
|
26
|
+
const getHeightWithoutLastWaypoint = (height) => height - FOOTER_HEIGHT - BASE_WAYPOINT_HEIGHT;
|
|
27
|
+
const positionMmToKm = (position) => Math.round((position / 1000000) * 10) / 10;
|
|
28
|
+
const positionKmToMm = (position) => position * 1000000;
|
|
29
|
+
const calcTotalDistance = (ops) => {
|
|
30
|
+
if (ops.length === 0) {
|
|
31
|
+
return 0;
|
|
32
|
+
}
|
|
33
|
+
return ops.at(-1).position - ops.at(0).position;
|
|
34
|
+
};
|
|
35
|
+
function getDistance$1(a, b) {
|
|
36
|
+
return {
|
|
37
|
+
x: b.x - a.x,
|
|
38
|
+
y: b.y - a.y,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const zoomValueToTimeScale = (slider) => MIN_ZOOM_MS_PER_PX * Math.pow(MAX_ZOOM_MS_PER_PX / MIN_ZOOM_MS_PER_PX, slider / 100);
|
|
43
|
+
const timeScaleToZoomValue = (timeScale) => (100 * Math.log(timeScale / MIN_ZOOM_MS_PER_PX)) /
|
|
44
|
+
Math.log(MAX_ZOOM_MS_PER_PX / MIN_ZOOM_MS_PER_PX);
|
|
45
|
+
/**
|
|
46
|
+
* min zoom is computed with manchette px height between first and last waypoint.
|
|
47
|
+
* max zoom just the canvas drawing height (without the x-axis scale section)
|
|
48
|
+
*/
|
|
49
|
+
const getExtremaScales = (drawingHeightWithoutTopPadding, drawingHeightWithoutBothPadding, pathLengthMillimeter) => ({
|
|
50
|
+
minZoomMillimeterPerPx: pathLengthMillimeter / drawingHeightWithoutBothPadding,
|
|
51
|
+
maxZoomMillimeterPerPx: MAX_ZOOM_MANCHETTE_HEIGHT_MILLIMETER / drawingHeightWithoutTopPadding,
|
|
52
|
+
});
|
|
53
|
+
const zoomValueToSpaceScale = (minZoomMillimeterPerPx, maxZoomMillimeterPerPx, slider) => minZoomMillimeterPerPx *
|
|
54
|
+
Math.pow(maxZoomMillimeterPerPx / minZoomMillimeterPerPx, (slider - MIN_ZOOM_Y) / (MAX_ZOOM_Y - MIN_ZOOM_Y));
|
|
55
|
+
const spaceScaleToZoomValue = (minZoomMillimeterPerPx, maxZoomMillimeterPerPx, spaceScale) => ((MAX_ZOOM_Y - MIN_ZOOM_Y) * Math.log(spaceScale / minZoomMillimeterPerPx)) /
|
|
56
|
+
Math.log(maxZoomMillimeterPerPx / minZoomMillimeterPerPx) +
|
|
57
|
+
MIN_ZOOM_Y;
|
|
58
|
+
/** Zoom on X axis and center on the mouse position */
|
|
59
|
+
const zoomX = (currentZoom, currentOffset, newZoom, position) => {
|
|
60
|
+
const boundedZoom = clamp$1(newZoom, MIN_ZOOM_X, MAX_ZOOM_X);
|
|
61
|
+
const oldTimeScale = zoomValueToTimeScale(currentZoom);
|
|
62
|
+
const newTimeScale = zoomValueToTimeScale(boundedZoom);
|
|
63
|
+
const newOffset = position - ((position - currentOffset) * oldTimeScale) / newTimeScale;
|
|
64
|
+
return {
|
|
65
|
+
xZoom: boundedZoom,
|
|
66
|
+
xOffset: newOffset,
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
const filterVisibleElements$1 = (elements, totalDistance, heightWithoutFinalWaypoint, minSpace) => {
|
|
70
|
+
const getPosition = (waypoint) => (waypoint.position / totalDistance) * heightWithoutFinalWaypoint;
|
|
71
|
+
const firstElement = elements.at(0);
|
|
72
|
+
const lastElement = elements.at(-1);
|
|
73
|
+
if (!firstElement || !lastElement)
|
|
74
|
+
return elements;
|
|
75
|
+
const sortedElements = [...elements].sort((a, b) => (b.weight ?? 0) - (a.weight ?? 0));
|
|
76
|
+
const displayedElements = [firstElement, lastElement];
|
|
77
|
+
for (const element of sortedElements) {
|
|
78
|
+
const hasSpace = !displayedElements.some((displayed) => Math.abs(getPosition(element) - getPosition(displayed)) < minSpace);
|
|
79
|
+
if (hasSpace) {
|
|
80
|
+
displayedElements.push(element);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return displayedElements.sort((a, b) => a.position - b.position);
|
|
84
|
+
};
|
|
85
|
+
const selectWaypointsToDisplay = (waypoints, { height, isProportional, yZoom }) => {
|
|
86
|
+
if (waypoints.length < 2)
|
|
87
|
+
return [];
|
|
88
|
+
// display all waypoints in linear mode
|
|
89
|
+
if (!isProportional)
|
|
90
|
+
return waypoints;
|
|
91
|
+
const totalDistance = calcTotalDistance(waypoints);
|
|
92
|
+
const manchetteHeight = getHeightWithoutLastWaypoint(height);
|
|
93
|
+
// in proportional mode, hide some waypoints to avoid collisions
|
|
94
|
+
const minSpace = BASE_WAYPOINT_HEIGHT / yZoom;
|
|
95
|
+
return filterVisibleElements$1(waypoints, totalDistance, manchetteHeight, minSpace);
|
|
96
|
+
};
|
|
97
|
+
/**
|
|
98
|
+
* 2 modes for space scales
|
|
99
|
+
* km (isProportional): { coefficient: gives a scale in meter/pixel }
|
|
100
|
+
* linear: { size: height in pixel } (each point distributed evenly along the height of manchette.)
|
|
101
|
+
*/
|
|
102
|
+
const getScales = (waypoints, { isProportional, yZoom, height }, minZoomMillimeterPerPx, maxZoomMillimeterPerPx) => {
|
|
103
|
+
if (!waypoints.length)
|
|
104
|
+
return [];
|
|
105
|
+
if (waypoints.length === 1) {
|
|
106
|
+
const waypoint = waypoints[0];
|
|
107
|
+
return [
|
|
108
|
+
{
|
|
109
|
+
from: waypoint.position,
|
|
110
|
+
to: waypoint.position,
|
|
111
|
+
size: height || 1,
|
|
112
|
+
},
|
|
113
|
+
];
|
|
114
|
+
}
|
|
115
|
+
if (!isProportional) {
|
|
116
|
+
return waypoints.slice(0, -1).map((from, index) => {
|
|
117
|
+
const to = waypoints[index + 1];
|
|
118
|
+
return {
|
|
119
|
+
from: from.position,
|
|
120
|
+
to: to.position,
|
|
121
|
+
size: BASE_WAYPOINT_HEIGHT * yZoom,
|
|
122
|
+
};
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
const from = waypoints.at(0).position;
|
|
126
|
+
const to = waypoints.at(-1).position;
|
|
127
|
+
const scaleCoeff = isProportional
|
|
128
|
+
? { coefficient: zoomValueToSpaceScale(minZoomMillimeterPerPx, maxZoomMillimeterPerPx, yZoom) }
|
|
129
|
+
: { size: BASE_WAYPOINT_HEIGHT * (waypoints.length - 1) * yZoom };
|
|
130
|
+
return [
|
|
131
|
+
{
|
|
132
|
+
from,
|
|
133
|
+
to,
|
|
134
|
+
...scaleCoeff,
|
|
135
|
+
},
|
|
136
|
+
];
|
|
137
|
+
};
|
|
138
|
+
const isInteractiveWaypoint = (item) => item != null && typeof item === 'object' && 'id' in item && 'position' in item;
|
|
139
|
+
|
|
140
|
+
const CHRONOGRAM_HEADER_HEIGHT = 33;
|
|
141
|
+
const CHRONOGRAM_BOTTOM_PADDING = 40;
|
|
142
|
+
const INITIAL_CHRONOGRAM_HEIGHT = 600;
|
|
143
|
+
const LEVEL_CROSSING_ITEM_HEIGHT = 48;
|
|
144
|
+
const CHRONOGRAM_SLIDER_WIDTH = 122;
|
|
145
|
+
|
|
146
|
+
// TODO: manchette's existant utils => common ?
|
|
147
|
+
function getDistance(a, b) {
|
|
148
|
+
return {
|
|
149
|
+
x: b.x - a.x,
|
|
150
|
+
y: b.y - a.y,
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
const INITIAL_STATE$1 = {
|
|
154
|
+
height: 0,
|
|
155
|
+
xOffset: 0,
|
|
156
|
+
yOffset: 0,
|
|
157
|
+
panning: null,
|
|
158
|
+
xZoom: timeScaleToZoomValue(3000),
|
|
159
|
+
};
|
|
160
|
+
const useChronogram = ({ itemCount, chronogramManchetteRef, chronogramChartRef, chronogramHeight, }) => {
|
|
161
|
+
const calculatedInitialHeight = useMemo(() => CHRONOGRAM_HEADER_HEIGHT + itemCount * LEVEL_CROSSING_ITEM_HEIGHT + CHRONOGRAM_BOTTOM_PADDING, [itemCount]);
|
|
162
|
+
const [isShiftPressed, setIsShiftPressed] = useState(false);
|
|
163
|
+
const [state, setState] = useState({
|
|
164
|
+
...INITIAL_STATE$1,
|
|
165
|
+
height: calculatedInitialHeight,
|
|
166
|
+
});
|
|
167
|
+
const { height, xOffset, yOffset, xZoom } = state;
|
|
168
|
+
const setHeight = useCallback((newHeight) => {
|
|
169
|
+
setState((prev) => ({
|
|
170
|
+
...prev,
|
|
171
|
+
height: Math.max(newHeight, calculatedInitialHeight),
|
|
172
|
+
}));
|
|
173
|
+
}, [calculatedInitialHeight]);
|
|
174
|
+
useEffect(() => {
|
|
175
|
+
// TODO: fix this lint
|
|
176
|
+
/* eslint-disable-next-line react-hooks/set-state-in-effect */
|
|
177
|
+
setHeight(chronogramHeight);
|
|
178
|
+
}, [chronogramHeight, setHeight]);
|
|
179
|
+
// =========== Pan (horizontal time navigation) ===========
|
|
180
|
+
const onTimePan = useCallback((payload) => {
|
|
181
|
+
setState((prev) => {
|
|
182
|
+
if (!payload.isPanning) {
|
|
183
|
+
return {
|
|
184
|
+
...prev,
|
|
185
|
+
panning: null,
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
if (!prev.panning) {
|
|
189
|
+
return {
|
|
190
|
+
...prev,
|
|
191
|
+
panning: { initialOffset: { x: prev.xOffset, y: prev.yOffset } },
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
const { initialOffset } = prev.panning;
|
|
195
|
+
const diff = getDistance(payload.initialPosition, payload.position);
|
|
196
|
+
const newXOffset = initialOffset.x + diff.x;
|
|
197
|
+
return {
|
|
198
|
+
...prev,
|
|
199
|
+
xOffset: newXOffset,
|
|
200
|
+
};
|
|
201
|
+
});
|
|
202
|
+
}, []);
|
|
203
|
+
// =========== Y Scroll ===========
|
|
204
|
+
const handleVerticalScroll = useCallback(() => {
|
|
205
|
+
if (chronogramManchetteRef.current) {
|
|
206
|
+
const { scrollTop } = chronogramManchetteRef.current;
|
|
207
|
+
if (scrollTop >= 0) {
|
|
208
|
+
setState((prev) => ({ ...prev, yOffset: scrollTop }));
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
}, [chronogramManchetteRef]);
|
|
212
|
+
// ======== Shift key events ==========
|
|
213
|
+
const handleKeyDown = useCallback((event) => {
|
|
214
|
+
if (event.key === 'Shift') {
|
|
215
|
+
setIsShiftPressed(true);
|
|
216
|
+
}
|
|
217
|
+
}, []);
|
|
218
|
+
const handleKeyUp = useCallback((event) => {
|
|
219
|
+
if (event.key === 'Shift') {
|
|
220
|
+
setIsShiftPressed(false);
|
|
221
|
+
}
|
|
222
|
+
}, []);
|
|
223
|
+
useEffect(() => {
|
|
224
|
+
window.addEventListener('keydown', handleKeyDown);
|
|
225
|
+
window.addEventListener('keyup', handleKeyUp);
|
|
226
|
+
return () => {
|
|
227
|
+
window.removeEventListener('keydown', handleKeyDown);
|
|
228
|
+
window.removeEventListener('keyup', handleKeyUp);
|
|
229
|
+
};
|
|
230
|
+
}, [handleKeyDown, handleKeyUp]);
|
|
231
|
+
// =========== X Zoom ===========
|
|
232
|
+
const handleXZoom = useCallback((newXZoom, xPosition = (chronogramChartRef.current?.offsetWidth || 0) / 2) => {
|
|
233
|
+
setState((prev) => ({
|
|
234
|
+
...prev,
|
|
235
|
+
...zoomX(prev.xZoom, prev.xOffset, newXZoom, xPosition),
|
|
236
|
+
}));
|
|
237
|
+
}, [chronogramChartRef]);
|
|
238
|
+
const handleXZoomOnWheelEvent = useCallback((wheelEvent, newXZoom, xPosition) => {
|
|
239
|
+
if (isShiftPressed) {
|
|
240
|
+
wheelEvent.preventDefault();
|
|
241
|
+
handleXZoom(newXZoom, xPosition);
|
|
242
|
+
}
|
|
243
|
+
}, [handleXZoom, isShiftPressed]);
|
|
244
|
+
return useMemo(() => ({
|
|
245
|
+
handleVerticalScroll,
|
|
246
|
+
handleXZoom,
|
|
247
|
+
handleXZoomOnWheelEvent,
|
|
248
|
+
height,
|
|
249
|
+
onPan: onTimePan,
|
|
250
|
+
setHeight,
|
|
251
|
+
xOffset,
|
|
252
|
+
xZoom,
|
|
253
|
+
yOffset,
|
|
254
|
+
}), [
|
|
255
|
+
height,
|
|
256
|
+
setHeight,
|
|
257
|
+
xOffset,
|
|
258
|
+
xZoom,
|
|
259
|
+
yOffset,
|
|
260
|
+
handleVerticalScroll,
|
|
261
|
+
handleXZoom,
|
|
262
|
+
handleXZoomOnWheelEvent,
|
|
263
|
+
onTimePan,
|
|
264
|
+
]);
|
|
265
|
+
};
|
|
266
|
+
|
|
10
267
|
const TimeChartCanvasContext = createContext(
|
|
11
268
|
// That value should never be used, since the context should always be accessed within a provider
|
|
12
269
|
undefined);
|
|
@@ -72,9 +329,15 @@ const HOUR = 60 * MINUTE;
|
|
|
72
329
|
|
|
73
330
|
const COLORS_TO_INDICES = {};
|
|
74
331
|
const INDICES_TO_COLORS = {};
|
|
75
|
-
|
|
76
|
-
const
|
|
77
|
-
const
|
|
332
|
+
// COLORS DEFINITIONS:
|
|
333
|
+
const BLACK_100 = 'rgb(0, 0, 0)';
|
|
334
|
+
const BLACK_ALPHA_25 = 'rgba(0, 0, 0, 0.25)';
|
|
335
|
+
const GREY_90 = 'rgb(31, 27, 23)';
|
|
336
|
+
const GREY_50$3 = 'rgb(121, 118, 113)';
|
|
337
|
+
const GREY_30$1 = 'rgb(182, 178, 175)';
|
|
338
|
+
const RED_100 = 'rgb(221, 34, 34)';
|
|
339
|
+
const WHITE_100$3 = 'rgb(255, 255, 255)';
|
|
340
|
+
const WHITE_ALPHA_75 = 'rgba(255, 255, 255, 0.75)';
|
|
78
341
|
/**
|
|
79
342
|
* This function returns a unique hex color corresponding to the given index. The colors are
|
|
80
343
|
* generated as #000001, #000002 ... #0000ff, #000100 etc.
|
|
@@ -450,60 +713,255 @@ function useDraw(contextKey, layer, fn) {
|
|
|
450
713
|
}, [layer, fn, register, unregister]);
|
|
451
714
|
}
|
|
452
715
|
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
}
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
716
|
+
/**
|
|
717
|
+
* This function takes a MouseEvent and an HTMLElement, and returns the position of the mouse,
|
|
718
|
+
* relatively to the DOM element. This allows for instance dragging an element that is on the given
|
|
719
|
+
* DOM element while the events are bound to the document or the body.
|
|
720
|
+
*/
|
|
721
|
+
function getEventPosition(e, dom) {
|
|
722
|
+
const bbox = dom.getBoundingClientRect();
|
|
723
|
+
return {
|
|
724
|
+
x: e.clientX - bbox.left,
|
|
725
|
+
y: e.clientY - bbox.top,
|
|
726
|
+
};
|
|
727
|
+
}
|
|
728
|
+
/**
|
|
729
|
+
* This function returns a delta value for a given WheelEvent. It can be very useful, since the
|
|
730
|
+
* given `deltaY` and `detail` attributes are not normalized.
|
|
731
|
+
*/
|
|
732
|
+
function getEventWheelDelta(e) {
|
|
733
|
+
if (typeof e.deltaY !== 'undefined')
|
|
734
|
+
return (e.deltaY * -3) / 360;
|
|
735
|
+
if (typeof e.detail !== 'undefined')
|
|
736
|
+
return e.detail / -9;
|
|
737
|
+
throw new Error('Could not extract delta from event.');
|
|
738
|
+
}
|
|
739
|
+
|
|
740
|
+
/**
|
|
741
|
+
* This hook handles SpaceTimeChart mouse interactions.
|
|
742
|
+
* It is an internal hook, and should only be used inside SpaceTimeChart.
|
|
743
|
+
*/
|
|
744
|
+
function useMouseInteractions(dom, { position, hoveredItem, down, isHover }, handlers, context) {
|
|
745
|
+
const contextRef = useRef(context);
|
|
746
|
+
const handlersRef = useRef(handlers);
|
|
747
|
+
const [panningState, setPanningState] = useState({ type: 'idle' });
|
|
748
|
+
// Cache latest context in ref:
|
|
749
|
+
useEffect(() => {
|
|
750
|
+
contextRef.current = context;
|
|
751
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
752
|
+
}, [context.fingerprint]);
|
|
753
|
+
useEffect(() => {
|
|
754
|
+
handlersRef.current = handlers;
|
|
755
|
+
}, [handlers]);
|
|
756
|
+
// Generate event handlers:
|
|
757
|
+
const clickHandler = useCallback((event) => {
|
|
758
|
+
if (!dom)
|
|
759
|
+
return;
|
|
760
|
+
const { onClick } = handlersRef.current;
|
|
761
|
+
if (onClick) {
|
|
762
|
+
onClick({
|
|
763
|
+
event,
|
|
764
|
+
position,
|
|
765
|
+
data: contextRef.current.getData(position),
|
|
766
|
+
hoveredItem,
|
|
767
|
+
context: contextRef.current,
|
|
768
|
+
});
|
|
769
|
+
}
|
|
770
|
+
}, [dom, hoveredItem, position]);
|
|
771
|
+
const wheelHandler = useCallback((event) => {
|
|
772
|
+
const { onZoom } = handlersRef.current;
|
|
773
|
+
if (onZoom && dom)
|
|
774
|
+
onZoom({
|
|
775
|
+
delta: getEventWheelDelta(event),
|
|
776
|
+
position: getEventPosition(event, dom),
|
|
777
|
+
event,
|
|
778
|
+
context: contextRef.current,
|
|
779
|
+
});
|
|
780
|
+
}, [dom]);
|
|
781
|
+
// Bind event handlers:
|
|
782
|
+
useEffect(() => {
|
|
783
|
+
if (!dom)
|
|
784
|
+
return;
|
|
785
|
+
dom.addEventListener('click', clickHandler);
|
|
786
|
+
return () => {
|
|
787
|
+
dom.removeEventListener('click', clickHandler);
|
|
788
|
+
};
|
|
789
|
+
}, [dom, clickHandler]);
|
|
790
|
+
useEffect(() => {
|
|
791
|
+
if (!dom)
|
|
792
|
+
return;
|
|
793
|
+
dom.addEventListener('wheel', wheelHandler);
|
|
794
|
+
return () => {
|
|
795
|
+
dom.removeEventListener('wheel', wheelHandler);
|
|
796
|
+
};
|
|
797
|
+
}, [dom, wheelHandler]);
|
|
798
|
+
// Listen to "up" and "down" updates:
|
|
799
|
+
useEffect(() => {
|
|
800
|
+
const { onPan } = handlersRef.current;
|
|
801
|
+
if (down) {
|
|
802
|
+
// Start panning:
|
|
803
|
+
setPanningState({
|
|
804
|
+
type: 'panning',
|
|
805
|
+
initialPosition: position,
|
|
806
|
+
initialData: contextRef.current.getData(position),
|
|
807
|
+
});
|
|
808
|
+
}
|
|
809
|
+
else {
|
|
810
|
+
// Stop panning:
|
|
811
|
+
if (panningState.type === 'panning' && onPan)
|
|
812
|
+
onPan({
|
|
813
|
+
isPanning: false,
|
|
814
|
+
position,
|
|
815
|
+
initialPosition: panningState.initialPosition,
|
|
816
|
+
data: contextRef.current.getData(position),
|
|
817
|
+
initialData: panningState.initialData,
|
|
818
|
+
context: contextRef.current,
|
|
819
|
+
});
|
|
820
|
+
if (panningState.type !== 'idle')
|
|
821
|
+
setPanningState({ type: 'idle' });
|
|
822
|
+
}
|
|
823
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
824
|
+
}, [down]);
|
|
825
|
+
// Listen to "move" updates:
|
|
826
|
+
useEffect(() => {
|
|
827
|
+
const { onPan, onMouseMove } = handlersRef.current;
|
|
828
|
+
if (onMouseMove) {
|
|
829
|
+
onMouseMove({
|
|
830
|
+
position,
|
|
831
|
+
isHover,
|
|
832
|
+
data: contextRef.current.getData(position),
|
|
833
|
+
hoveredItem,
|
|
834
|
+
context: contextRef.current,
|
|
835
|
+
});
|
|
836
|
+
}
|
|
837
|
+
if (panningState.type === 'panning' && onPan)
|
|
838
|
+
onPan({
|
|
839
|
+
isPanning: true,
|
|
840
|
+
position,
|
|
841
|
+
initialPosition: panningState.initialPosition,
|
|
842
|
+
data: contextRef.current.getData(position),
|
|
843
|
+
initialData: panningState.initialData,
|
|
844
|
+
context: contextRef.current,
|
|
845
|
+
});
|
|
846
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
847
|
+
}, [position.x, position.y]);
|
|
848
|
+
}
|
|
849
|
+
|
|
850
|
+
/**
|
|
851
|
+
* This hook handles SpaceTimeChart mouse tracking.
|
|
852
|
+
* It is an internal hook, and should only be used inside SpaceTimeChart.
|
|
853
|
+
*/
|
|
854
|
+
function useMouseTracking(dom) {
|
|
855
|
+
const [mouseState, setMouseState] = useState({
|
|
856
|
+
isHover: false,
|
|
857
|
+
position: { x: NaN, y: NaN },
|
|
858
|
+
});
|
|
859
|
+
// Generate event handlers:
|
|
860
|
+
const downHandler = useCallback((e) => {
|
|
861
|
+
if (!dom)
|
|
862
|
+
return;
|
|
863
|
+
setMouseState((state) => ({
|
|
864
|
+
...state,
|
|
865
|
+
down: { ctrl: e.ctrlKey, shift: e.shiftKey },
|
|
866
|
+
}));
|
|
867
|
+
}, [dom]);
|
|
868
|
+
const upHandler = useCallback(() => {
|
|
869
|
+
if (!dom)
|
|
870
|
+
return;
|
|
871
|
+
setMouseState((state) => ({ ...state, down: undefined }));
|
|
872
|
+
}, [dom]);
|
|
873
|
+
const moveHandler = useCallback((event) => {
|
|
874
|
+
if (!dom)
|
|
875
|
+
return;
|
|
876
|
+
const position = getEventPosition(event, dom);
|
|
877
|
+
const { x, y } = position;
|
|
878
|
+
const width = dom.offsetWidth;
|
|
879
|
+
const height = dom.offsetHeight;
|
|
880
|
+
const isHover = x >= 0 && x <= width && y >= 0 && y <= height;
|
|
881
|
+
setMouseState((state) => ({
|
|
882
|
+
...state,
|
|
883
|
+
position,
|
|
884
|
+
isHover,
|
|
885
|
+
}));
|
|
886
|
+
}, [dom]);
|
|
887
|
+
// Bind event handlers:
|
|
888
|
+
useEffect(() => {
|
|
889
|
+
if (!dom)
|
|
890
|
+
return;
|
|
891
|
+
dom.addEventListener('mousedown', downHandler);
|
|
892
|
+
return () => {
|
|
893
|
+
dom.removeEventListener('mousedown', downHandler);
|
|
894
|
+
};
|
|
895
|
+
}, [dom, downHandler]);
|
|
896
|
+
useEffect(() => {
|
|
897
|
+
document.addEventListener('mouseup', upHandler);
|
|
898
|
+
return () => {
|
|
899
|
+
document.removeEventListener('mouseup', upHandler);
|
|
900
|
+
};
|
|
901
|
+
}, [upHandler]);
|
|
902
|
+
useEffect(() => {
|
|
903
|
+
document.addEventListener('mousemove', moveHandler);
|
|
904
|
+
return () => {
|
|
905
|
+
document.removeEventListener('mousemove', moveHandler);
|
|
906
|
+
};
|
|
907
|
+
}, [moveHandler]);
|
|
908
|
+
return mouseState;
|
|
909
|
+
}
|
|
910
|
+
|
|
911
|
+
const MARGIN = 100;
|
|
912
|
+
const MINUTE_OPTIONS = {
|
|
913
|
+
minute: '2-digit',
|
|
914
|
+
hour12: false,
|
|
915
|
+
};
|
|
916
|
+
const HOUR_OPTIONS_SHORT = {
|
|
917
|
+
hour: '2-digit',
|
|
918
|
+
hour12: false,
|
|
919
|
+
};
|
|
920
|
+
const HOUR_OPTIONS_LONG = {
|
|
921
|
+
hour: '2-digit',
|
|
922
|
+
minute: '2-digit',
|
|
923
|
+
hour12: false,
|
|
924
|
+
};
|
|
925
|
+
const DATE_OPTIONS = {
|
|
926
|
+
day: '2-digit',
|
|
927
|
+
month: '2-digit',
|
|
928
|
+
year: 'numeric',
|
|
929
|
+
};
|
|
930
|
+
const MINUTES_FORMATTER = (t) => {
|
|
931
|
+
const minutes = new Date(t).toLocaleTimeString(undefined, MINUTE_OPTIONS);
|
|
932
|
+
return `:${minutes}`;
|
|
933
|
+
};
|
|
934
|
+
const HOURS_FORMATTER = (t, pixelsPerMinute) => new Date(t).toLocaleTimeString(undefined, pixelsPerMinute > 1 ? HOUR_OPTIONS_LONG : HOUR_OPTIONS_SHORT);
|
|
935
|
+
const DATES_FORMATER = (t) => new Date(t).toLocaleDateString(undefined, DATE_OPTIONS);
|
|
936
|
+
const RANGES_FORMATER = [
|
|
937
|
+
() => '',
|
|
938
|
+
() => '',
|
|
939
|
+
MINUTES_FORMATTER,
|
|
940
|
+
MINUTES_FORMATTER,
|
|
941
|
+
MINUTES_FORMATTER,
|
|
942
|
+
MINUTES_FORMATTER,
|
|
943
|
+
HOURS_FORMATTER,
|
|
944
|
+
HOURS_FORMATTER,
|
|
945
|
+
HOURS_FORMATTER,
|
|
946
|
+
HOURS_FORMATTER,
|
|
947
|
+
HOURS_FORMATTER,
|
|
948
|
+
];
|
|
949
|
+
const TimeCaptions = () => {
|
|
950
|
+
const drawingFunction = useCallback((ctx, { timeScale, timeOrigin, timePixelOffset, getTimePixel, width, height, theme: { background, breakpoints, timeRanges, timeCaptionsPriorities, timeCaptionsStyles, timeGraduationsStyles, dateCaptionsStyle, }, captionSize = 40, swapAxis = false, hideTimeCaptions = false, hideDates = false, showTicks = false, }) => {
|
|
951
|
+
if (hideTimeCaptions)
|
|
952
|
+
return;
|
|
953
|
+
const timeAxisSize = !swapAxis ? width : height;
|
|
954
|
+
const spaceAxisSize = (!swapAxis ? height : width) - captionSize;
|
|
955
|
+
// Add some margin, so that captions of times right outside the stage are still visible:
|
|
956
|
+
const minT = timeOrigin - timeScale * (timePixelOffset + MARGIN);
|
|
957
|
+
const maxT = minT + timeScale * (width + MARGIN * 2);
|
|
958
|
+
// Find which styles to apply, relatively to the timescale (i.e. horizontal zoom level):
|
|
959
|
+
const pixelsPerMinute = (1 / timeScale) * MINUTE;
|
|
960
|
+
let labelLevels = [];
|
|
961
|
+
breakpoints.some((breakpoint, i) => {
|
|
962
|
+
if (pixelsPerMinute < breakpoint) {
|
|
963
|
+
labelLevels = timeCaptionsPriorities[i];
|
|
964
|
+
return true;
|
|
507
965
|
}
|
|
508
966
|
return false;
|
|
509
967
|
});
|
|
@@ -861,23 +1319,135 @@ const ChronogramContext = createContext(
|
|
|
861
1319
|
// That value should never be used, since the context should always be accessed within a provider
|
|
862
1320
|
undefined);
|
|
863
1321
|
|
|
864
|
-
|
|
865
|
-
const
|
|
866
|
-
const
|
|
867
|
-
const
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
1322
|
+
function formatDuration(start, end) {
|
|
1323
|
+
const totalSeconds = Math.floor((end - start) / 1000);
|
|
1324
|
+
const minutes = Math.floor(totalSeconds / 60);
|
|
1325
|
+
const seconds = totalSeconds % 60;
|
|
1326
|
+
return `${minutes}m${String(seconds).padStart(2, '0')}s`;
|
|
1327
|
+
}
|
|
1328
|
+
|
|
1329
|
+
const BLOCK_HEIGHT = 10;
|
|
1330
|
+
const PADDING_TOP = 18;
|
|
1331
|
+
const STRIPE_SPACING = 24;
|
|
1332
|
+
const STRIPE_WIDTH = 8;
|
|
1333
|
+
const TRACKS_INTERVALS = 3;
|
|
1334
|
+
const CLOSING_TIME_Y_OFFSET = 5;
|
|
1335
|
+
const TRAIN_NAME_Y_OFFSET = 14;
|
|
1336
|
+
const drawTrackLines = (ctx, width, bandTop, bandBottom) => {
|
|
1337
|
+
const lineYs = [
|
|
1338
|
+
bandTop,
|
|
1339
|
+
bandTop + BLOCK_HEIGHT / TRACKS_INTERVALS,
|
|
1340
|
+
bandTop + (2 * BLOCK_HEIGHT) / TRACKS_INTERVALS,
|
|
1341
|
+
bandBottom,
|
|
1342
|
+
];
|
|
1343
|
+
ctx.strokeStyle = GREY_30$1;
|
|
1344
|
+
ctx.lineWidth = 1;
|
|
1345
|
+
lineYs.forEach((y) => {
|
|
1346
|
+
ctx.beginPath();
|
|
1347
|
+
ctx.moveTo(0, y);
|
|
1348
|
+
ctx.lineTo(width, y);
|
|
1349
|
+
ctx.stroke();
|
|
1350
|
+
});
|
|
1351
|
+
};
|
|
1352
|
+
const drawStripedBlock = (ctx, x, y, width) => {
|
|
1353
|
+
ctx.save();
|
|
1354
|
+
ctx.beginPath();
|
|
1355
|
+
ctx.rect(x, y, width, BLOCK_HEIGHT);
|
|
1356
|
+
ctx.clip();
|
|
1357
|
+
ctx.fillStyle = WHITE_100$3;
|
|
1358
|
+
ctx.fillRect(x, y, width, BLOCK_HEIGHT);
|
|
1359
|
+
ctx.strokeStyle = RED_100;
|
|
1360
|
+
ctx.lineWidth = STRIPE_WIDTH;
|
|
1361
|
+
for (let offset = STRIPE_WIDTH / 2; offset < width + BLOCK_HEIGHT; offset += STRIPE_SPACING) {
|
|
1362
|
+
ctx.beginPath();
|
|
1363
|
+
ctx.moveTo(x + offset, y + BLOCK_HEIGHT + 2);
|
|
1364
|
+
ctx.lineTo(x + offset + BLOCK_HEIGHT, y - 2);
|
|
1365
|
+
ctx.stroke();
|
|
1366
|
+
}
|
|
1367
|
+
ctx.restore();
|
|
1368
|
+
ctx.strokeStyle = GREY_90;
|
|
1369
|
+
ctx.lineWidth = 1;
|
|
1370
|
+
ctx.strokeRect(x, y, width, BLOCK_HEIGHT);
|
|
1371
|
+
};
|
|
1372
|
+
/** Draws a black block to indicate insufficient time between two occupancy blocks */
|
|
1373
|
+
const drawGapBlock = (ctx, bandTop, gapStartX, gapEndX) => {
|
|
1374
|
+
const gapWidth = gapEndX - gapStartX;
|
|
1375
|
+
if (gapWidth > 0) {
|
|
1376
|
+
ctx.fillStyle = BLACK_100;
|
|
1377
|
+
ctx.fillRect(gapStartX - 0.5, bandTop - 0.5, gapWidth + 1, BLOCK_HEIGHT + 1);
|
|
1378
|
+
}
|
|
1379
|
+
};
|
|
1380
|
+
/** Draws text around an occupancy block */
|
|
1381
|
+
const drawBlockText = ({ ctx, x, y, text, color, maxWidth, }) => {
|
|
1382
|
+
ctx.save();
|
|
1383
|
+
ctx.font = '12px IBM Plex Sans';
|
|
1384
|
+
if (color)
|
|
1385
|
+
ctx.fillStyle = color;
|
|
1386
|
+
ctx.textAlign = 'center';
|
|
1387
|
+
ctx.fillText(text, x, y, maxWidth);
|
|
1388
|
+
ctx.restore();
|
|
1389
|
+
};
|
|
1390
|
+
const drawBlocks = ({ ctx, blocks, getTimePixel, bandTop, bandBottom, }) => {
|
|
1391
|
+
let previousBlockEndX;
|
|
1392
|
+
for (const block of blocks) {
|
|
1393
|
+
const blockStartX = getTimePixel(block.startTime);
|
|
1394
|
+
const blockEndX = getTimePixel(block.endTime);
|
|
1395
|
+
const blockWidth = blockEndX - blockStartX;
|
|
1396
|
+
const blockCenterX = blockStartX + blockWidth / 2;
|
|
1397
|
+
if (blockWidth <= 0)
|
|
1398
|
+
continue;
|
|
1399
|
+
if (previousBlockEndX !== undefined) {
|
|
1400
|
+
drawGapBlock(ctx, bandTop, previousBlockEndX, blockStartX);
|
|
1401
|
+
}
|
|
1402
|
+
drawBlockText({
|
|
1403
|
+
ctx,
|
|
1404
|
+
x: blockCenterX,
|
|
1405
|
+
y: bandTop - CLOSING_TIME_Y_OFFSET,
|
|
1406
|
+
text: formatDuration(block.startTime, block.endTime),
|
|
1407
|
+
maxWidth: blockWidth,
|
|
1408
|
+
});
|
|
1409
|
+
drawStripedBlock(ctx, blockStartX, bandTop, blockWidth);
|
|
1410
|
+
drawBlockText({
|
|
1411
|
+
ctx,
|
|
1412
|
+
x: blockCenterX,
|
|
1413
|
+
y: bandBottom + TRAIN_NAME_Y_OFFSET,
|
|
1414
|
+
text: block.trainNames.join('; '),
|
|
1415
|
+
color: GREY_50$3,
|
|
1416
|
+
});
|
|
1417
|
+
previousBlockEndX = blockEndX;
|
|
1418
|
+
}
|
|
1419
|
+
};
|
|
1420
|
+
const OccupancyBlocksLayer = () => {
|
|
1421
|
+
const { levelCrossingsOccupancies, yPixelOffset } = useContext(ChronogramContext);
|
|
1422
|
+
const drawOccupancyBlocksLayer = useCallback((ctx, { getTimePixel }) => {
|
|
1423
|
+
const { width } = ctx.canvas.getBoundingClientRect();
|
|
1424
|
+
let startY = PADDING_TOP + CHRONOGRAM_HEADER_HEIGHT - yPixelOffset;
|
|
1425
|
+
for (const levelCrossing of levelCrossingsOccupancies) {
|
|
1426
|
+
const bandTop = startY;
|
|
1427
|
+
const bandBottom = startY + BLOCK_HEIGHT;
|
|
1428
|
+
drawTrackLines(ctx, width, bandTop, bandBottom);
|
|
1429
|
+
for (const blocks of levelCrossing) {
|
|
1430
|
+
if (!blocks.length)
|
|
1431
|
+
continue;
|
|
1432
|
+
drawBlocks({ ctx, blocks, getTimePixel, bandTop, bandBottom });
|
|
1433
|
+
}
|
|
1434
|
+
startY += LEVEL_CROSSING_ITEM_HEIGHT;
|
|
1435
|
+
}
|
|
1436
|
+
}, [levelCrossingsOccupancies, yPixelOffset]);
|
|
1437
|
+
useDraw(TimeChartCanvasContext, 'overlay', drawOccupancyBlocksLayer);
|
|
1438
|
+
return null;
|
|
1439
|
+
};
|
|
1440
|
+
|
|
1441
|
+
const ChronogramCanvas = (props) => {
|
|
1442
|
+
const { levelCrossingsOccupancies, timeOrigin, timeScale, xOffset = 0, yOffset = 0, theme, onPan, onZoom, onClick, // TODO: the 3 last handlers are custom and need to be extracted but are not used for now
|
|
1443
|
+
onHoveredChildUpdate, onMouseMove, ...attr } = props;
|
|
1444
|
+
// TODO: remove this console.info once interactions are implemented and handlers are used
|
|
1445
|
+
console.info(onClick, onMouseMove, onHoveredChildUpdate);
|
|
1446
|
+
const [root, setRoot] = useState(null);
|
|
1447
|
+
const [canvasesRoot, setCanvasesRoot] = useState(null);
|
|
1448
|
+
const fullTheme = useMemo(() => ({ ...DEFAULT_THEME, ...theme }), [theme]);
|
|
1449
|
+
const { width, height } = useSize(root);
|
|
1450
|
+
const fingerprint = useMemo(() => JSON.stringify({
|
|
881
1451
|
levelCrossingsOccupancies,
|
|
882
1452
|
width,
|
|
883
1453
|
height,
|
|
@@ -885,7 +1455,7 @@ const Chronogram = (props) => {
|
|
|
885
1455
|
timeScale,
|
|
886
1456
|
xOffset,
|
|
887
1457
|
yOffset,
|
|
888
|
-
]);
|
|
1458
|
+
}), [levelCrossingsOccupancies, width, height, timeOrigin, timeScale, xOffset, yOffset]);
|
|
889
1459
|
const pickingState = useMemo(() => {
|
|
890
1460
|
const pickingElements = [];
|
|
891
1461
|
const resetPickingElements = () => {
|
|
@@ -905,314 +1475,97 @@ const Chronogram = (props) => {
|
|
|
905
1475
|
const getTimePixel = getTimeToPixel(timeOrigin, xOffset, timeScale);
|
|
906
1476
|
const getTime = getPixelToTime(timeOrigin, xOffset, timeScale);
|
|
907
1477
|
// TODO: Check and fix those functions once we introduce mouse interactions
|
|
908
|
-
const getData = (point) => ({ time: point.x, position: point.y });
|
|
909
|
-
const getPoint = ({ time, position }) => ({
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
});
|
|
913
|
-
return {
|
|
914
|
-
...pickingState,
|
|
915
|
-
fingerprint,
|
|
916
|
-
width,
|
|
917
|
-
height,
|
|
918
|
-
getTimePixel,
|
|
919
|
-
getTime,
|
|
920
|
-
getData,
|
|
921
|
-
getPoint,
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
captionSize: fullTheme.dateCaptionsSize + fullTheme.timeCaptionsSize,
|
|
930
|
-
};
|
|
931
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
932
|
-
}, [fingerprint, pickingState]);
|
|
933
|
-
const { canvasContext } = useCanvas$1(canvasesRoot, contextState);
|
|
934
|
-
// Check theme validity:
|
|
935
|
-
useEffect(() => {
|
|
936
|
-
validateTheme(fullTheme);
|
|
937
|
-
}, [fullTheme]);
|
|
938
|
-
return (React.createElement("div", { ...attr, ref: setRoot, className: cx('relative', attr.className), style: { background: fullTheme.background } },
|
|
939
|
-
React.createElement("div", { ref: setCanvasesRoot, className: "absolute inset-0" }),
|
|
940
|
-
React.createElement(ChronogramContext.Provider, { value: contextState },
|
|
941
|
-
React.createElement(TimeChartCanvasContext.Provider, { value: canvasContext },
|
|
942
|
-
React.createElement(TimeGraduations, null),
|
|
943
|
-
React.createElement(TimeCaptions, null)))));
|
|
944
|
-
};
|
|
945
|
-
|
|
946
|
-
/**
|
|
947
|
-
* This function takes a path, a point index and looks forward in the points order for the first
|
|
948
|
-
* position variation. It then returns "forward" or "backward" according to that variation.
|
|
949
|
-
*
|
|
950
|
-
* If it does not find any variation for some reason, it returns "still" instead.
|
|
951
|
-
*
|
|
952
|
-
* Finally, if `reversed` is true, then, it searches points in the other direction.
|
|
953
|
-
*/
|
|
954
|
-
function getPathDirection({ points }, index, reversed) {
|
|
955
|
-
if (points.length < 2 || !points[index])
|
|
956
|
-
return 'still';
|
|
957
|
-
const reference = points[index].position;
|
|
958
|
-
let i = index;
|
|
959
|
-
let point;
|
|
960
|
-
while ((point = points[i])) {
|
|
961
|
-
if (point.position !== reference) {
|
|
962
|
-
const delta = reversed ? reference - point.position : point.position - reference;
|
|
963
|
-
return delta > 0 ? 'forward' : 'backward';
|
|
964
|
-
}
|
|
965
|
-
i = i + (reversed ? -1 : 1);
|
|
966
|
-
}
|
|
967
|
-
return 'still';
|
|
968
|
-
}
|
|
969
|
-
/**
|
|
970
|
-
* This function takes a SpaceToPixel function and a position, and checks if the function returns
|
|
971
|
-
* the same pixel for the position, starting from both sides. It then returns one or two pixel
|
|
972
|
-
* positions accordingly.
|
|
973
|
-
*/
|
|
974
|
-
function getSpacePixels(getSpacePixel, position) {
|
|
975
|
-
const spacePixelFromStart = getSpacePixel(position);
|
|
976
|
-
const spacePixelFromEnd = getSpacePixel(position, true);
|
|
977
|
-
return spacePixelFromStart === spacePixelFromEnd
|
|
978
|
-
? [spacePixelFromStart]
|
|
979
|
-
: [spacePixelFromStart, spacePixelFromEnd];
|
|
980
|
-
}
|
|
981
|
-
|
|
982
|
-
const SpaceGraduations = () => {
|
|
983
|
-
const drawingFunction = useCallback((ctx, { timePixelOffset, getSpacePixel, operationalPoints, flatSteps, swapAxis, width, height, theme: { spaceGraduationsStyles }, }) => {
|
|
984
|
-
const axisSize = !swapAxis ? width : height;
|
|
985
|
-
// Draw operational point lines:
|
|
986
|
-
operationalPoints.forEach((point) => {
|
|
987
|
-
if (flatSteps.has(point.position))
|
|
988
|
-
return;
|
|
989
|
-
const styles = spaceGraduationsStyles[point.importanceLevel || 0];
|
|
990
|
-
if (!styles)
|
|
991
|
-
return;
|
|
992
|
-
ctx.strokeStyle = styles.color;
|
|
993
|
-
ctx.lineWidth = styles.width;
|
|
994
|
-
ctx.globalAlpha = styles.opacity || 1;
|
|
995
|
-
if (styles.dashArray) {
|
|
996
|
-
ctx.setLineDash(styles.dashArray || []);
|
|
997
|
-
ctx.lineDashOffset = -timePixelOffset;
|
|
998
|
-
}
|
|
999
|
-
// Detect flat steps, and draw two graduations if any (one on each side of the step):
|
|
1000
|
-
getSpacePixels(getSpacePixel, point.position).forEach((rawPixel) => {
|
|
1001
|
-
const spacePixel = getCrispLineCoordinate(rawPixel, ctx.lineWidth);
|
|
1002
|
-
ctx.beginPath();
|
|
1003
|
-
if (!swapAxis) {
|
|
1004
|
-
ctx.moveTo(0, spacePixel);
|
|
1005
|
-
ctx.lineTo(axisSize, spacePixel);
|
|
1006
|
-
}
|
|
1007
|
-
else {
|
|
1008
|
-
ctx.moveTo(spacePixel, 0);
|
|
1009
|
-
ctx.lineTo(spacePixel, axisSize);
|
|
1010
|
-
}
|
|
1011
|
-
ctx.stroke();
|
|
1012
|
-
});
|
|
1013
|
-
});
|
|
1014
|
-
ctx.setLineDash([]);
|
|
1015
|
-
ctx.lineDashOffset = 0;
|
|
1016
|
-
ctx.globalAlpha = 1;
|
|
1017
|
-
}, []);
|
|
1018
|
-
useDraw(SpaceTimeChartCanvasContext, 'graduations', drawingFunction);
|
|
1019
|
-
return null;
|
|
1020
|
-
};
|
|
1021
|
-
|
|
1022
|
-
/**
|
|
1023
|
-
* This function takes a MouseEvent and an HTMLElement, and returns the position of the mouse,
|
|
1024
|
-
* relatively to the DOM element. This allows for instance dragging an element that is on the given
|
|
1025
|
-
* DOM element while the events are bound to the document or the body.
|
|
1026
|
-
*/
|
|
1027
|
-
function getEventPosition(e, dom) {
|
|
1028
|
-
const bbox = dom.getBoundingClientRect();
|
|
1029
|
-
return {
|
|
1030
|
-
x: e.clientX - bbox.left,
|
|
1031
|
-
y: e.clientY - bbox.top,
|
|
1032
|
-
};
|
|
1033
|
-
}
|
|
1034
|
-
/**
|
|
1035
|
-
* This function returns a delta value for a given WheelEvent. It can be very useful, since the
|
|
1036
|
-
* given `deltaY` and `detail` attributes are not normalized.
|
|
1037
|
-
*/
|
|
1038
|
-
function getEventWheelDelta(e) {
|
|
1039
|
-
if (typeof e.deltaY !== 'undefined')
|
|
1040
|
-
return (e.deltaY * -3) / 360;
|
|
1041
|
-
if (typeof e.detail !== 'undefined')
|
|
1042
|
-
return e.detail / -9;
|
|
1043
|
-
throw new Error('Could not extract delta from event.');
|
|
1044
|
-
}
|
|
1045
|
-
|
|
1046
|
-
/**
|
|
1047
|
-
* This hook handles SpaceTimeChart mouse interactions.
|
|
1048
|
-
* It is an internal hook, and should only be used inside SpaceTimeChart.
|
|
1049
|
-
*/
|
|
1050
|
-
function useMouseInteractions(dom, { position, hoveredItem, down, isHover }, handlers, context) {
|
|
1051
|
-
const contextRef = useRef(context);
|
|
1052
|
-
const handlersRef = useRef(handlers);
|
|
1053
|
-
const [panningState, setPanningState] = useState({ type: 'idle' });
|
|
1054
|
-
// Cache latest context in ref:
|
|
1055
|
-
useEffect(() => {
|
|
1056
|
-
contextRef.current = context;
|
|
1057
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1058
|
-
}, [context.fingerprint]);
|
|
1059
|
-
useEffect(() => {
|
|
1060
|
-
handlersRef.current = handlers;
|
|
1061
|
-
}, [handlers]);
|
|
1062
|
-
// Generate event handlers:
|
|
1063
|
-
const clickHandler = useCallback((event) => {
|
|
1064
|
-
if (!dom)
|
|
1065
|
-
return;
|
|
1066
|
-
const { onClick } = handlersRef.current;
|
|
1067
|
-
if (onClick) {
|
|
1068
|
-
onClick({
|
|
1069
|
-
event,
|
|
1070
|
-
position,
|
|
1071
|
-
data: contextRef.current.getData(position),
|
|
1072
|
-
hoveredItem,
|
|
1073
|
-
context: contextRef.current,
|
|
1074
|
-
});
|
|
1075
|
-
}
|
|
1076
|
-
}, [dom, hoveredItem, position]);
|
|
1077
|
-
const wheelHandler = useCallback((event) => {
|
|
1078
|
-
const { onZoom } = handlersRef.current;
|
|
1079
|
-
if (onZoom && dom)
|
|
1080
|
-
onZoom({
|
|
1081
|
-
delta: getEventWheelDelta(event),
|
|
1082
|
-
position: getEventPosition(event, dom),
|
|
1083
|
-
event,
|
|
1084
|
-
context: contextRef.current,
|
|
1085
|
-
});
|
|
1086
|
-
}, [dom]);
|
|
1087
|
-
// Bind event handlers:
|
|
1088
|
-
useEffect(() => {
|
|
1089
|
-
if (!dom)
|
|
1090
|
-
return;
|
|
1091
|
-
dom.addEventListener('click', clickHandler);
|
|
1092
|
-
return () => {
|
|
1093
|
-
dom.removeEventListener('click', clickHandler);
|
|
1094
|
-
};
|
|
1095
|
-
}, [dom, clickHandler]);
|
|
1096
|
-
useEffect(() => {
|
|
1097
|
-
if (!dom)
|
|
1098
|
-
return;
|
|
1099
|
-
dom.addEventListener('wheel', wheelHandler);
|
|
1100
|
-
return () => {
|
|
1101
|
-
dom.removeEventListener('wheel', wheelHandler);
|
|
1102
|
-
};
|
|
1103
|
-
}, [dom, wheelHandler]);
|
|
1104
|
-
// Listen to "up" and "down" updates:
|
|
1105
|
-
useEffect(() => {
|
|
1106
|
-
const { onPan } = handlersRef.current;
|
|
1107
|
-
if (down) {
|
|
1108
|
-
// Start panning:
|
|
1109
|
-
setPanningState({
|
|
1110
|
-
type: 'panning',
|
|
1111
|
-
initialPosition: position,
|
|
1112
|
-
initialData: contextRef.current.getData(position),
|
|
1113
|
-
});
|
|
1114
|
-
}
|
|
1115
|
-
else {
|
|
1116
|
-
// Stop panning:
|
|
1117
|
-
if (panningState.type === 'panning' && onPan)
|
|
1118
|
-
onPan({
|
|
1119
|
-
isPanning: false,
|
|
1120
|
-
position,
|
|
1121
|
-
initialPosition: panningState.initialPosition,
|
|
1122
|
-
data: contextRef.current.getData(position),
|
|
1123
|
-
initialData: panningState.initialData,
|
|
1124
|
-
context: contextRef.current,
|
|
1125
|
-
});
|
|
1126
|
-
if (panningState.type !== 'idle')
|
|
1127
|
-
setPanningState({ type: 'idle' });
|
|
1128
|
-
}
|
|
1129
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1130
|
-
}, [down]);
|
|
1131
|
-
// Listen to "move" updates:
|
|
1132
|
-
useEffect(() => {
|
|
1133
|
-
const { onPan, onMouseMove } = handlersRef.current;
|
|
1134
|
-
if (onMouseMove) {
|
|
1135
|
-
onMouseMove({
|
|
1136
|
-
position,
|
|
1137
|
-
isHover,
|
|
1138
|
-
data: contextRef.current.getData(position),
|
|
1139
|
-
hoveredItem,
|
|
1140
|
-
context: contextRef.current,
|
|
1141
|
-
});
|
|
1142
|
-
}
|
|
1143
|
-
if (panningState.type === 'panning' && onPan)
|
|
1144
|
-
onPan({
|
|
1145
|
-
isPanning: true,
|
|
1146
|
-
position,
|
|
1147
|
-
initialPosition: panningState.initialPosition,
|
|
1148
|
-
data: contextRef.current.getData(position),
|
|
1149
|
-
initialData: panningState.initialData,
|
|
1150
|
-
context: contextRef.current,
|
|
1151
|
-
});
|
|
1152
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1153
|
-
}, [position.x, position.y]);
|
|
1154
|
-
}
|
|
1155
|
-
|
|
1156
|
-
/**
|
|
1157
|
-
* This hook handles SpaceTimeChart mouse tracking.
|
|
1158
|
-
* It is an internal hook, and should only be used inside SpaceTimeChart.
|
|
1159
|
-
*/
|
|
1160
|
-
function useMouseTracking(dom) {
|
|
1161
|
-
const [mouseState, setMouseState] = useState({
|
|
1162
|
-
isHover: false,
|
|
1163
|
-
position: { x: NaN, y: NaN },
|
|
1164
|
-
});
|
|
1165
|
-
// Generate event handlers:
|
|
1166
|
-
const downHandler = useCallback((e) => {
|
|
1167
|
-
if (!dom)
|
|
1168
|
-
return;
|
|
1169
|
-
setMouseState((state) => ({
|
|
1170
|
-
...state,
|
|
1171
|
-
down: { ctrl: e.ctrlKey, shift: e.shiftKey },
|
|
1172
|
-
}));
|
|
1173
|
-
}, [dom]);
|
|
1174
|
-
const upHandler = useCallback(() => {
|
|
1175
|
-
if (!dom)
|
|
1176
|
-
return;
|
|
1177
|
-
setMouseState((state) => ({ ...state, down: undefined }));
|
|
1178
|
-
}, [dom]);
|
|
1179
|
-
const moveHandler = useCallback((event) => {
|
|
1180
|
-
if (!dom)
|
|
1181
|
-
return;
|
|
1182
|
-
const position = getEventPosition(event, dom);
|
|
1183
|
-
const { x, y } = position;
|
|
1184
|
-
const width = dom.offsetWidth;
|
|
1185
|
-
const height = dom.offsetHeight;
|
|
1186
|
-
const isHover = x >= 0 && x <= width && y >= 0 && y <= height;
|
|
1187
|
-
setMouseState((state) => ({
|
|
1188
|
-
...state,
|
|
1189
|
-
position,
|
|
1190
|
-
isHover,
|
|
1191
|
-
}));
|
|
1192
|
-
}, [dom]);
|
|
1193
|
-
// Bind event handlers:
|
|
1194
|
-
useEffect(() => {
|
|
1195
|
-
if (!dom)
|
|
1196
|
-
return;
|
|
1197
|
-
dom.addEventListener('mousedown', downHandler);
|
|
1198
|
-
return () => {
|
|
1199
|
-
dom.removeEventListener('mousedown', downHandler);
|
|
1478
|
+
const getData = (point) => ({ time: point.x, position: point.y });
|
|
1479
|
+
const getPoint = ({ time, position }) => ({
|
|
1480
|
+
x: getTimePixel(time),
|
|
1481
|
+
y: position,
|
|
1482
|
+
});
|
|
1483
|
+
return {
|
|
1484
|
+
...pickingState,
|
|
1485
|
+
fingerprint,
|
|
1486
|
+
width,
|
|
1487
|
+
height,
|
|
1488
|
+
getTimePixel,
|
|
1489
|
+
getTime,
|
|
1490
|
+
getData,
|
|
1491
|
+
getPoint,
|
|
1492
|
+
levelCrossingsOccupancies,
|
|
1493
|
+
timeOrigin,
|
|
1494
|
+
timeScale,
|
|
1495
|
+
timePixelOffset: xOffset,
|
|
1496
|
+
yPixelOffset: yOffset,
|
|
1497
|
+
theme: fullTheme,
|
|
1498
|
+
captionSize: fullTheme.dateCaptionsSize + fullTheme.timeCaptionsSize,
|
|
1200
1499
|
};
|
|
1201
|
-
|
|
1500
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1501
|
+
}, [fingerprint, pickingState, fullTheme]);
|
|
1502
|
+
const mouseState = useMouseTracking(root);
|
|
1503
|
+
const { position, down, isHover } = mouseState;
|
|
1504
|
+
const { canvasContext } = useCanvas$1(canvasesRoot, contextState, position);
|
|
1505
|
+
const mouseContext = useMemo(() => ({
|
|
1506
|
+
down,
|
|
1507
|
+
isHover,
|
|
1508
|
+
position: mouseState.position,
|
|
1509
|
+
hoveredItem: null,
|
|
1510
|
+
data: contextState.getData(mouseState.position),
|
|
1511
|
+
}), [mouseState.position, down, isHover, contextState]);
|
|
1512
|
+
// Handle interactions:
|
|
1513
|
+
useMouseInteractions(root, mouseContext, { onPan, onZoom }, contextState);
|
|
1514
|
+
// Check theme validity:
|
|
1202
1515
|
useEffect(() => {
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
}
|
|
1207
|
-
|
|
1516
|
+
validateTheme(fullTheme);
|
|
1517
|
+
}, [fullTheme]);
|
|
1518
|
+
return (React.createElement("div", { ...attr, ref: setRoot, className: cx('relative h-full', attr.className), style: { background: fullTheme.background } },
|
|
1519
|
+
React.createElement("div", { ref: setCanvasesRoot, className: "absolute inset-0" },
|
|
1520
|
+
React.createElement(ChronogramContext.Provider, { value: contextState },
|
|
1521
|
+
React.createElement(TimeChartCanvasContext.Provider, { value: canvasContext },
|
|
1522
|
+
React.createElement(MouseContext.Provider, { value: mouseContext },
|
|
1523
|
+
React.createElement(TimeGraduations, null),
|
|
1524
|
+
React.createElement(TimeCaptions, null),
|
|
1525
|
+
React.createElement(OccupancyBlocksLayer, null)))))));
|
|
1526
|
+
};
|
|
1527
|
+
|
|
1528
|
+
const ChronogramManchette = ({ levelCrossingsNames, height, width = 262, onDelete, }) => (React.createElement("div", { className: "chronogram-manchette", style: {
|
|
1529
|
+
height: `${height}px`,
|
|
1530
|
+
width: `${width}px`,
|
|
1531
|
+
} },
|
|
1532
|
+
React.createElement("div", { className: "chronogram-manchette-header" },
|
|
1533
|
+
React.createElement(Note, { iconColor: GREY_30$1 })),
|
|
1534
|
+
React.createElement("div", { className: "chronogram-manchette-list" }, levelCrossingsNames.map((lcName, index) => (React.createElement("div", { key: index, className: "level-crossing flex justify-between" },
|
|
1535
|
+
React.createElement("div", { className: "flex items-center" }, lcName),
|
|
1536
|
+
React.createElement("button", { className: "cursor-pointer", onClick: () => onDelete(lcName) },
|
|
1537
|
+
React.createElement(XCircle, { className: "x-circle" })))))),
|
|
1538
|
+
React.createElement("div", { className: "chronogram-manchette-footer" })));
|
|
1539
|
+
|
|
1540
|
+
const Chronogram = ({ levelCrossingData, timeOrigin, height = INITIAL_CHRONOGRAM_HEIGHT, }) => {
|
|
1541
|
+
const chronogramManchetteRef = useRef(null);
|
|
1542
|
+
const chronogramChartRef = useRef(null);
|
|
1543
|
+
const [levelCrossingsOccupancies, setLevelCrossingsOccupancies] = useState(levelCrossingData);
|
|
1544
|
+
const { height: chronogramHeight, handleVerticalScroll, handleXZoom, handleXZoomOnWheelEvent, onPan, xOffset, xZoom, yOffset, } = useChronogram({
|
|
1545
|
+
itemCount: levelCrossingsOccupancies.length,
|
|
1546
|
+
chronogramManchetteRef,
|
|
1547
|
+
chronogramChartRef,
|
|
1548
|
+
chronogramHeight: height,
|
|
1549
|
+
});
|
|
1550
|
+
function handleDeleteLevelCrossing(name) {
|
|
1551
|
+
setLevelCrossingsOccupancies((previousLevelCrossingsOccupancies) => previousLevelCrossingsOccupancies.filter((lc) => lc.name !== name));
|
|
1552
|
+
}
|
|
1208
1553
|
useEffect(() => {
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
},
|
|
1214
|
-
|
|
1215
|
-
}
|
|
1554
|
+
// TODO: fix this lint
|
|
1555
|
+
/* eslint-disable-next-line react-hooks/set-state-in-effect */
|
|
1556
|
+
setLevelCrossingsOccupancies(levelCrossingData);
|
|
1557
|
+
}, [levelCrossingData]);
|
|
1558
|
+
return (React.createElement("div", { className: "ui-chronogram", style: { height } },
|
|
1559
|
+
React.createElement("div", { ref: chronogramManchetteRef, className: "chronogram-manchette-container flex", onScroll: handleVerticalScroll },
|
|
1560
|
+
React.createElement(ChronogramManchette, { onDelete: handleDeleteLevelCrossing, levelCrossingsNames: levelCrossingsOccupancies.map((lc) => lc.name), height: chronogramHeight }),
|
|
1561
|
+
React.createElement("div", { ref: chronogramChartRef, className: "chronogram-container" },
|
|
1562
|
+
React.createElement(ChronogramCanvas, { timeOrigin: timeOrigin, timeScale: zoomValueToTimeScale(xZoom), xOffset: xOffset, yOffset: yOffset, levelCrossingsOccupancies: levelCrossingsOccupancies.map((lc) => lc.occupancies), onPan: onPan, onZoom: ({ delta, position, event }) => {
|
|
1563
|
+
handleXZoomOnWheelEvent(event, xZoom + delta, position.x);
|
|
1564
|
+
} }))),
|
|
1565
|
+
React.createElement(Slider, { containerClassName: "chronogram-slider-container", className: "chronogram-slider", width: CHRONOGRAM_SLIDER_WIDTH, value: xZoom, onChange: (e) => {
|
|
1566
|
+
handleXZoom(Number(e.target.value));
|
|
1567
|
+
} })));
|
|
1568
|
+
};
|
|
1216
1569
|
|
|
1217
1570
|
/* eslint-disable @typescript-eslint/no-use-before-define */
|
|
1218
1571
|
/**
|
|
@@ -1727,6 +2080,42 @@ function fillRect(ctx, { timeStart, timeEnd, spaceStart, spaceEnd }, { getPoint
|
|
|
1727
2080
|
return { width, height };
|
|
1728
2081
|
}
|
|
1729
2082
|
|
|
2083
|
+
/**
|
|
2084
|
+
* This function takes a path, a point index and looks forward in the points order for the first
|
|
2085
|
+
* position variation. It then returns "forward" or "backward" according to that variation.
|
|
2086
|
+
*
|
|
2087
|
+
* If it does not find any variation for some reason, it returns "still" instead.
|
|
2088
|
+
*
|
|
2089
|
+
* Finally, if `reversed` is true, then, it searches points in the other direction.
|
|
2090
|
+
*/
|
|
2091
|
+
function getPathDirection({ points }, index, reversed) {
|
|
2092
|
+
if (points.length < 2 || !points[index])
|
|
2093
|
+
return 'still';
|
|
2094
|
+
const reference = points[index].position;
|
|
2095
|
+
let i = index;
|
|
2096
|
+
let point;
|
|
2097
|
+
while ((point = points[i])) {
|
|
2098
|
+
if (point.position !== reference) {
|
|
2099
|
+
const delta = reversed ? reference - point.position : point.position - reference;
|
|
2100
|
+
return delta > 0 ? 'forward' : 'backward';
|
|
2101
|
+
}
|
|
2102
|
+
i = i + (reversed ? -1 : 1);
|
|
2103
|
+
}
|
|
2104
|
+
return 'still';
|
|
2105
|
+
}
|
|
2106
|
+
/**
|
|
2107
|
+
* This function takes a SpaceToPixel function and a position, and checks if the function returns
|
|
2108
|
+
* the same pixel for the position, starting from both sides. It then returns one or two pixel
|
|
2109
|
+
* positions accordingly.
|
|
2110
|
+
*/
|
|
2111
|
+
function getSpacePixels(getSpacePixel, position) {
|
|
2112
|
+
const spacePixelFromStart = getSpacePixel(position);
|
|
2113
|
+
const spacePixelFromEnd = getSpacePixel(position, true);
|
|
2114
|
+
return spacePixelFromStart === spacePixelFromEnd
|
|
2115
|
+
? [spacePixelFromStart]
|
|
2116
|
+
: [spacePixelFromStart, spacePixelFromEnd];
|
|
2117
|
+
}
|
|
2118
|
+
|
|
1730
2119
|
const DEFAULT_PICKING_TOLERANCE = 5;
|
|
1731
2120
|
const PAUSE_THICKNESS = 7;
|
|
1732
2121
|
const PAUSE_OPACITY = 0.2;
|
|
@@ -2226,6 +2615,46 @@ function snapPosition(mousePosition, hoveredItem) {
|
|
|
2226
2615
|
}
|
|
2227
2616
|
}
|
|
2228
2617
|
|
|
2618
|
+
const SpaceGraduations = () => {
|
|
2619
|
+
const drawingFunction = useCallback((ctx, { timePixelOffset, getSpacePixel, operationalPoints, flatSteps, swapAxis, width, height, theme: { spaceGraduationsStyles }, }) => {
|
|
2620
|
+
const axisSize = !swapAxis ? width : height;
|
|
2621
|
+
// Draw operational point lines:
|
|
2622
|
+
operationalPoints.forEach((point) => {
|
|
2623
|
+
if (flatSteps.has(point.position))
|
|
2624
|
+
return;
|
|
2625
|
+
const styles = spaceGraduationsStyles[point.importanceLevel || 0];
|
|
2626
|
+
if (!styles)
|
|
2627
|
+
return;
|
|
2628
|
+
ctx.strokeStyle = styles.color;
|
|
2629
|
+
ctx.lineWidth = styles.width;
|
|
2630
|
+
ctx.globalAlpha = styles.opacity || 1;
|
|
2631
|
+
if (styles.dashArray) {
|
|
2632
|
+
ctx.setLineDash(styles.dashArray || []);
|
|
2633
|
+
ctx.lineDashOffset = -timePixelOffset;
|
|
2634
|
+
}
|
|
2635
|
+
// Detect flat steps, and draw two graduations if any (one on each side of the step):
|
|
2636
|
+
getSpacePixels(getSpacePixel, point.position).forEach((rawPixel) => {
|
|
2637
|
+
const spacePixel = getCrispLineCoordinate(rawPixel, ctx.lineWidth);
|
|
2638
|
+
ctx.beginPath();
|
|
2639
|
+
if (!swapAxis) {
|
|
2640
|
+
ctx.moveTo(0, spacePixel);
|
|
2641
|
+
ctx.lineTo(axisSize, spacePixel);
|
|
2642
|
+
}
|
|
2643
|
+
else {
|
|
2644
|
+
ctx.moveTo(spacePixel, 0);
|
|
2645
|
+
ctx.lineTo(spacePixel, axisSize);
|
|
2646
|
+
}
|
|
2647
|
+
ctx.stroke();
|
|
2648
|
+
});
|
|
2649
|
+
});
|
|
2650
|
+
ctx.setLineDash([]);
|
|
2651
|
+
ctx.lineDashOffset = 0;
|
|
2652
|
+
ctx.globalAlpha = 1;
|
|
2653
|
+
}, []);
|
|
2654
|
+
useDraw(SpaceTimeChartCanvasContext, 'graduations', drawingFunction);
|
|
2655
|
+
return null;
|
|
2656
|
+
};
|
|
2657
|
+
|
|
2229
2658
|
const SpaceTimeChart = (props) => {
|
|
2230
2659
|
const { operationalPoints, spaceOrigin, spaceScales, timeOrigin, timeScale, xOffset = 0, yOffset = 0, swapAxis, onHoveredChildUpdate, children, additionalChildren, enableSnapping, hideTimeCaptions, hideGrid, hidePathsLabels, showTicks, hideDates, theme, onPan, onZoom, onClick, onMouseMove, ...attr } = props;
|
|
2231
2660
|
const [root, setRoot] = useState(null);
|
|
@@ -2651,38 +3080,6 @@ function isPathOnScreen(width, height, points) {
|
|
|
2651
3080
|
return segments.some(([from, to]) => isSegmentOnScreen(width, height, from, to));
|
|
2652
3081
|
}
|
|
2653
3082
|
|
|
2654
|
-
const INITIAL_OP_LIST_HEIGHT = 521;
|
|
2655
|
-
const BASE_WAYPOINT_HEIGHT = 32;
|
|
2656
|
-
const INITIAL_SPACE_TIME_CHART_HEIGHT = INITIAL_OP_LIST_HEIGHT + 40;
|
|
2657
|
-
const MIN_ZOOM_MS_PER_PX = 600_000;
|
|
2658
|
-
const MAX_ZOOM_MS_PER_PX = 625;
|
|
2659
|
-
const DEFAULT_ZOOM_MS_PER_PX = 7_500;
|
|
2660
|
-
const MIN_ZOOM_X = 0;
|
|
2661
|
-
const MAX_ZOOM_X = 100;
|
|
2662
|
-
const MIN_ZOOM_Y = 1;
|
|
2663
|
-
const MAX_ZOOM_Y = 10.5;
|
|
2664
|
-
const ZOOM_Y_DELTA = 0.5;
|
|
2665
|
-
const MAX_ZOOM_MANCHETTE_HEIGHT_MILLIMETER = 500_000;
|
|
2666
|
-
const FOOTER_HEIGHT = 40; // height of the manchette footer
|
|
2667
|
-
const WAYPOINT_LINE_HEIGHT = 16;
|
|
2668
|
-
const PATH_COLOR_DEFAULT = '#8A714B';
|
|
2669
|
-
|
|
2670
|
-
const getHeightWithoutLastWaypoint = (height) => height - FOOTER_HEIGHT - BASE_WAYPOINT_HEIGHT;
|
|
2671
|
-
const positionMmToKm = (position) => Math.round((position / 1000000) * 10) / 10;
|
|
2672
|
-
const positionKmToMm = (position) => position * 1000000;
|
|
2673
|
-
const calcTotalDistance = (ops) => {
|
|
2674
|
-
if (ops.length === 0) {
|
|
2675
|
-
return 0;
|
|
2676
|
-
}
|
|
2677
|
-
return ops.at(-1).position - ops.at(0).position;
|
|
2678
|
-
};
|
|
2679
|
-
function getDistance(a, b) {
|
|
2680
|
-
return {
|
|
2681
|
-
x: b.x - a.x,
|
|
2682
|
-
y: b.y - a.y,
|
|
2683
|
-
};
|
|
2684
|
-
}
|
|
2685
|
-
|
|
2686
3083
|
const Waypoint = ({ waypoint: { name, secondaryCode, id, position, onClick, styles }, waypointRef, isActive, isMenuActive, testIdPrefix, hidePositions = false, }) => (React.createElement("div", { "data-testid": testIdPrefix ? `${testIdPrefix}-base-info` : undefined, className: cx('flex waypoint items-baseline', {
|
|
2687
3084
|
'waypoint-active': isActive,
|
|
2688
3085
|
'menu-active': isMenuActive,
|
|
@@ -2690,111 +3087,13 @@ const Waypoint = ({ waypoint: { name, secondaryCode, id, position, onClick, styl
|
|
|
2690
3087
|
if (onClick && !isMenuActive)
|
|
2691
3088
|
onClick(id);
|
|
2692
3089
|
} },
|
|
2693
|
-
!hidePositions && (React.createElement("div", { "data-testid":
|
|
2694
|
-
React.createElement("div", { "data-testid":
|
|
3090
|
+
!hidePositions && (React.createElement("div", { "data-testid": "waypoint-position", className: "waypoint-position justify-self-start text-end" }, positionMmToKm(position))),
|
|
3091
|
+
React.createElement("div", { "data-testid": "waypoint-name", className: "waypoint-name mx-2 justify-self-start" }, name),
|
|
2695
3092
|
React.createElement("div", { className: "waypoint-separator" }),
|
|
2696
3093
|
secondaryCode && (React.createElement(React.Fragment, null,
|
|
2697
|
-
React.createElement("div", { "data-testid":
|
|
3094
|
+
React.createElement("div", { "data-testid": "waypoint-ch", className: "waypoint-ch font-mono justify-self-end" }, secondaryCode),
|
|
2698
3095
|
React.createElement("div", { className: "waypoint-separator" })))));
|
|
2699
3096
|
|
|
2700
|
-
const zoomValueToTimeScale = (slider) => MIN_ZOOM_MS_PER_PX * Math.pow(MAX_ZOOM_MS_PER_PX / MIN_ZOOM_MS_PER_PX, slider / 100);
|
|
2701
|
-
const timeScaleToZoomValue = (timeScale) => (100 * Math.log(timeScale / MIN_ZOOM_MS_PER_PX)) /
|
|
2702
|
-
Math.log(MAX_ZOOM_MS_PER_PX / MIN_ZOOM_MS_PER_PX);
|
|
2703
|
-
/**
|
|
2704
|
-
* min zoom is computed with manchette px height between first and last waypoint.
|
|
2705
|
-
* max zoom just the canvas drawing height (without the x-axis scale section)
|
|
2706
|
-
*/
|
|
2707
|
-
const getExtremaScales = (drawingHeightWithoutTopPadding, drawingHeightWithoutBothPadding, pathLengthMillimeter) => ({
|
|
2708
|
-
minZoomMillimeterPerPx: pathLengthMillimeter / drawingHeightWithoutBothPadding,
|
|
2709
|
-
maxZoomMillimeterPerPx: MAX_ZOOM_MANCHETTE_HEIGHT_MILLIMETER / drawingHeightWithoutTopPadding,
|
|
2710
|
-
});
|
|
2711
|
-
const zoomValueToSpaceScale = (minZoomMillimeterPerPx, maxZoomMillimeterPerPx, slider) => minZoomMillimeterPerPx *
|
|
2712
|
-
Math.pow(maxZoomMillimeterPerPx / minZoomMillimeterPerPx, (slider - MIN_ZOOM_Y) / (MAX_ZOOM_Y - MIN_ZOOM_Y));
|
|
2713
|
-
const spaceScaleToZoomValue = (minZoomMillimeterPerPx, maxZoomMillimeterPerPx, spaceScale) => ((MAX_ZOOM_Y - MIN_ZOOM_Y) * Math.log(spaceScale / minZoomMillimeterPerPx)) /
|
|
2714
|
-
Math.log(maxZoomMillimeterPerPx / minZoomMillimeterPerPx) +
|
|
2715
|
-
MIN_ZOOM_Y;
|
|
2716
|
-
/** Zoom on X axis and center on the mouse position */
|
|
2717
|
-
const zoomX = (currentZoom, currentOffset, newZoom, position) => {
|
|
2718
|
-
const boundedZoom = clamp$1(newZoom, MIN_ZOOM_X, MAX_ZOOM_X);
|
|
2719
|
-
const oldTimeScale = zoomValueToTimeScale(currentZoom);
|
|
2720
|
-
const newTimeScale = zoomValueToTimeScale(boundedZoom);
|
|
2721
|
-
const newOffset = position - ((position - currentOffset) * oldTimeScale) / newTimeScale;
|
|
2722
|
-
return {
|
|
2723
|
-
xZoom: boundedZoom,
|
|
2724
|
-
xOffset: newOffset,
|
|
2725
|
-
};
|
|
2726
|
-
};
|
|
2727
|
-
const filterVisibleElements$1 = (elements, totalDistance, heightWithoutFinalWaypoint, minSpace) => {
|
|
2728
|
-
const getPosition = (waypoint) => (waypoint.position / totalDistance) * heightWithoutFinalWaypoint;
|
|
2729
|
-
const firstElement = elements.at(0);
|
|
2730
|
-
const lastElement = elements.at(-1);
|
|
2731
|
-
if (!firstElement || !lastElement)
|
|
2732
|
-
return elements;
|
|
2733
|
-
const sortedElements = [...elements].sort((a, b) => (b.weight ?? 0) - (a.weight ?? 0));
|
|
2734
|
-
const displayedElements = [firstElement, lastElement];
|
|
2735
|
-
for (const element of sortedElements) {
|
|
2736
|
-
const hasSpace = !displayedElements.some((displayed) => Math.abs(getPosition(element) - getPosition(displayed)) < minSpace);
|
|
2737
|
-
if (hasSpace) {
|
|
2738
|
-
displayedElements.push(element);
|
|
2739
|
-
}
|
|
2740
|
-
}
|
|
2741
|
-
return displayedElements.sort((a, b) => a.position - b.position);
|
|
2742
|
-
};
|
|
2743
|
-
const selectWaypointsToDisplay = (waypoints, { height, isProportional, yZoom }) => {
|
|
2744
|
-
if (waypoints.length < 2)
|
|
2745
|
-
return [];
|
|
2746
|
-
// display all waypoints in linear mode
|
|
2747
|
-
if (!isProportional)
|
|
2748
|
-
return waypoints;
|
|
2749
|
-
const totalDistance = calcTotalDistance(waypoints);
|
|
2750
|
-
const manchetteHeight = getHeightWithoutLastWaypoint(height);
|
|
2751
|
-
// in proportional mode, hide some waypoints to avoid collisions
|
|
2752
|
-
const minSpace = BASE_WAYPOINT_HEIGHT / yZoom;
|
|
2753
|
-
return filterVisibleElements$1(waypoints, totalDistance, manchetteHeight, minSpace);
|
|
2754
|
-
};
|
|
2755
|
-
/**
|
|
2756
|
-
* 2 modes for space scales
|
|
2757
|
-
* km (isProportional): { coefficient: gives a scale in meter/pixel }
|
|
2758
|
-
* linear: { size: height in pixel } (each point distributed evenly along the height of manchette.)
|
|
2759
|
-
*/
|
|
2760
|
-
const getScales = (waypoints, { isProportional, yZoom, height }, minZoomMillimeterPerPx, maxZoomMillimeterPerPx) => {
|
|
2761
|
-
if (!waypoints.length)
|
|
2762
|
-
return [];
|
|
2763
|
-
if (waypoints.length === 1) {
|
|
2764
|
-
const waypoint = waypoints[0];
|
|
2765
|
-
return [
|
|
2766
|
-
{
|
|
2767
|
-
from: waypoint.position,
|
|
2768
|
-
to: waypoint.position,
|
|
2769
|
-
size: height || 1,
|
|
2770
|
-
},
|
|
2771
|
-
];
|
|
2772
|
-
}
|
|
2773
|
-
if (!isProportional) {
|
|
2774
|
-
return waypoints.slice(0, -1).map((from, index) => {
|
|
2775
|
-
const to = waypoints[index + 1];
|
|
2776
|
-
return {
|
|
2777
|
-
from: from.position,
|
|
2778
|
-
to: to.position,
|
|
2779
|
-
size: BASE_WAYPOINT_HEIGHT * yZoom,
|
|
2780
|
-
};
|
|
2781
|
-
});
|
|
2782
|
-
}
|
|
2783
|
-
const from = waypoints.at(0).position;
|
|
2784
|
-
const to = waypoints.at(-1).position;
|
|
2785
|
-
const scaleCoeff = isProportional
|
|
2786
|
-
? { coefficient: zoomValueToSpaceScale(minZoomMillimeterPerPx, maxZoomMillimeterPerPx, yZoom) }
|
|
2787
|
-
: { size: BASE_WAYPOINT_HEIGHT * (waypoints.length - 1) * yZoom };
|
|
2788
|
-
return [
|
|
2789
|
-
{
|
|
2790
|
-
from,
|
|
2791
|
-
to,
|
|
2792
|
-
...scaleCoeff,
|
|
2793
|
-
},
|
|
2794
|
-
];
|
|
2795
|
-
};
|
|
2796
|
-
const isInteractiveWaypoint = (item) => item != null && typeof item === 'object' && 'id' in item && 'position' in item;
|
|
2797
|
-
|
|
2798
3097
|
const Manchette = ({ zoomYIn, zoomYOut, resetZoom, yZoom = 1, contents, activeWaypointId, activeWaypointRef, isProportional = true, toggleMode, children, height = INITIAL_OP_LIST_HEIGHT, width = 295, hidePositions = false, translations, }) => (React.createElement("div", { className: "ui-manchette-container", style: { width: `${width}px` } },
|
|
2799
3098
|
React.createElement("div", { className: "bg-white-100 border-r border-grey-30 relative", style: { height: `${height}px` } },
|
|
2800
3099
|
React.createElement("div", { className: "waypoints-list", style: { width: `${width - 1}px` } },
|
|
@@ -2945,7 +3244,7 @@ const useSyncManchette = ({ manchetteWithSpaceTimeChartRef, diagramRef, initialS
|
|
|
2945
3244
|
}
|
|
2946
3245
|
const newState = { ...prev };
|
|
2947
3246
|
const { initialOffset } = prev.panning;
|
|
2948
|
-
const diff = getDistance(payload.initialPosition, payload.position);
|
|
3247
|
+
const diff = getDistance$1(payload.initialPosition, payload.position);
|
|
2949
3248
|
const manchette = manchetteWithSpaceTimeChartRef.current;
|
|
2950
3249
|
newState.xOffset = initialOffset.x + diff.x;
|
|
2951
3250
|
let newYOffset = initialOffset.y - diff.y;
|
|
@@ -3790,7 +4089,7 @@ const SettingsPanel = ({ color, store, setStore, setIsMouseHoveringSettingsPanel
|
|
|
3790
4089
|
},
|
|
3791
4090
|
}));
|
|
3792
4091
|
};
|
|
3793
|
-
return (React.createElement("div", { id: "settings-panel", style: {
|
|
4092
|
+
return (React.createElement("div", { id: "settings-panel", "data-testid": testIdPrefix, style: {
|
|
3794
4093
|
background: `rgba(${color.substring(4, color.length - 1)}, 0.4)`,
|
|
3795
4094
|
height: `${SETTINGS_PANEL_BASE_HEIGHT}px`,
|
|
3796
4095
|
}, className: "font-sans", onMouseEnter: () => setIsMouseHoveringSettingsPanel(true), onMouseLeave: () => setIsMouseHoveringSettingsPanel(false) },
|
|
@@ -4799,8 +5098,6 @@ const ReticleLayer = ({ width, internalHeight: height, store, translations, }) =
|
|
|
4799
5098
|
// The tooltip shouldn't be displayed when hovering on the linear layers
|
|
4800
5099
|
if (store.cursor.y && store.cursor.y < height - MARGINS.MARGIN_TOP - MARGINS.MARGIN_BOTTOM) {
|
|
4801
5100
|
const detailsBox = drawCursor({ ctx, width, height, store });
|
|
4802
|
-
// TODO: fix this lint
|
|
4803
|
-
// eslint-disable-next-line react-hooks/set-state-in-effect
|
|
4804
5101
|
setTrainDetails(detailsBox || null);
|
|
4805
5102
|
}
|
|
4806
5103
|
else {
|
|
@@ -5822,14 +6119,16 @@ const OccupancyZonesLayer = ({ tracks, occupancyZones, position, topPadding, sel
|
|
|
5822
6119
|
// else, if there are too much trains:
|
|
5823
6120
|
else {
|
|
5824
6121
|
const nextIndex = filteredOccupancyZones.findIndex((filteredZone, i) => i > zoneIndex && filteredZone.startTime >= lastEndTime);
|
|
5825
|
-
|
|
6122
|
+
// nextIndex === -1 means all remaining zones overlap — skip to the end
|
|
6123
|
+
const endIndex = nextIndex === -1 ? filteredOccupancyZones.length : nextIndex;
|
|
6124
|
+
const remainingTrainsNb = endIndex - zoneIndex;
|
|
5826
6125
|
instructions.push({
|
|
5827
6126
|
type: 'remainingTrains',
|
|
5828
6127
|
amount: remainingTrainsNb,
|
|
5829
6128
|
time: (startTime + endTime) / 2,
|
|
5830
6129
|
offsetY: trackY,
|
|
5831
6130
|
});
|
|
5832
|
-
zoneIndex
|
|
6131
|
+
zoneIndex = endIndex;
|
|
5833
6132
|
}
|
|
5834
6133
|
}
|
|
5835
6134
|
});
|
|
@@ -6005,7 +6304,7 @@ const TracksLayer = ({ tracks, position, topPadding, drawBorders, }) => {
|
|
|
6005
6304
|
|
|
6006
6305
|
const CloseButton = ({ position, onClose }) => {
|
|
6007
6306
|
const { getSpacePixel } = useContext(SpaceTimeChartContext);
|
|
6008
|
-
return (React.createElement("button", { className: "close-track-occupancy-panel", onClick: () => onClose(), style: {
|
|
6307
|
+
return (React.createElement("button", { "data-testid": "close-track-occupancy-panel", className: "close-track-occupancy-panel", onClick: () => onClose(), style: {
|
|
6009
6308
|
top: getSpacePixel(position),
|
|
6010
6309
|
} },
|
|
6011
6310
|
React.createElement("span", null,
|
|
@@ -6016,11 +6315,9 @@ const TrackOccupancyCanvas = ({ position, tracks, occupancyZones, selectedTrainI
|
|
|
6016
6315
|
React.createElement(OccupancyZonesLayer, { tracks: tracks, position: position, topPadding: topPadding, occupancyZones: occupancyZones, selectedTrainId: selectedTrainId }),
|
|
6017
6316
|
onClose && React.createElement(CloseButton, { position: position, onClose: onClose })));
|
|
6018
6317
|
|
|
6019
|
-
const TrackOccupancyManchette = ({ tracks, children }) => (React.createElement("div", { className: "track-occupancy-manchette" },
|
|
6318
|
+
const TrackOccupancyManchette = ({ tracks, children }) => (React.createElement("div", { "data-testid": "track-occupancy-manchette", className: "track-occupancy-manchette" },
|
|
6020
6319
|
children,
|
|
6021
|
-
tracks.map((track) => (
|
|
6022
|
-
// height is shared between manchette and canvas components
|
|
6023
|
-
React.createElement("div", { className: "track", key: track.id, style: { height: TRACK_HEIGHT_CONTAINER } },
|
|
6320
|
+
tracks.map((track) => (React.createElement("div", { className: "track", key: track.id, style: { height: TRACK_HEIGHT_CONTAINER } },
|
|
6024
6321
|
React.createElement("span", { className: "track-line" }, track.line),
|
|
6025
6322
|
React.createElement("div", { className: "track-name" }, track.name),
|
|
6026
6323
|
React.createElement("div", { className: "track-rail" }))))));
|
|
@@ -6029,6 +6326,8 @@ const TrackOccupancyStandalone = ({ tracks, occupancyZones, selectedTrainId, onS
|
|
|
6029
6326
|
const manchetteWithSpaceTimeChartRef = useRef(null);
|
|
6030
6327
|
const spaceTimeChartRef = useRef(null);
|
|
6031
6328
|
const defaultTimeOrigin = useMemo(() => {
|
|
6329
|
+
// TODO: fix this lint
|
|
6330
|
+
/* eslint-disable-next-line react-hooks/purity */
|
|
6032
6331
|
const minTime = Math.min(...(occupancyZones.map((zone) => zone.startTime) || Date.now()));
|
|
6033
6332
|
// Take first round hour before minTime:
|
|
6034
6333
|
return Math.floor(minTime / HOUR) * HOUR;
|
|
@@ -6088,5 +6387,5 @@ const TrackOccupancyStandalone = ({ tracks, occupancyZones, selectedTrainId, onS
|
|
|
6088
6387
|
}) }))))));
|
|
6089
6388
|
};
|
|
6090
6389
|
|
|
6091
|
-
export { BASE_WAYPOINT_HEIGHT, CANVAS_PADDING, COLORS, Chronogram, ChronogramContext, ConflictLayer, ConflictTooltip, DEFAULT_LEVEL, DEFAULT_THEME, DEFAULT_ZOOM_MS_PER_PX, EtcsBrakingCurveType, EtcsBrakingType, FONTS, MINUTES_TEXT_OFFSET, Manchette, ManchetteWithSpaceTimeChart, MouseContext, OCCUPANCY_ZONE_HEIGHT, OCCUPANCY_ZONE_Y_START, OccupancyBlockLayer, PathLayer, PatternRect, Quadrilateral, STATION_TEXT_OFFSET, SpaceTimeChart, SpaceTimeChartCanvasContext, SpaceTimeChartContext, SpeedSpaceChart, TICKS_PATTERN, TICKS_PRIORITIES, TRACK_HEIGHT_CONTAINER, TimeCaptions, TimeGraduations, Tooltip$1 as Tooltip, TrackOccupancyCanvas, TrackOccupancyManchette, TrackOccupancyStandalone, Waypoint as WaypointComponent, WorkScheduleLayer, ZoomRect, computeRectZoomOffsets, getCrispLineCoordinate, getSpaceAtTime, isConflictPickingElement, isInteractiveWaypoint, isOccupancyPickingElement, isPathOnScreen, isPointPickingElement, isQuadrilaterPickingElement, isSegmentPickingElement, positionKmToMm, positionMmToKm, timeScaleToZoomValue, useDraw, useManchetteWithSpaceTimeChart, usePicking };
|
|
6390
|
+
export { BASE_WAYPOINT_HEIGHT, CANVAS_PADDING, COLORS, Chronogram, ChronogramCanvas, ChronogramContext, ConflictLayer, ConflictTooltip, DEFAULT_LEVEL, DEFAULT_THEME, DEFAULT_ZOOM_MS_PER_PX, EtcsBrakingCurveType, EtcsBrakingType, FONTS, MINUTES_TEXT_OFFSET, Manchette, ManchetteWithSpaceTimeChart, MouseContext, OCCUPANCY_ZONE_HEIGHT, OCCUPANCY_ZONE_Y_START, OccupancyBlockLayer, OccupancyBlocksLayer, PathLayer, PatternRect, Quadrilateral, STATION_TEXT_OFFSET, SpaceTimeChart, SpaceTimeChartCanvasContext, SpaceTimeChartContext, SpeedSpaceChart, TICKS_PATTERN, TICKS_PRIORITIES, TRACK_HEIGHT_CONTAINER, TimeCaptions, TimeGraduations, Tooltip$1 as Tooltip, TrackOccupancyCanvas, TrackOccupancyManchette, TrackOccupancyStandalone, Waypoint as WaypointComponent, WorkScheduleLayer, ZoomRect, computeRectZoomOffsets, getCrispLineCoordinate, getSpaceAtTime, isConflictPickingElement, isInteractiveWaypoint, isOccupancyPickingElement, isPathOnScreen, isPointPickingElement, isQuadrilaterPickingElement, isSegmentPickingElement, positionKmToMm, positionMmToKm, timeScaleToZoomValue, useDraw, useManchetteWithSpaceTimeChart, usePicking };
|
|
6092
6391
|
//# sourceMappingURL=index.esm.js.map
|