@aquera/nile-visualization 2.9.53 → 2.9.55
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/README.md +8 -0
- package/dist/src/index.d.ts +1 -1
- package/dist/src/internal/types/chart-master-detail-config.type.d.ts +11 -1
- package/dist/src/nile-chart/nile-chart-config.d.ts +11 -1
- package/dist/src/nile-chart/nile-chart.js +6 -1
- package/dist/src/nile-master-detail-chart/index.d.ts +1 -1
- package/dist/src/nile-master-detail-chart/nile-master-detail-chart.css.js +201 -6
- package/dist/src/nile-master-detail-chart/nile-master-detail-chart.d.ts +67 -1
- package/dist/src/nile-master-detail-chart/nile-master-detail-chart.js +349 -16
- package/dist/src/nile-master-detail-chart/nile-master-detail-chart.test.js +353 -3
- package/package.json +1 -1
|
@@ -28,11 +28,15 @@ export const MASTER_DETAIL_CHART_PARTS = [
|
|
|
28
28
|
'navigator-bar',
|
|
29
29
|
'navigator-slider',
|
|
30
30
|
'navigator-pan-button',
|
|
31
|
+
'navigator-handle',
|
|
32
|
+
'navigator-window',
|
|
33
|
+
'navigator-handle-label',
|
|
34
|
+
'navigator-mask',
|
|
31
35
|
];
|
|
32
36
|
/** Duration units accepted by `navigator-default-window`, `navigator-pan-step` and `navigator-slider-step`. */
|
|
33
37
|
const DURATION_UNITS = { m: 6e4, h: 36e5, d: 864e5, w: 6048e5 };
|
|
34
|
-
/**
|
|
35
|
-
const
|
|
38
|
+
/** Room (px) reserved above the master plot for the `labeled` handles' value pills. */
|
|
39
|
+
const LABEL_ROOM = 26;
|
|
36
40
|
/**
|
|
37
41
|
* @tag nile-master-detail-chart
|
|
38
42
|
* @summary A detail chart above an overview (master) strip; dragging on the strip zooms the detail.
|
|
@@ -50,7 +54,14 @@ const NAV_CONTROL_GUTTER = 48;
|
|
|
50
54
|
* (`navigator-slider`, `navigator-pan-buttons`).
|
|
51
55
|
* @csspart navigator-slider - The `nile-slider` that positions the window (`navigator-slider`).
|
|
52
56
|
* @csspart navigator-pan-button - Each pan button (`Pan back`, `Pan forward`) in the bar (`navigator-pan-buttons`).
|
|
57
|
+
* @csspart navigator-handle - Each draggable edge grip on the master window (`navigator-handles`).
|
|
58
|
+
* @csspart navigator-window - The draggable window body between the grips (`navigator-handles`).
|
|
59
|
+
* @csspart navigator-handle-label - The value pill above each `labeled` grip (`navigator-handle-variant="labeled"`).
|
|
60
|
+
* @csspart navigator-mask - Each frosted area outside the window on the master pane (`navigator-mask="frost"`).
|
|
53
61
|
*
|
|
62
|
+
* @cssproperty --nile-master-detail-frost-tint - How much surface colour covers the master outside the window
|
|
63
|
+
* with `navigator-mask="frost"`: `0%` is clear, `100%` hides it. Default `45%`.
|
|
64
|
+
* @cssproperty --nile-master-detail-frost-blur - Blur behind the `frost` mask. Default `1px`; `0` turns it off.
|
|
54
65
|
* @dependency nile-slider - `navigator-slider` renders a `nile-slider` from `@aquera/nile-elements`; register it in the app.
|
|
55
66
|
*/
|
|
56
67
|
let NileMasterDetailChart = class NileMasterDetailChart extends NileElement {
|
|
@@ -66,6 +77,9 @@ let NileMasterDetailChart = class NileMasterDetailChart extends NileElement {
|
|
|
66
77
|
this._panning = false;
|
|
67
78
|
this._drag = null;
|
|
68
79
|
this._dragFrame = 0;
|
|
80
|
+
/** Live grip-drag gesture: which edge (or the body), the pointer id, and the master-axis geometry at grab. */
|
|
81
|
+
this._grip = null;
|
|
82
|
+
this._gripFrame = 0;
|
|
69
83
|
this.config = null;
|
|
70
84
|
this.chartTitle = '';
|
|
71
85
|
this.chartSubtitle = '';
|
|
@@ -120,6 +134,33 @@ let NileMasterDetailChart = class NileMasterDetailChart extends NileElement {
|
|
|
120
134
|
* ending at the latest data. Empty opens on the full range.
|
|
121
135
|
*/
|
|
122
136
|
this.navigatorDefaultWindow = '';
|
|
137
|
+
/**
|
|
138
|
+
* Draggable grips on the master window: an edge grip on each side resizes the window (the other edge
|
|
139
|
+
* stays put, grips never cross), the body between them moves it keeping its width. Each grip is a
|
|
140
|
+
* keyboard-focusable `role="slider"` thumb. Works in master+detail and `master-only`. Turns on
|
|
141
|
+
* `navigator-default-window`.
|
|
142
|
+
*/
|
|
143
|
+
this.navigatorHandles = false;
|
|
144
|
+
/**
|
|
145
|
+
* Look of the `navigator-handles` grips: `pill` (default) is a small rounded grip; `labeled` is a
|
|
146
|
+
* full-height edge line with a grip and a pill above it showing the edge's value.
|
|
147
|
+
*/
|
|
148
|
+
this.navigatorHandleVariant = 'pill';
|
|
149
|
+
/**
|
|
150
|
+
* When the `labeled` handles show their value pills: `active` (default) — only while a grip is hovered,
|
|
151
|
+
* focused or dragged, or the window is dragged — or `always`.
|
|
152
|
+
*/
|
|
153
|
+
this.navigatorHandleLabel = 'active';
|
|
154
|
+
/**
|
|
155
|
+
* Highcharts date format for the `labeled` handles' pills on a datetime axis, e.g. `%b %e` (default,
|
|
156
|
+
* `Jun 15`), `%e %b %Y` (`15 Jun 2026`) or `%H:%M`. Other axes show the formatted value.
|
|
157
|
+
*/
|
|
158
|
+
this.navigatorHandleLabelFormat = '%b %e';
|
|
159
|
+
/**
|
|
160
|
+
* How the master pane shades the range outside the window: `solid` (default) fills it with `mask-fill`;
|
|
161
|
+
* `frost` blurs and fades it so the window stands out.
|
|
162
|
+
*/
|
|
163
|
+
this.navigatorMask = 'solid';
|
|
123
164
|
this._window = null;
|
|
124
165
|
this.height = '600px';
|
|
125
166
|
this.masterHeight = 100;
|
|
@@ -167,15 +208,23 @@ let NileMasterDetailChart = class NileMasterDetailChart extends NileElement {
|
|
|
167
208
|
this.masterChart?.reflow();
|
|
168
209
|
}
|
|
169
210
|
}
|
|
211
|
+
get _labeledHandles() {
|
|
212
|
+
return this.navigatorHandles && this.navigatorHandleVariant === 'labeled';
|
|
213
|
+
}
|
|
214
|
+
get _frostMask() {
|
|
215
|
+
return this.navigatorMask === 'frost';
|
|
216
|
+
}
|
|
170
217
|
/** True when any navigator feature is on. */
|
|
171
218
|
get _anyNavigator() {
|
|
172
|
-
return this.navigatorControls || this.navigatorSlider || this.navigatorPanButtons;
|
|
219
|
+
return this.navigatorControls || this.navigatorSlider || this.navigatorPanButtons || this.navigatorHandles;
|
|
173
220
|
}
|
|
174
221
|
/** Re-renders only when a navigator is shown, so plain charts skip the extra update. */
|
|
175
222
|
_trackWindow(min, max) {
|
|
176
223
|
this._window = { min, max };
|
|
177
224
|
if (this._anyNavigator)
|
|
178
225
|
this.requestUpdate();
|
|
226
|
+
if (this.navigatorHandles || this._frostMask)
|
|
227
|
+
this.updateComplete.then(() => this._positionHandles());
|
|
179
228
|
}
|
|
180
229
|
_cssLength(val) {
|
|
181
230
|
return typeof val === 'number'
|
|
@@ -231,6 +280,8 @@ let NileMasterDetailChart = class NileMasterDetailChart extends NileElement {
|
|
|
231
280
|
this.applyConfig(this.config);
|
|
232
281
|
return;
|
|
233
282
|
}
|
|
283
|
+
if (changedProperties.has('navigatorHandleLabelFormat'))
|
|
284
|
+
this._positionHandles();
|
|
234
285
|
if (changedProperties.has('masterOnly')) {
|
|
235
286
|
this.destroyCharts();
|
|
236
287
|
if (!this.loading)
|
|
@@ -264,6 +315,7 @@ let NileMasterDetailChart = class NileMasterDetailChart extends NileElement {
|
|
|
264
315
|
'navigatorControls',
|
|
265
316
|
'navigatorSlider',
|
|
266
317
|
'navigatorPanButtons',
|
|
318
|
+
'navigatorHandles',
|
|
267
319
|
'detailTitle',
|
|
268
320
|
'masterTitle',
|
|
269
321
|
'maskFill',
|
|
@@ -289,8 +341,12 @@ let NileMasterDetailChart = class NileMasterDetailChart extends NileElement {
|
|
|
289
341
|
return oldV !== newV;
|
|
290
342
|
}
|
|
291
343
|
};
|
|
292
|
-
if (!props.some(reallyChanged))
|
|
344
|
+
if (!props.some(reallyChanged)) {
|
|
345
|
+
if (changedProperties.has('navigatorHandleVariant') || changedProperties.has('navigatorMask')) {
|
|
346
|
+
this._restyleMaster();
|
|
347
|
+
}
|
|
293
348
|
return;
|
|
349
|
+
}
|
|
294
350
|
if (this.loading) {
|
|
295
351
|
this.destroyCharts();
|
|
296
352
|
return;
|
|
@@ -313,6 +369,15 @@ let NileMasterDetailChart = class NileMasterDetailChart extends NileElement {
|
|
|
313
369
|
this.initCharts();
|
|
314
370
|
}
|
|
315
371
|
}
|
|
372
|
+
/** Applies a handle-look or mask change to the master without resetting the window. */
|
|
373
|
+
_restyleMaster() {
|
|
374
|
+
if (!this.masterChart || this.loading || !this._typesValid)
|
|
375
|
+
return;
|
|
376
|
+
this.masterChart.update(this.buildMasterOptions(), true, true);
|
|
377
|
+
if (this._window)
|
|
378
|
+
this.applySelection(this._window.min, this._window.max);
|
|
379
|
+
this._positionHandles();
|
|
380
|
+
}
|
|
316
381
|
setupResizeObserver() {
|
|
317
382
|
const target = this.detailContainer ?? this.masterContainer;
|
|
318
383
|
if (!target)
|
|
@@ -463,8 +528,8 @@ let NileMasterDetailChart = class NileMasterDetailChart extends NileElement {
|
|
|
463
528
|
shared: true,
|
|
464
529
|
};
|
|
465
530
|
const merged = deepMerge({
|
|
466
|
-
//
|
|
467
|
-
chart: { type: this.detailType, reflow: true
|
|
531
|
+
// The + / − zoom control overlays the chart's top-right corner; it reserves no space.
|
|
532
|
+
chart: { type: this.detailType, reflow: true },
|
|
468
533
|
title: { text: this.detailTitle || undefined },
|
|
469
534
|
xAxis: {
|
|
470
535
|
type: this.xAxisType,
|
|
@@ -513,7 +578,7 @@ let NileMasterDetailChart = class NileMasterDetailChart extends NileElement {
|
|
|
513
578
|
// masterOnly fills the container, so its auto margins already reserve
|
|
514
579
|
// room — leave that mode untouched.
|
|
515
580
|
marginBottom: mo ? undefined : 30,
|
|
516
|
-
|
|
581
|
+
spacingTop: this._labeledHandles && !this.masterTitle ? 10 + LABEL_ROOM : undefined,
|
|
517
582
|
zoomType: 'x',
|
|
518
583
|
events: {
|
|
519
584
|
selection(event) {
|
|
@@ -536,9 +601,18 @@ let NileMasterDetailChart = class NileMasterDetailChart extends NileElement {
|
|
|
536
601
|
self.setZoomed(true);
|
|
537
602
|
return false;
|
|
538
603
|
},
|
|
604
|
+
redraw() {
|
|
605
|
+
self._positionHandles();
|
|
606
|
+
},
|
|
607
|
+
render() {
|
|
608
|
+
self._positionHandles();
|
|
609
|
+
},
|
|
539
610
|
},
|
|
540
611
|
},
|
|
541
|
-
title: {
|
|
612
|
+
title: {
|
|
613
|
+
text: this.masterTitle || undefined,
|
|
614
|
+
...(this._labeledHandles && this.masterTitle ? { margin: 15 + LABEL_ROOM } : {}),
|
|
615
|
+
},
|
|
542
616
|
// With several series the legend lives on the detail pane, so the master
|
|
543
617
|
// must use the same colours or the overview contradicts it. Inherit the
|
|
544
618
|
// detail palette (`options.colors`, which nile-chart fills from its theme)
|
|
@@ -636,6 +710,8 @@ let NileMasterDetailChart = class NileMasterDetailChart extends NileElement {
|
|
|
636
710
|
const xAxis = this.masterChart.xAxis[0];
|
|
637
711
|
xAxis.removePlotBand('mask-before');
|
|
638
712
|
xAxis.removePlotBand('mask-after');
|
|
713
|
+
if (this._frostMask)
|
|
714
|
+
return;
|
|
639
715
|
if (min > dataMin)
|
|
640
716
|
xAxis.addPlotBand({ id: 'mask-before', from: dataMin, to: min, color: this.maskFill });
|
|
641
717
|
if (max < dataMax)
|
|
@@ -916,6 +992,184 @@ let NileMasterDetailChart = class NileMasterDetailChart extends NileElement {
|
|
|
916
992
|
this._drag = null;
|
|
917
993
|
this._panning = false;
|
|
918
994
|
}
|
|
995
|
+
/** Grip step for Shift + arrow: ~10% of the data points, at least one. */
|
|
996
|
+
get _gripShiftStep() {
|
|
997
|
+
return Math.max(1, Math.round(this._allXs().length * 0.1));
|
|
998
|
+
}
|
|
999
|
+
/** Moves one window edge to data index `index`, clamped so the grips stay at least one point apart. */
|
|
1000
|
+
_resizeWindow(edge, index) {
|
|
1001
|
+
const cur = this._windowIndices();
|
|
1002
|
+
const xs = this._allXs();
|
|
1003
|
+
if (!cur || xs.length < 2)
|
|
1004
|
+
return;
|
|
1005
|
+
const last = xs.length - 1;
|
|
1006
|
+
let { lo, hi } = cur;
|
|
1007
|
+
if (edge === 'start')
|
|
1008
|
+
lo = Math.min(Math.max(0, index), hi - 1);
|
|
1009
|
+
else
|
|
1010
|
+
hi = Math.max(Math.min(last, index), lo + 1);
|
|
1011
|
+
if (lo === cur.lo && hi === cur.hi)
|
|
1012
|
+
return;
|
|
1013
|
+
this._applyWindow(lo, hi);
|
|
1014
|
+
}
|
|
1015
|
+
/** The master x-axis, when the chart exists. */
|
|
1016
|
+
get _masterAxis() {
|
|
1017
|
+
return this.masterChart?.xAxis?.[0] ?? null;
|
|
1018
|
+
}
|
|
1019
|
+
/** Positions the two grips and the body over the master plot from the current window. No-op when off. */
|
|
1020
|
+
_positionHandles() {
|
|
1021
|
+
if (!(this.navigatorHandles || this._frostMask) || this.masterCollapsed)
|
|
1022
|
+
return;
|
|
1023
|
+
const chart = this.masterChart;
|
|
1024
|
+
const ax = this._masterAxis;
|
|
1025
|
+
const cur = this._windowIndices();
|
|
1026
|
+
if (!chart || !ax || typeof ax.toPixels !== 'function' || !cur)
|
|
1027
|
+
return;
|
|
1028
|
+
const xs = this._allXs();
|
|
1029
|
+
const left = ax.toPixels(xs[cur.lo], false);
|
|
1030
|
+
const right = ax.toPixels(xs[cur.hi], false);
|
|
1031
|
+
const top = chart.plotTop ?? 0;
|
|
1032
|
+
const height = chart.plotHeight ?? 0;
|
|
1033
|
+
const grips = this.renderRoot.querySelectorAll('[part~="navigator-handle"]');
|
|
1034
|
+
const body = this.renderRoot.querySelector('[part~="navigator-window"]');
|
|
1035
|
+
grips.forEach(g => {
|
|
1036
|
+
const px = g.dataset.edge === 'end' ? right : left;
|
|
1037
|
+
g.style.left = `${px}px`;
|
|
1038
|
+
g.style.top = `${top}px`;
|
|
1039
|
+
g.style.height = `${height}px`;
|
|
1040
|
+
});
|
|
1041
|
+
this._placeLabels(grips, left, right);
|
|
1042
|
+
if (body) {
|
|
1043
|
+
body.style.left = `${left}px`;
|
|
1044
|
+
body.style.width = `${Math.max(0, right - left)}px`;
|
|
1045
|
+
body.style.top = `${top}px`;
|
|
1046
|
+
body.style.height = `${height}px`;
|
|
1047
|
+
}
|
|
1048
|
+
const plotLeft = chart.plotLeft ?? 0;
|
|
1049
|
+
const plotRight = plotLeft + (chart.plotWidth ?? 0);
|
|
1050
|
+
this.renderRoot.querySelectorAll('[part~="navigator-mask"]').forEach(m => {
|
|
1051
|
+
const [from, to] = m.dataset.side === 'after' ? [right, plotRight] : [plotLeft, left];
|
|
1052
|
+
m.style.left = `${from}px`;
|
|
1053
|
+
m.style.width = `${Math.max(0, to - from)}px`;
|
|
1054
|
+
m.style.top = `${top}px`;
|
|
1055
|
+
m.style.height = `${height}px`;
|
|
1056
|
+
});
|
|
1057
|
+
}
|
|
1058
|
+
/** Centres each value pill on top of its edge and keeps both inside the master. */
|
|
1059
|
+
_placeLabels(grips, left, right) {
|
|
1060
|
+
const width = grips[0]?.offsetParent?.clientWidth ?? 0;
|
|
1061
|
+
const labelOf = (edge) => Array.from(grips)
|
|
1062
|
+
.find(g => g.dataset.edge === edge)
|
|
1063
|
+
?.querySelector('[part~="navigator-handle-label"]') ?? null;
|
|
1064
|
+
const start = labelOf('start');
|
|
1065
|
+
const end = labelOf('end');
|
|
1066
|
+
if (!start || !end || !width)
|
|
1067
|
+
return;
|
|
1068
|
+
const ws = start.offsetWidth;
|
|
1069
|
+
const we = end.offsetWidth;
|
|
1070
|
+
// Each pill stays centred on top of its own handle; it only slides sideways to stay inside the master.
|
|
1071
|
+
const cs = Math.min(Math.max(left, ws / 2), width - ws / 2);
|
|
1072
|
+
const ce = Math.min(Math.max(right, we / 2), width - we / 2);
|
|
1073
|
+
// Crowded: the CSS dims the pill underneath so the one on top reads clearly.
|
|
1074
|
+
grips[0]?.parentElement?.toggleAttribute('data-crowded', right - left < (ws + we) / 2 + 4);
|
|
1075
|
+
start.style.marginLeft = cs !== left ? `${cs - left}px` : '';
|
|
1076
|
+
end.style.marginLeft = ce !== right ? `${ce - right}px` : '';
|
|
1077
|
+
}
|
|
1078
|
+
_onGripStart(e, edge) {
|
|
1079
|
+
if (e.button !== 0 || !e.isPrimary)
|
|
1080
|
+
return;
|
|
1081
|
+
const cur = this._windowIndices();
|
|
1082
|
+
const ax = this._masterAxis;
|
|
1083
|
+
const len = ax?.len;
|
|
1084
|
+
if (!cur || !len)
|
|
1085
|
+
return;
|
|
1086
|
+
const xs = this._allXs();
|
|
1087
|
+
const a = this._toScale(xs[cur.lo]);
|
|
1088
|
+
const b = this._toScale(xs[cur.hi]);
|
|
1089
|
+
const span = this._toScale(xs[xs.length - 1]) - this._toScale(xs[0]);
|
|
1090
|
+
this._grip = { id: e.pointerId, edge, x: e.clientX, a, b, perPx: span / len, active: false };
|
|
1091
|
+
// Capture at once: a narrow grip loses the pointer before the 4px threshold otherwise.
|
|
1092
|
+
try {
|
|
1093
|
+
e.currentTarget.setPointerCapture(e.pointerId);
|
|
1094
|
+
}
|
|
1095
|
+
catch {
|
|
1096
|
+
// Synthetic pointers can't be captured; the gesture still follows move events.
|
|
1097
|
+
}
|
|
1098
|
+
}
|
|
1099
|
+
_onGripMove(e) {
|
|
1100
|
+
const g = this._grip;
|
|
1101
|
+
if (!g || e.pointerId !== g.id)
|
|
1102
|
+
return;
|
|
1103
|
+
const dx = e.clientX - g.x;
|
|
1104
|
+
if (!g.active) {
|
|
1105
|
+
if (Math.abs(dx) < 4)
|
|
1106
|
+
return;
|
|
1107
|
+
g.active = true;
|
|
1108
|
+
try {
|
|
1109
|
+
e.currentTarget.setPointerCapture(e.pointerId);
|
|
1110
|
+
}
|
|
1111
|
+
catch {
|
|
1112
|
+
// Pointer already released (or synthetic) — the gesture still follows move events.
|
|
1113
|
+
}
|
|
1114
|
+
}
|
|
1115
|
+
e.preventDefault();
|
|
1116
|
+
cancelAnimationFrame(this._gripFrame);
|
|
1117
|
+
this._gripFrame = requestAnimationFrame(() => {
|
|
1118
|
+
const xs = this._allXs();
|
|
1119
|
+
const perPx = g.perPx;
|
|
1120
|
+
if (g.edge === 'body') {
|
|
1121
|
+
const shift = dx * perPx;
|
|
1122
|
+
this._setWindow(this._fromScale(g.a + shift), this._fromScale(g.b + shift));
|
|
1123
|
+
}
|
|
1124
|
+
else {
|
|
1125
|
+
const scale = (g.edge === 'start' ? g.a : g.b) + dx * perPx;
|
|
1126
|
+
this._resizeWindow(g.edge, this._nearestIndex(xs, this._fromScale(scale)));
|
|
1127
|
+
}
|
|
1128
|
+
});
|
|
1129
|
+
}
|
|
1130
|
+
_onGripEnd(e) {
|
|
1131
|
+
if (!this._grip || e.pointerId !== this._grip.id)
|
|
1132
|
+
return;
|
|
1133
|
+
this._grip = null;
|
|
1134
|
+
cancelAnimationFrame(this._gripFrame);
|
|
1135
|
+
}
|
|
1136
|
+
_onGripKeydown(e, edge) {
|
|
1137
|
+
if (e.altKey || e.ctrlKey || e.metaKey)
|
|
1138
|
+
return;
|
|
1139
|
+
const cur = this._windowIndices();
|
|
1140
|
+
const xs = this._allXs();
|
|
1141
|
+
if (!cur || xs.length < 2)
|
|
1142
|
+
return;
|
|
1143
|
+
const last = xs.length - 1;
|
|
1144
|
+
const idx = edge === 'start' ? cur.lo : cur.hi;
|
|
1145
|
+
const step = e.shiftKey ? this._gripShiftStep : 1;
|
|
1146
|
+
let next;
|
|
1147
|
+
if (e.key === 'ArrowLeft')
|
|
1148
|
+
next = idx - step;
|
|
1149
|
+
else if (e.key === 'ArrowRight')
|
|
1150
|
+
next = idx + step;
|
|
1151
|
+
else if (e.key === 'Home')
|
|
1152
|
+
next = edge === 'start' ? 0 : cur.lo + 1;
|
|
1153
|
+
else if (e.key === 'End')
|
|
1154
|
+
next = edge === 'start' ? cur.hi - 1 : last;
|
|
1155
|
+
else
|
|
1156
|
+
return;
|
|
1157
|
+
e.preventDefault();
|
|
1158
|
+
this._resizeWindow(edge, next);
|
|
1159
|
+
}
|
|
1160
|
+
/** An x value as a `labeled` grip's pill shows it: `navigator-handle-label-format` on a datetime axis. */
|
|
1161
|
+
_formatShortX(v) {
|
|
1162
|
+
if (this.xAxisType === 'datetime' && this._hc?.dateFormat) {
|
|
1163
|
+
return this._hc.dateFormat(this.navigatorHandleLabelFormat || '%b %e', v);
|
|
1164
|
+
}
|
|
1165
|
+
return this._formatX(v);
|
|
1166
|
+
}
|
|
1167
|
+
/** Formats an x value for a grip's `aria-valuetext`: a date on a datetime axis, else the raw value. */
|
|
1168
|
+
_formatX(v) {
|
|
1169
|
+
if (this.xAxisType === 'datetime' && this._hc?.dateFormat)
|
|
1170
|
+
return this._hc.dateFormat('%e %b %Y', v);
|
|
1171
|
+
return String(v);
|
|
1172
|
+
}
|
|
919
1173
|
/** Arrow keys pan, + / − zoom, when the chart pane has focus. */
|
|
920
1174
|
_onNavKeydown(e) {
|
|
921
1175
|
if (!this.navigatorControls || e.altKey || e.ctrlKey || e.metaKey)
|
|
@@ -975,6 +1229,7 @@ let NileMasterDetailChart = class NileMasterDetailChart extends NileElement {
|
|
|
975
1229
|
class="navigator-slider"
|
|
976
1230
|
part="navigator-slider"
|
|
977
1231
|
aria-label="Visible range position"
|
|
1232
|
+
.valueLabel=${'none'}
|
|
978
1233
|
.minValue=${0}
|
|
979
1234
|
.maxValue=${1000}
|
|
980
1235
|
.value=${nav.sliderValue}
|
|
@@ -986,6 +1241,64 @@ let NileMasterDetailChart = class NileMasterDetailChart extends NileElement {
|
|
|
986
1241
|
${this.navigatorPanButtons ? this._panButton('ng-chevron-right', 'Pan forward', nav.atEnd, 1) : nothing}
|
|
987
1242
|
</div>`;
|
|
988
1243
|
}
|
|
1244
|
+
/** Draggable grips over the master window: an edge grip each side plus the movable body between them. */
|
|
1245
|
+
_renderOverlay(showHandles, showMask) {
|
|
1246
|
+
const overlayClasses = [
|
|
1247
|
+
'navigator-overlay',
|
|
1248
|
+
this._labeledHandles ? 'navigator-overlay--labeled' : '',
|
|
1249
|
+
this._labeledHandles && this.navigatorHandleLabel === 'active' ? 'navigator-overlay--label-active' : '',
|
|
1250
|
+
].join(' ');
|
|
1251
|
+
return html `<div class=${overlayClasses}>
|
|
1252
|
+
${showMask
|
|
1253
|
+
? html `<div class="navigator-mask" part="navigator-mask" data-side="before"></div>
|
|
1254
|
+
<div class="navigator-mask" part="navigator-mask" data-side="after"></div>`
|
|
1255
|
+
: nothing}
|
|
1256
|
+
${showHandles ? this._renderHandles() : nothing}
|
|
1257
|
+
</div>`;
|
|
1258
|
+
}
|
|
1259
|
+
_renderGrip(edge, value, min, max) {
|
|
1260
|
+
const labeled = this._labeledHandles;
|
|
1261
|
+
return html `<div
|
|
1262
|
+
class="navigator-handle"
|
|
1263
|
+
part="navigator-handle"
|
|
1264
|
+
data-edge=${edge}
|
|
1265
|
+
role="slider"
|
|
1266
|
+
tabindex="0"
|
|
1267
|
+
aria-label=${edge === 'start' ? 'Window start' : 'Window end'}
|
|
1268
|
+
aria-valuemin=${min}
|
|
1269
|
+
aria-valuemax=${max}
|
|
1270
|
+
aria-valuenow=${value}
|
|
1271
|
+
aria-valuetext=${this._formatX(value)}
|
|
1272
|
+
@pointerdown=${(e) => this._onGripStart(e, edge)}
|
|
1273
|
+
@pointermove=${this._onGripMove}
|
|
1274
|
+
@pointerup=${this._onGripEnd}
|
|
1275
|
+
@pointercancel=${this._onGripEnd}
|
|
1276
|
+
@keydown=${(e) => this._onGripKeydown(e, edge)}
|
|
1277
|
+
>
|
|
1278
|
+
${labeled
|
|
1279
|
+
? html `<span class="navigator-handle-grip"></span
|
|
1280
|
+
><span class="navigator-handle-label" part="navigator-handle-label" aria-hidden="true"
|
|
1281
|
+
>${this._formatShortX(value)}</span
|
|
1282
|
+
>`
|
|
1283
|
+
: nothing}
|
|
1284
|
+
</div>`;
|
|
1285
|
+
}
|
|
1286
|
+
_renderHandles() {
|
|
1287
|
+
const xs = this._allXs();
|
|
1288
|
+
const cur = this._windowIndices() ?? { lo: 0, hi: xs.length - 1 };
|
|
1289
|
+
const startX = xs[cur.lo];
|
|
1290
|
+
const endX = xs[cur.hi];
|
|
1291
|
+
return html `${this._renderGrip('start', startX, xs[0], endX)}
|
|
1292
|
+
<div
|
|
1293
|
+
class="navigator-window"
|
|
1294
|
+
part="navigator-window"
|
|
1295
|
+
@pointerdown=${(e) => this._onGripStart(e, 'body')}
|
|
1296
|
+
@pointermove=${this._onGripMove}
|
|
1297
|
+
@pointerup=${this._onGripEnd}
|
|
1298
|
+
@pointercancel=${this._onGripEnd}
|
|
1299
|
+
></div>
|
|
1300
|
+
${this._renderGrip('end', endX, startX, xs[xs.length - 1])}`;
|
|
1301
|
+
}
|
|
989
1302
|
/** Map-style + / − zoom buttons, overlaid on the top-right corner of the chart. */
|
|
990
1303
|
_renderZoomControls() {
|
|
991
1304
|
const nav = this._navState;
|
|
@@ -1042,6 +1355,8 @@ let NileMasterDetailChart = class NileMasterDetailChart extends NileElement {
|
|
|
1042
1355
|
const enoughData = this._allXs().length >= 2;
|
|
1043
1356
|
const showNav = this.navigatorControls && enoughData;
|
|
1044
1357
|
const showBar = (this.navigatorSlider || this.navigatorPanButtons) && enoughData;
|
|
1358
|
+
const showHandles = this.navigatorHandles && enoughData && !masterHidden;
|
|
1359
|
+
const showMask = this._frostMask && enoughData && !masterHidden && !this.masterOnly;
|
|
1045
1360
|
const pannable = showNav && !this.masterOnly && !this._navState.full;
|
|
1046
1361
|
const navLabel = 'Chart. Arrow keys pan, plus and minus zoom.';
|
|
1047
1362
|
const detailClasses = [
|
|
@@ -1079,14 +1394,17 @@ let NileMasterDetailChart = class NileMasterDetailChart extends NileElement {
|
|
|
1079
1394
|
</button>
|
|
1080
1395
|
</nile-lite-tooltip>`
|
|
1081
1396
|
: null}`}
|
|
1082
|
-
<div
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1397
|
+
<div class="master-wrap ${masterHidden ? 'master-wrap--collapsed' : ''}">
|
|
1398
|
+
<div
|
|
1399
|
+
class="master-container ${masterHidden ? 'master-container--collapsed' : ''}"
|
|
1400
|
+
part="master-container"
|
|
1401
|
+
tabindex=${showNav && this.masterOnly ? '0' : nothing}
|
|
1402
|
+
role=${showNav && this.masterOnly ? 'region' : nothing}
|
|
1403
|
+
aria-label=${showNav && this.masterOnly ? navLabel : nothing}
|
|
1404
|
+
@keydown=${this.masterOnly ? this._onNavKeydown : nothing}
|
|
1405
|
+
></div>
|
|
1406
|
+
${showHandles || showMask ? this._renderOverlay(showHandles, showMask) : nothing}
|
|
1407
|
+
</div>
|
|
1090
1408
|
${showNav ? this._renderZoomControls() : nothing}
|
|
1091
1409
|
${showBar ? this._renderNavigatorBar() : nothing}
|
|
1092
1410
|
</div>`;
|
|
@@ -1165,6 +1483,21 @@ __decorate([
|
|
|
1165
1483
|
__decorate([
|
|
1166
1484
|
property({ type: String, attribute: 'navigator-default-window' })
|
|
1167
1485
|
], NileMasterDetailChart.prototype, "navigatorDefaultWindow", void 0);
|
|
1486
|
+
__decorate([
|
|
1487
|
+
property({ type: Boolean, reflect: true, attribute: 'navigator-handles' })
|
|
1488
|
+
], NileMasterDetailChart.prototype, "navigatorHandles", void 0);
|
|
1489
|
+
__decorate([
|
|
1490
|
+
property({ type: String, reflect: true, attribute: 'navigator-handle-variant' })
|
|
1491
|
+
], NileMasterDetailChart.prototype, "navigatorHandleVariant", void 0);
|
|
1492
|
+
__decorate([
|
|
1493
|
+
property({ type: String, reflect: true, attribute: 'navigator-handle-label' })
|
|
1494
|
+
], NileMasterDetailChart.prototype, "navigatorHandleLabel", void 0);
|
|
1495
|
+
__decorate([
|
|
1496
|
+
property({ type: String, attribute: 'navigator-handle-label-format' })
|
|
1497
|
+
], NileMasterDetailChart.prototype, "navigatorHandleLabelFormat", void 0);
|
|
1498
|
+
__decorate([
|
|
1499
|
+
property({ type: String, reflect: true, attribute: 'navigator-mask' })
|
|
1500
|
+
], NileMasterDetailChart.prototype, "navigatorMask", void 0);
|
|
1168
1501
|
__decorate([
|
|
1169
1502
|
property({ type: String })
|
|
1170
1503
|
], NileMasterDetailChart.prototype, "height", void 0);
|