@aquera/nile-visualization 2.9.47 → 2.9.49

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 CHANGED
@@ -36,6 +36,12 @@ To run a local development server that serves the basic demo located in `demo/in
36
36
 
37
37
  In this section, you can find the updates for each release of `nile-visualization`. It's a good practice to maintain detailed release notes to help users and developers understand what changes have been made from one version to another and how these changes might affect their projects.
38
38
 
39
+ #### Version 2.9.49 (November 20, 2026)
40
+ - Nile Master-Detail Chart: `navigator-controls` is now map-style. The control bar under the master (pan buttons, window slider, zoom) is replaced by + / − zoom buttons over the chart's top-right corner; drag the zoomed chart (or focus it and use ← / →) to pan, + / − keys zoom. The chart keeps 48 px clear on the right for the control, which stays opaque when a button is disabled. The range caption under the master is removed, and with it `navigator-hint` and the `navigator-caption` / `navigator-hint` parts; build a readout from `nile-chart-selection { min, max }` if you need one. `navigator-default-window` is unchanged. New CSS part `navigator-button` (UIF-1433)
41
+
42
+ #### Version 2.9.48 (November 20, 2026)
43
+ - Nile Master-Detail Chart: Optional navigator bar under the master pane (`navigator-controls`): pan, a window slider, zoom in / out and a range caption with an optional `navigator-hint`. `navigator-default-window` (e.g. `0.25`, `7d`) opens zoomed in so the controls are usable on load. Off by default (UIF-1433)
44
+
39
45
  #### Version 2.9.47 (November 20, 2026)
40
46
  - Nile Charts: Reverted the 2.9.44 changes (x-axis label options and lite tooltips, UIF-1426)
41
47
 
@@ -14,6 +14,9 @@ export interface ChartMasterDetailConfigType {
14
14
  masterType?: MasterDetailSeriesType;
15
15
  masterOnly?: boolean;
16
16
  masterCollapsible?: boolean;
17
+ navigatorControls?: boolean;
18
+ /** Opening window with navigator controls: a fraction (`0.25`) or a duration (`7d`, `12h`, `30m`, `2w`). */
19
+ navigatorDefaultWindow?: string;
17
20
  xAxisType?: MasterDetailXAxisType;
18
21
  xAxisMin?: number | null;
19
22
  xAxisMax?: number | null;
@@ -422,6 +422,9 @@ export interface NileMasterDetailChartConfig extends NileChartConfigBase {
422
422
  masterType?: string;
423
423
  masterOnly?: boolean;
424
424
  masterCollapsible?: boolean;
425
+ navigatorControls?: boolean;
426
+ /** Opening window with navigator controls: a fraction (`0.25`) or a duration (`7d`, `12h`, `30m`, `2w`). */
427
+ navigatorDefaultWindow?: string;
425
428
  xAxisType?: 'datetime' | 'linear' | 'logarithmic' | 'category';
426
429
  xAxisMin?: number | null;
427
430
  xAxisMax?: number | null;
@@ -1642,6 +1642,8 @@ let NileChart = NileChart_1 = class NileChart extends NileElement {
1642
1642
  .masterType=${config.masterType ?? 'area'}
1643
1643
  .masterOnly=${config.masterOnly ?? false}
1644
1644
  .masterCollapsible=${config.masterCollapsible ?? false}
1645
+ .navigatorControls=${config.navigatorControls ?? false}
1646
+ .navigatorDefaultWindow=${config.navigatorDefaultWindow ?? ''}
1645
1647
  .xAxisType=${config.xAxisType ?? 'datetime'}
1646
1648
  .xAxisMin=${config.xAxisMin ?? null}
1647
1649
  .xAxisMax=${config.xAxisMax ?? null}
@@ -12,6 +12,7 @@ export const styles = css `
12
12
  }
13
13
 
14
14
  .chart-stack {
15
+ position: relative;
15
16
  display: flex;
16
17
  flex-direction: column;
17
18
  box-sizing: border-box;
@@ -98,6 +99,80 @@ export const styles = css `
98
99
  background: var(--nile-colors-dark-200, var(--ng-colors-bg-secondary-hover));
99
100
  }
100
101
 
102
+ /* Map-style zoom: one solid, joined control over the chart's top-right corner. The control owns the
103
+ background, border, radius and shadow; the buttons inside are borderless with a hairline divider,
104
+ so disabled buttons stay opaque (only the icon dims) and the chart never shows through. */
105
+ .navigator {
106
+ position: absolute;
107
+ top: var(--nile-master-detail-navigator-offset, var(--nile-spacing-2, var(--ng-spacing-2, 8px)));
108
+ right: var(--nile-master-detail-navigator-offset, var(--nile-spacing-2, var(--ng-spacing-2, 8px)));
109
+ z-index: 2;
110
+ display: flex;
111
+ flex-direction: column;
112
+ overflow: hidden;
113
+ background: var(--nile-colors-white-base, var(--ng-colors-bg-primary, Canvas));
114
+ border: var(--nile-border-width-1, var(--ng-stroke-width-1, 1px)) solid
115
+ var(--nile-colors-neutral-400, var(--ng-colors-border-secondary));
116
+ border-radius: var(--nile-radius-sm, var(--ng-radius-md, 8px));
117
+ box-shadow: var(--nile-box-shadow-1, var(--ng-shadow-xs));
118
+ }
119
+
120
+ .navigator-button {
121
+ display: flex;
122
+ align-items: center;
123
+ justify-content: center;
124
+ box-sizing: border-box;
125
+ width: var(--nile-height-32px, var(--ng-height-32px, 32px));
126
+ height: var(--nile-height-32px, var(--ng-height-32px, 32px));
127
+ padding: 0;
128
+ margin: 0;
129
+ border: none;
130
+ background: transparent;
131
+ color: var(--nile-colors-neutral-700, var(--ng-colors-text-secondary-700));
132
+ cursor: pointer;
133
+ transition: background 150ms ease, color 150ms ease;
134
+ }
135
+
136
+ .navigator-button + .navigator-button {
137
+ border-top: var(--nile-border-width-1, var(--ng-stroke-width-1, 1px)) solid
138
+ var(--nile-colors-neutral-400, var(--ng-colors-border-secondary));
139
+ }
140
+
141
+ .navigator-button:hover:not(:disabled) {
142
+ background: var(--nile-colors-dark-200, var(--ng-colors-bg-secondary-hover));
143
+ }
144
+
145
+ .navigator-button:focus-visible {
146
+ outline: var(--nile-border-width-2, var(--ng-stroke-width-2, 2px)) solid
147
+ var(--nile-colors-primary-600, var(--ng-colors-border-brand));
148
+ outline-offset: -2px;
149
+ }
150
+
151
+ /* Disabled: greyed fill and icon, still opaque, so it reads as unavailable at a glance. */
152
+ .navigator-button:disabled {
153
+ background: var(--nile-colors-neutral-100, var(--ng-colors-bg-tertiary, color-mix(in srgb, CanvasText 6%, Canvas)));
154
+ color: var(--nile-colors-neutral-400, var(--ng-colors-fg-disabled, GrayText));
155
+ cursor: not-allowed;
156
+ }
157
+
158
+ /* Drag-to-pan on the detail pane once zoomed in; vertical touch scroll still scrolls the page. */
159
+ .detail-container--pannable {
160
+ cursor: grab;
161
+ touch-action: pan-y;
162
+ }
163
+
164
+ .detail-container--panning {
165
+ cursor: grabbing;
166
+ user-select: none;
167
+ }
168
+
169
+ .detail-container:focus-visible,
170
+ .master-container:focus-visible {
171
+ outline: var(--nile-border-width-2, var(--ng-stroke-width-2, 2px)) solid
172
+ var(--nile-colors-primary-600, var(--ng-colors-border-brand));
173
+ outline-offset: -2px;
174
+ }
175
+
101
176
  .chart-loading {
102
177
  display: flex;
103
178
  align-items: center;
@@ -32,6 +32,10 @@ export declare class NileMasterDetailChart extends NileElement {
32
32
  private zoomed;
33
33
  private setZoomed;
34
34
  private masterCollapsed;
35
+ /** True while a drag-to-pan gesture is moving the window (drives the grabbing cursor). */
36
+ private _panning;
37
+ private _drag;
38
+ private _dragFrame;
35
39
  private toggleMasterCollapsed;
36
40
  config: SeparatedChartConfigInputType | null;
37
41
  chartTitle: string;
@@ -50,6 +54,16 @@ export declare class NileMasterDetailChart extends NileElement {
50
54
  masterType: MasterDetailSeriesType;
51
55
  masterOnly: boolean;
52
56
  masterCollapsible: boolean;
57
+ navigatorControls: boolean;
58
+ /**
59
+ * Opening window when `navigator-controls` is on and no `selection-min` / `selection-max` is set:
60
+ * a fraction of the range (`0.25`) or, on a datetime axis, a duration (`30m`, `12h`, `7d`, `2w`),
61
+ * ending at the latest data. Empty opens on the full range.
62
+ */
63
+ navigatorDefaultWindow: string;
64
+ private _window;
65
+ /** Re-renders only when the control bar is shown, so plain charts skip the extra update. */
66
+ private _trackWindow;
53
67
  height: string;
54
68
  masterHeight: string | number;
55
69
  xAxisType: MasterDetailXAxisType;
@@ -101,11 +115,43 @@ export declare class NileMasterDetailChart extends NileElement {
101
115
  private _zoomWindow;
102
116
  private _masterMinRange;
103
117
  private snapSelection;
118
+ /** Opening window from `navigatorDefaultWindow`, snapped to data points; `null` means use the full range. */
119
+ private _defaultWindow;
104
120
  private defaultSelection;
105
121
  private buildDetailOptions;
106
122
  private buildMasterOptions;
107
123
  resetZoom(): void;
108
124
  private applySelection;
125
+ /** Pan and zoom work on the log scale when the x-axis is logarithmic. */
126
+ private get _isLogX();
127
+ private _toScale;
128
+ private _fromScale;
129
+ /** Index of the data x nearest to `v` on the axis scale; `xs` is sorted. */
130
+ private _nearestIndex;
131
+ /** Clamps `[min, max]` into the data range keeping its width, then snaps both edges to data points. */
132
+ private _snapWindow;
133
+ private _windowIndices;
134
+ private _applyWindow;
135
+ private _setWindow;
136
+ /** Move the window by 25% of its width toward the start (`-1`) or end (`1`), at least one data point. */
137
+ panBy(direction: -1 | 1): void;
138
+ /** Scale the window around its centre: `0.5` zooms in, `2` zooms out; at least one data point per step. */
139
+ zoomBy(factor: number): void;
140
+ private get _navState();
141
+ /** Drag-to-pan on the detail pane: the window follows the pointer, keeping its width. */
142
+ private get _canDragPan();
143
+ private _onPanStart;
144
+ private _onPanMove;
145
+ private _onPanEnd;
146
+ /** Arrow keys pan, + / − zoom, when the chart pane has focus. */
147
+ private _onNavKeydown;
148
+ /**
149
+ * A native button inside one solid, joined control: disabled stays opaque (only the icon dims), so the
150
+ * chart never shows through, and the cluster keeps a single border with a hairline divider.
151
+ */
152
+ private _navButton;
153
+ /** Map-style + / − zoom buttons, overlaid on the top-right corner of the chart. */
154
+ private _renderZoomControls;
109
155
  private initCharts;
110
156
  private destroyCharts;
111
157
  render(): TemplateResult | typeof nothing;
@@ -17,6 +17,22 @@ export const MASTER_DETAIL_SERIES_TYPES = [
17
17
  'bar',
18
18
  ];
19
19
  export const MASTER_DETAIL_X_AXIS_TYPES = ['datetime', 'linear', 'logarithmic', 'category'];
20
+ /**
21
+ * @tag nile-master-detail-chart
22
+ * @summary A detail chart above an overview (master) strip; dragging on the strip zooms the detail.
23
+ *
24
+ * @event nile-chart-ready - Charts are created. `detail: { chart }`
25
+ * @event nile-chart-selection - The visible window changed. `detail: { min, max }`
26
+ * @event nile-master-detail-zoom - Zoomed in or back to the full range. `detail: { zoomed }`
27
+ *
28
+ * @csspart detail-container - The detail chart.
29
+ * @csspart master-container - The master (overview) strip.
30
+ * @csspart master-toggle - The show/hide button for the master strip (`master-collapsible`).
31
+ * @csspart navigator - The map-style zoom buttons (+ / −) over the top-right corner of the chart (`navigator-controls`).
32
+ * @csspart navigator-button - Each zoom button (`Zoom in`, `Zoom out`) inside the `navigator` control.
33
+ */
34
+ /** Right spacing (px) reserved on the chart under the zoom control: 32px control + 8px offset + 8px gap. */
35
+ const NAV_CONTROL_GUTTER = 48;
20
36
  let NileMasterDetailChart = class NileMasterDetailChart extends NileElement {
21
37
  constructor() {
22
38
  super(...arguments);
@@ -26,6 +42,10 @@ let NileMasterDetailChart = class NileMasterDetailChart extends NileElement {
26
42
  this.resizeObserver = null;
27
43
  this.zoomed = false;
28
44
  this.masterCollapsed = false;
45
+ /** True while a drag-to-pan gesture is moving the window (drives the grabbing cursor). */
46
+ this._panning = false;
47
+ this._drag = null;
48
+ this._dragFrame = 0;
29
49
  this.config = null;
30
50
  this.chartTitle = '';
31
51
  this.chartSubtitle = '';
@@ -43,6 +63,14 @@ let NileMasterDetailChart = class NileMasterDetailChart extends NileElement {
43
63
  this.masterType = 'area';
44
64
  this.masterOnly = false;
45
65
  this.masterCollapsible = false;
66
+ this.navigatorControls = false;
67
+ /**
68
+ * Opening window when `navigator-controls` is on and no `selection-min` / `selection-max` is set:
69
+ * a fraction of the range (`0.25`) or, on a datetime axis, a duration (`30m`, `12h`, `7d`, `2w`),
70
+ * ending at the latest data. Empty opens on the full range.
71
+ */
72
+ this.navigatorDefaultWindow = '';
73
+ this._window = null;
46
74
  this.height = '600px';
47
75
  this.masterHeight = 100;
48
76
  this.xAxisType = 'datetime';
@@ -85,6 +113,12 @@ let NileMasterDetailChart = class NileMasterDetailChart extends NileElement {
85
113
  this.masterChart?.reflow();
86
114
  }
87
115
  }
116
+ /** Re-renders only when the control bar is shown, so plain charts skip the extra update. */
117
+ _trackWindow(min, max) {
118
+ this._window = { min, max };
119
+ if (this.navigatorControls)
120
+ this.requestUpdate();
121
+ }
88
122
  _cssLength(val) {
89
123
  return typeof val === 'number'
90
124
  ? (Number.isFinite(val) ? `${val}px` : '')
@@ -168,6 +202,8 @@ let NileMasterDetailChart = class NileMasterDetailChart extends NileElement {
168
202
  'yAxisMax',
169
203
  'selectionMin',
170
204
  'selectionMax',
205
+ 'navigatorDefaultWindow',
206
+ 'navigatorControls',
171
207
  'detailTitle',
172
208
  'masterTitle',
173
209
  'maskFill',
@@ -306,8 +342,44 @@ let NileMasterDetailChart = class NileMasterDetailChart extends NileElement {
306
342
  const hi = nearest(max);
307
343
  return { min: Math.min(lo, hi), max: Math.max(lo, hi) };
308
344
  }
345
+ /** Opening window from `navigatorDefaultWindow`, snapped to data points; `null` means use the full range. */
346
+ _defaultWindow() {
347
+ const v = String(this.navigatorDefaultWindow ?? '').trim();
348
+ const xs = this._allXs();
349
+ if (!v || xs.length < 2)
350
+ return null;
351
+ const dataMin = xs[0];
352
+ const dataMax = xs[xs.length - 1];
353
+ let min = null;
354
+ const fraction = Number(v);
355
+ if (Number.isFinite(fraction)) {
356
+ if (fraction > 0 && fraction < 1) {
357
+ const sMin = this._toScale(dataMin);
358
+ const sMax = this._toScale(dataMax);
359
+ min = this._fromScale(sMax - (sMax - sMin) * fraction);
360
+ }
361
+ }
362
+ else {
363
+ const m = /^(\d+(?:\.\d+)?)\s*(m|h|d|w)$/i.exec(v);
364
+ if (m && this.xAxisType === 'datetime') {
365
+ const unit = { m: 6e4, h: 36e5, d: 864e5, w: 6048e5 };
366
+ const width = Number(m[1]) * unit[m[2].toLowerCase()];
367
+ if (width > 0 && width < dataMax - dataMin)
368
+ min = dataMax - width;
369
+ }
370
+ }
371
+ if (min == null)
372
+ return null;
373
+ const w = this._snapWindow(min, dataMax);
374
+ return w ? { min: xs[w.lo], max: xs[w.hi] } : null;
375
+ }
309
376
  defaultSelection() {
310
377
  const { dataMin, dataMax } = this.dataExtremes();
378
+ if (this.navigatorControls && this.selectionMin == null && this.selectionMax == null) {
379
+ const win = this._defaultWindow();
380
+ if (win)
381
+ return win;
382
+ }
311
383
  return {
312
384
  min: this.selectionMin ?? dataMin,
313
385
  max: this.selectionMax ?? dataMax,
@@ -332,7 +404,8 @@ let NileMasterDetailChart = class NileMasterDetailChart extends NileElement {
332
404
  shared: true,
333
405
  };
334
406
  const merged = deepMerge({
335
- chart: { type: this.detailType, reflow: true },
407
+ // Keep the plot clear of the + / − zoom control in the top-right corner.
408
+ chart: { type: this.detailType, reflow: true, spacingRight: this.navigatorControls ? NAV_CONTROL_GUTTER : undefined },
336
409
  title: { text: this.detailTitle || undefined },
337
410
  xAxis: {
338
411
  type: this.xAxisType,
@@ -381,6 +454,7 @@ let NileMasterDetailChart = class NileMasterDetailChart extends NileElement {
381
454
  // masterOnly fills the container, so its auto margins already reserve
382
455
  // room — leave that mode untouched.
383
456
  marginBottom: mo ? undefined : 30,
457
+ spacingRight: mo && this.navigatorControls ? NAV_CONTROL_GUTTER : undefined,
384
458
  zoomType: 'x',
385
459
  events: {
386
460
  selection(event) {
@@ -393,6 +467,7 @@ let NileMasterDetailChart = class NileMasterDetailChart extends NileElement {
393
467
  : { min: ext.min, max: ext.max };
394
468
  const win = self._zoomWindow(sel.min, sel.max);
395
469
  self.masterChart?.xAxis[0].setExtremes(win.min, win.max);
470
+ self._trackWindow(sel.min, sel.max);
396
471
  self.setZoomed(true);
397
472
  self.emit('nile-chart-selection', sel);
398
473
  return false;
@@ -466,6 +541,7 @@ let NileMasterDetailChart = class NileMasterDetailChart extends NileElement {
466
541
  if (!this.masterChart)
467
542
  return;
468
543
  const { dataMin, dataMax } = this.dataExtremes();
544
+ this._trackWindow(dataMin, dataMax);
469
545
  if (this.masterOnly) {
470
546
  this.masterChart.xAxis[0].setExtremes(dataMin, dataMax);
471
547
  }
@@ -480,6 +556,7 @@ let NileMasterDetailChart = class NileMasterDetailChart extends NileElement {
480
556
  this.emit('nile-chart-selection', { min: dataMin, max: dataMax });
481
557
  }
482
558
  applySelection(min, max) {
559
+ this._trackWindow(min, max);
483
560
  if (!this.masterChart)
484
561
  return;
485
562
  if (this.masterOnly) {
@@ -505,6 +582,209 @@ let NileMasterDetailChart = class NileMasterDetailChart extends NileElement {
505
582
  if (max < dataMax)
506
583
  xAxis.addPlotBand({ id: 'mask-after', from: max, to: dataMax, color: this.maskFill });
507
584
  }
585
+ /** Pan and zoom work on the log scale when the x-axis is logarithmic. */
586
+ get _isLogX() {
587
+ const xs = this._allXs();
588
+ return this.xAxisType === 'logarithmic' && xs.length > 0 && xs[0] > 0;
589
+ }
590
+ _toScale(v) {
591
+ return this._isLogX ? Math.log10(v) : v;
592
+ }
593
+ _fromScale(v) {
594
+ return this._isLogX ? Math.pow(10, v) : v;
595
+ }
596
+ /** Index of the data x nearest to `v` on the axis scale; `xs` is sorted. */
597
+ _nearestIndex(xs, v) {
598
+ let lo = 0;
599
+ let hi = xs.length - 1;
600
+ while (lo < hi) {
601
+ const mid = (lo + hi) >> 1;
602
+ if (xs[mid] < v)
603
+ lo = mid + 1;
604
+ else
605
+ hi = mid;
606
+ }
607
+ const sv = this._toScale(v);
608
+ if (lo > 0 && Math.abs(this._toScale(xs[lo - 1]) - sv) <= Math.abs(this._toScale(xs[lo]) - sv))
609
+ return lo - 1;
610
+ return lo;
611
+ }
612
+ /** Clamps `[min, max]` into the data range keeping its width, then snaps both edges to data points. */
613
+ _snapWindow(min, max) {
614
+ const xs = this._allXs();
615
+ if (xs.length < 2)
616
+ return null;
617
+ const sMin = this._toScale(xs[0]);
618
+ const sMax = this._toScale(xs[xs.length - 1]);
619
+ let a = this._toScale(min);
620
+ const width = Math.min(Math.max(this._toScale(max) - a, 0), sMax - sMin);
621
+ if (a < sMin)
622
+ a = sMin;
623
+ if (a + width > sMax)
624
+ a = sMax - width;
625
+ let lo = this._nearestIndex(xs, this._fromScale(a));
626
+ let hi = this._nearestIndex(xs, this._fromScale(a + width));
627
+ if (hi <= lo) {
628
+ if (lo < xs.length - 1)
629
+ hi = lo + 1;
630
+ else
631
+ lo = hi - 1;
632
+ }
633
+ return { lo, hi };
634
+ }
635
+ _windowIndices() {
636
+ const xs = this._allXs();
637
+ if (!this._window || xs.length < 2)
638
+ return null;
639
+ return { lo: this._nearestIndex(xs, this._window.min), hi: this._nearestIndex(xs, this._window.max) };
640
+ }
641
+ _applyWindow(lo, hi) {
642
+ const xs = this._allXs();
643
+ const min = xs[lo];
644
+ const max = xs[hi];
645
+ if (this.masterOnly) {
646
+ this._trackWindow(min, max);
647
+ this.masterChart?.xAxis[0].setExtremes(min, max);
648
+ }
649
+ else {
650
+ this.applySelection(min, max);
651
+ }
652
+ this.setZoomed(lo > 0 || hi < xs.length - 1);
653
+ this.emit('nile-chart-selection', { min, max });
654
+ }
655
+ _setWindow(min, max) {
656
+ const w = this._snapWindow(min, max);
657
+ if (w)
658
+ this._applyWindow(w.lo, w.hi);
659
+ }
660
+ /** Move the window by 25% of its width toward the start (`-1`) or end (`1`), at least one data point. */
661
+ panBy(direction) {
662
+ const cur = this._windowIndices();
663
+ if (!cur)
664
+ return;
665
+ const xs = this._allXs();
666
+ const a = this._toScale(xs[cur.lo]);
667
+ const b = this._toScale(xs[cur.hi]);
668
+ const d = (b - a) * 0.25 * direction;
669
+ let w = this._snapWindow(this._fromScale(a + d), this._fromScale(b + d));
670
+ if (w.lo === cur.lo && w.hi === cur.hi && cur.lo + direction >= 0 && cur.hi + direction <= xs.length - 1) {
671
+ w = { lo: cur.lo + direction, hi: cur.hi + direction };
672
+ }
673
+ this._applyWindow(w.lo, w.hi);
674
+ }
675
+ /** Scale the window around its centre: `0.5` zooms in, `2` zooms out; at least one data point per step. */
676
+ zoomBy(factor) {
677
+ const cur = this._windowIndices();
678
+ if (!cur)
679
+ return;
680
+ const xs = this._allXs();
681
+ const a = this._toScale(xs[cur.lo]);
682
+ const b = this._toScale(xs[cur.hi]);
683
+ const c = (a + b) / 2;
684
+ const half = ((b - a) * factor) / 2;
685
+ let w = this._snapWindow(this._fromScale(c - half), this._fromScale(c + half));
686
+ if (w.lo === cur.lo && w.hi === cur.hi) {
687
+ if (factor < 1 && cur.hi - cur.lo > 1)
688
+ w = { lo: cur.hi - cur.lo > 2 ? cur.lo + 1 : cur.lo, hi: cur.hi - 1 };
689
+ else if (factor > 1)
690
+ w = { lo: Math.max(0, cur.lo - 1), hi: Math.min(xs.length - 1, cur.hi + 1) };
691
+ }
692
+ this._applyWindow(w.lo, w.hi);
693
+ }
694
+ get _navState() {
695
+ const xs = this._allXs();
696
+ const last = xs.length - 1;
697
+ const cur = this._windowIndices() ?? { lo: 0, hi: last };
698
+ return {
699
+ full: cur.lo <= 0 && cur.hi >= last,
700
+ atMinWidth: cur.hi - cur.lo <= 1,
701
+ };
702
+ }
703
+ /** Drag-to-pan on the detail pane: the window follows the pointer, keeping its width. */
704
+ get _canDragPan() {
705
+ return this.navigatorControls && !this.masterOnly && this._allXs().length >= 2;
706
+ }
707
+ _onPanStart(e) {
708
+ if (!this._canDragPan || e.button !== 0 || !e.isPrimary || this._navState.full)
709
+ return;
710
+ const cur = this._windowIndices();
711
+ const len = this.detailChart?.xAxis[0]?.len;
712
+ if (!cur || !len)
713
+ return;
714
+ const xs = this._allXs();
715
+ const a = this._toScale(xs[cur.lo]);
716
+ const b = this._toScale(xs[cur.hi]);
717
+ this._drag = { id: e.pointerId, x: e.clientX, a, b, perPx: (b - a) / len, active: false };
718
+ }
719
+ _onPanMove(e) {
720
+ const d = this._drag;
721
+ if (!d || e.pointerId !== d.id)
722
+ return;
723
+ const dx = e.clientX - d.x;
724
+ if (!d.active) {
725
+ // A small threshold keeps plain clicks / taps on points working.
726
+ if (Math.abs(dx) < 4)
727
+ return;
728
+ d.active = true;
729
+ this._panning = true;
730
+ try {
731
+ e.currentTarget.setPointerCapture(e.pointerId);
732
+ }
733
+ catch {
734
+ // Pointer already released (or synthetic) — panning still follows move events.
735
+ }
736
+ }
737
+ e.preventDefault();
738
+ const shift = -dx * d.perPx;
739
+ cancelAnimationFrame(this._dragFrame);
740
+ this._dragFrame = requestAnimationFrame(() => this._setWindow(this._fromScale(d.a + shift), this._fromScale(d.b + shift)));
741
+ }
742
+ _onPanEnd(e) {
743
+ if (!this._drag || e.pointerId !== this._drag.id)
744
+ return;
745
+ this._drag = null;
746
+ this._panning = false;
747
+ }
748
+ /** Arrow keys pan, + / − zoom, when the chart pane has focus. */
749
+ _onNavKeydown(e) {
750
+ if (!this.navigatorControls || e.altKey || e.ctrlKey || e.metaKey)
751
+ return;
752
+ const key = e.key;
753
+ if (key === 'ArrowLeft')
754
+ this.panBy(-1);
755
+ else if (key === 'ArrowRight')
756
+ this.panBy(1);
757
+ else if (key === '+' || key === '=')
758
+ this.zoomBy(0.5);
759
+ else if (key === '-' || key === '_')
760
+ this.zoomBy(2);
761
+ else
762
+ return;
763
+ e.preventDefault();
764
+ }
765
+ /**
766
+ * A native button inside one solid, joined control: disabled stays opaque (only the icon dims), so the
767
+ * chart never shows through, and the cluster keeps a single border with a hairline divider.
768
+ */
769
+ _navButton(icon, label, disabled, onClick) {
770
+ return html `<button
771
+ type="button"
772
+ class="navigator-button"
773
+ part="navigator-button"
774
+ aria-label=${label}
775
+ title=${label}
776
+ ?disabled=${disabled}
777
+ @click=${onClick}
778
+ ><nile-glyph name=${icon} method="stroke" size="16" color="currentColor"></nile-glyph></button>`;
779
+ }
780
+ /** Map-style + / − zoom buttons, overlaid on the top-right corner of the chart. */
781
+ _renderZoomControls() {
782
+ const nav = this._navState;
783
+ return html `<div class="navigator" part="navigator" role="toolbar" aria-label="Chart zoom" aria-orientation="vertical">
784
+ ${this._navButton('ng-plus', 'Zoom in', nav.atMinWidth, () => this.zoomBy(0.5))}
785
+ ${this._navButton('ng-minus', 'Zoom out', nav.full, () => this.zoomBy(2))}
786
+ </div>`;
787
+ }
508
788
  async initCharts() {
509
789
  if (this.loading)
510
790
  return;
@@ -550,10 +830,30 @@ let NileMasterDetailChart = class NileMasterDetailChart extends NileElement {
550
830
  if (!this._typesValid)
551
831
  return nothing;
552
832
  const masterHidden = !this.masterOnly && this.masterCollapsed;
833
+ const showNav = this.navigatorControls && this._allXs().length >= 2;
834
+ const pannable = showNav && !this.masterOnly && !this._navState.full;
835
+ const navLabel = 'Chart. Arrow keys pan, plus and minus zoom.';
836
+ const detailClasses = [
837
+ 'detail-container',
838
+ masterHidden ? 'detail-container--grow' : '',
839
+ pannable ? 'detail-container--pannable' : '',
840
+ this._panning ? 'detail-container--panning' : '',
841
+ ].join(' ');
553
842
  return html `<div class="chart-stack">
554
843
  ${this.masterOnly
555
844
  ? null
556
- : html `<div class="detail-container ${masterHidden ? 'detail-container--grow' : ''}" part="detail-container"></div>
845
+ : html `<div
846
+ class=${detailClasses}
847
+ part="detail-container"
848
+ tabindex=${showNav ? '0' : nothing}
849
+ role=${showNav ? 'region' : nothing}
850
+ aria-label=${showNav ? navLabel : nothing}
851
+ @keydown=${this._onNavKeydown}
852
+ @pointerdown=${this._onPanStart}
853
+ @pointermove=${this._onPanMove}
854
+ @pointerup=${this._onPanEnd}
855
+ @pointercancel=${this._onPanEnd}
856
+ ></div>
557
857
  ${this.masterCollapsible
558
858
  ? html `<nile-lite-tooltip content=${this.masterCollapsed ? 'Show master' : 'Hide master'} placement="top">
559
859
  <button
@@ -568,7 +868,15 @@ let NileMasterDetailChart = class NileMasterDetailChart extends NileElement {
568
868
  </button>
569
869
  </nile-lite-tooltip>`
570
870
  : null}`}
571
- <div class="master-container ${masterHidden ? 'master-container--collapsed' : ''}" part="master-container"></div>
871
+ <div
872
+ class="master-container ${masterHidden ? 'master-container--collapsed' : ''}"
873
+ part="master-container"
874
+ tabindex=${showNav && this.masterOnly ? '0' : nothing}
875
+ role=${showNav && this.masterOnly ? 'region' : nothing}
876
+ aria-label=${showNav && this.masterOnly ? navLabel : nothing}
877
+ @keydown=${this.masterOnly ? this._onNavKeydown : nothing}
878
+ ></div>
879
+ ${showNav ? this._renderZoomControls() : nothing}
572
880
  </div>`;
573
881
  }
574
882
  };
@@ -582,6 +890,9 @@ __decorate([
582
890
  __decorate([
583
891
  state()
584
892
  ], NileMasterDetailChart.prototype, "masterCollapsed", void 0);
893
+ __decorate([
894
+ state()
895
+ ], NileMasterDetailChart.prototype, "_panning", void 0);
585
896
  __decorate([
586
897
  property({ type: Object })
587
898
  ], NileMasterDetailChart.prototype, "config", void 0);
@@ -618,6 +929,12 @@ __decorate([
618
929
  __decorate([
619
930
  property({ type: Boolean, attribute: 'master-collapsible' })
620
931
  ], NileMasterDetailChart.prototype, "masterCollapsible", void 0);
932
+ __decorate([
933
+ property({ type: Boolean, reflect: true, attribute: 'navigator-controls' })
934
+ ], NileMasterDetailChart.prototype, "navigatorControls", void 0);
935
+ __decorate([
936
+ property({ type: String, attribute: 'navigator-default-window' })
937
+ ], NileMasterDetailChart.prototype, "navigatorDefaultWindow", void 0);
621
938
  __decorate([
622
939
  property({ type: String })
623
940
  ], NileMasterDetailChart.prototype, "height", void 0);
@@ -89,7 +89,24 @@ function makeChart(options) {
89
89
  };
90
90
  return chart;
91
91
  }
92
- const makeFakeHC = () => ({ chart: (_c, options) => makeChart(options), setOptions() { } });
92
+ // Minimal Highcharts.dateFormat stand-in (UTC) so the navigator caption, which
93
+ // formats datetime ranges through `this._hc.dateFormat(...)`, has something to call.
94
+ function fakeDateFormat(format, timestamp) {
95
+ const d = new Date(timestamp);
96
+ const pad = (n) => String(n).padStart(2, '0');
97
+ return format
98
+ .replace(/%Y/g, String(d.getUTCFullYear()))
99
+ .replace(/%m/g, pad(d.getUTCMonth() + 1))
100
+ .replace(/%d/g, pad(d.getUTCDate()))
101
+ .replace(/%H/g, pad(d.getUTCHours()))
102
+ .replace(/%M/g, pad(d.getUTCMinutes()))
103
+ .replace(/%S/g, pad(d.getUTCSeconds()));
104
+ }
105
+ const makeFakeHC = () => ({
106
+ chart: (_c, options) => makeChart(options),
107
+ setOptions() { },
108
+ dateFormat: fakeDateFormat,
109
+ });
93
110
  // --- mount helper (injects the fake before first render) ---------------------
94
111
  const mounted = [];
95
112
  async function mount(props) {
@@ -258,5 +275,382 @@ describe('NileChart → master-detail passthrough', () => {
258
275
  expect(inner.series).to.deep.equal(SERIES);
259
276
  expect(inner.stacking).to.equal('normal');
260
277
  });
278
+ it('27. passes navigatorControls and navigatorDefaultWindow down to the inner chart', async () => {
279
+ const el = await fixture(html `<nile-chart style="display:block;width:600px;height:400px"></nile-chart>`);
280
+ el.config = {
281
+ chart: { type: 'master-detail', series: SERIES, navigatorControls: true, navigatorDefaultWindow: '7d' },
282
+ };
283
+ await el.updateComplete;
284
+ await el.updateComplete;
285
+ const inner = el.shadowRoot.querySelector('nile-master-detail-chart');
286
+ expect(inner, 'inner master-detail chart should render').to.exist;
287
+ expect(inner.navigatorControls).to.be.true;
288
+ expect(inner.navigatorDefaultWindow).to.equal('7d');
289
+ });
290
+ });
291
+ // --- navigator controls (spec: nile-master-detail-chart-navigator.md) --------
292
+ //
293
+ // Evenly spaced datetime data: 9 points one day apart, so every window edge the
294
+ // controls produce lands on an exact, predictable timestamp.
295
+ const DAY = 86400000;
296
+ const T0 = Date.UTC(2026, 8, 25, 3, 11, 21); // 2026-09-25 03:11:21 UTC
297
+ const DT_DATA = Array.from({ length: 9 }, (_, i) => ({ x: T0 + i * DAY, y: i }));
298
+ const DT_MIN = T0;
299
+ const DT_MAX = T0 + 8 * DAY; // full span = 8 days = 8 * pointStep
300
+ const DT_SERIES = [
301
+ { name: 'Clean', data: DT_DATA, color: '#0000ff' },
302
+ { name: 'Needs attention', data: DT_DATA.map((p) => ({ x: p.x, y: p.y * 2 })), color: '#ff0000' },
303
+ ];
304
+ const nav = (el) => el;
305
+ const navigatorPart = (el) => el.shadowRoot.querySelector('[part~="navigator"]');
306
+ const btn = (el, label) => el.shadowRoot.querySelector(`[part~="navigator"] [aria-label="${label}"]`);
307
+ const detailPane = (el) => el.shadowRoot.querySelector('.detail-container');
308
+ /** Drag on the detail pane by `dx` px; the fake x-axis is given a 400px plot width. */
309
+ async function dragDetail(el, dx) {
310
+ host(el).detailChart.xAxis[0].len = 400;
311
+ const pane = detailPane(el);
312
+ const opts = { pointerId: 1, isPrimary: true, button: 0, bubbles: true, composed: true };
313
+ pane.dispatchEvent(new PointerEvent('pointerdown', { ...opts, clientX: 200 }));
314
+ pane.dispatchEvent(new PointerEvent('pointermove', { ...opts, clientX: 200 + dx / 2 }));
315
+ pane.dispatchEvent(new PointerEvent('pointermove', { ...opts, clientX: 200 + dx }));
316
+ await new Promise((r) => requestAnimationFrame(() => r(null)));
317
+ pane.dispatchEvent(new PointerEvent('pointerup', { ...opts, clientX: 200 + dx }));
318
+ await el.updateComplete;
319
+ }
320
+ // Every control step goes through applySelection / setExtremes and re-emits
321
+ // `nile-chart-selection { min, max }`. Collect them after mount (the init-time
322
+ // emission has already fired by then).
323
+ function selectionSpy(el) {
324
+ const seen = [];
325
+ el.addEventListener('nile-chart-selection', (e) => seen.push(e.detail));
326
+ return seen;
327
+ }
328
+ const isDisabled = (node) => !!node && (node.hasAttribute('disabled') || node.disabled === true);
329
+ describe('NileMasterDetailChart — navigator controls', () => {
330
+ it('28. renders no control bar without navigator-controls', async () => {
331
+ const el = await mount({ series: DT_SERIES });
332
+ expect(navigatorPart(el)).to.be.null;
333
+ });
334
+ it('29. renders map-style + / − zoom only (no slider, no pan buttons) with navigator-controls', async () => {
335
+ const el = await mount({ series: DT_SERIES, navigatorControls: true });
336
+ expect(navigatorPart(el)).to.not.be.null;
337
+ expect(btn(el, 'Zoom in')).to.not.be.null;
338
+ expect(btn(el, 'Zoom out')).to.not.be.null;
339
+ expect(btn(el, 'Pan back')).to.be.null;
340
+ expect(btn(el, 'Pan forward')).to.be.null;
341
+ expect(el.shadowRoot.querySelector('nile-slider')).to.be.null;
342
+ // Zoom in first, like a map control.
343
+ const labels = [...navigatorPart(el).querySelectorAll('[aria-label]')].map((b) => b.getAttribute('aria-label'));
344
+ expect(labels).to.deep.equal(['Zoom in', 'Zoom out']);
345
+ });
346
+ it('30. renders the control bar in master-only mode', async () => {
347
+ const el = await mount({ series: DT_SERIES, navigatorControls: true, masterOnly: true });
348
+ expect(navigatorPart(el)).to.not.be.null;
349
+ });
350
+ it('31. renders no range caption or hint — the chart only shows the zoom control', async () => {
351
+ const el = await mount({ series: DT_SERIES, navigatorControls: true, navigatorHint: 'blue = clean' });
352
+ expect(navigatorPart(el)).to.not.be.null;
353
+ expect(el.shadowRoot.querySelector('[part~="navigator-caption"]'), 'caption').to.be.null;
354
+ expect(el.shadowRoot.querySelector('[part~="navigator-hint"]'), 'hint').to.be.null;
355
+ expect(el.shadowRoot.querySelector('[aria-live]'), 'no live region').to.be.null;
356
+ expect(el.shadowRoot.textContent.trim(), 'no text in the shadow root').to.equal('');
357
+ });
358
+ it('32. navigator-controls reflects to the attribute', async () => {
359
+ const el = await mount({ series: DT_SERIES, navigatorControls: true });
360
+ expect(el.hasAttribute('navigator-controls')).to.be.true;
361
+ });
362
+ it('33. at full range zoom out is disabled, zoom in enabled, and the chart is not draggable', async () => {
363
+ const el = await mount({ series: DT_SERIES, navigatorControls: true });
364
+ expect(isDisabled(btn(el, 'Zoom out')), 'zoom out').to.be.true;
365
+ expect(isDisabled(btn(el, 'Zoom in')), 'zoom in').to.be.false;
366
+ expect(detailPane(el).classList.contains('detail-container--pannable')).to.be.false;
367
+ });
368
+ it('34. zoom in halves the window around its centre and fires nile-chart-selection', async () => {
369
+ const el = await mount({ series: DT_SERIES, navigatorControls: true });
370
+ const seen = selectionSpy(el);
371
+ nav(el).zoomBy(0.5);
372
+ await el.updateComplete;
373
+ // centre = T0 + 4d, new width = 4d → [T0+2d, T0+6d]
374
+ expect(seen[seen.length - 1]).to.deep.equal({ min: T0 + 2 * DAY, max: T0 + 6 * DAY });
375
+ });
376
+ it('35. the zoom-in button halves the window', async () => {
377
+ const el = await mount({ series: DT_SERIES, navigatorControls: true });
378
+ const seen = selectionSpy(el);
379
+ btn(el, 'Zoom in').click();
380
+ await el.updateComplete;
381
+ expect(seen[seen.length - 1]).to.deep.equal({ min: T0 + 2 * DAY, max: T0 + 6 * DAY });
382
+ });
383
+ it('36. zoom out doubles the window toward the data range', async () => {
384
+ const el = await mount({ series: DT_SERIES, navigatorControls: true });
385
+ nav(el).zoomBy(0.5); // → width 4d [T0+2d, T0+6d]
386
+ await el.updateComplete;
387
+ const seen = selectionSpy(el);
388
+ nav(el).zoomBy(2); // double → width 8d, clamped to full range
389
+ await el.updateComplete;
390
+ expect(seen[seen.length - 1]).to.deep.equal({ min: DT_MIN, max: DT_MAX });
391
+ });
392
+ it('37. zoom out is disabled at full range', async () => {
393
+ const el = await mount({ series: DT_SERIES, navigatorControls: true });
394
+ expect(isDisabled(btn(el, 'Zoom out'))).to.be.true;
395
+ });
396
+ it('38. pan forward moves by 25% of the width and preserves the width', async () => {
397
+ const el = await mount({ series: DT_SERIES, navigatorControls: true });
398
+ nav(el).zoomBy(0.5); // width 4d → [T0+2d, T0+6d]
399
+ await el.updateComplete;
400
+ const seen = selectionSpy(el);
401
+ nav(el).panBy(1); // +25% of 4d = +1d → [T0+3d, T0+7d]
402
+ await el.updateComplete;
403
+ const w = seen[seen.length - 1];
404
+ expect(w).to.deep.equal({ min: T0 + 3 * DAY, max: T0 + 7 * DAY });
405
+ expect(w.max - w.min).to.equal(4 * DAY);
406
+ });
407
+ it('39. pan back moves the window toward the start, same width', async () => {
408
+ const el = await mount({ series: DT_SERIES, navigatorControls: true });
409
+ nav(el).zoomBy(0.5); // [T0+2d, T0+6d]
410
+ await el.updateComplete;
411
+ const seen = selectionSpy(el);
412
+ nav(el).panBy(-1); // -1d → [T0+1d, T0+5d]
413
+ await el.updateComplete;
414
+ expect(seen[seen.length - 1]).to.deep.equal({ min: T0 + 1 * DAY, max: T0 + 5 * DAY });
415
+ });
416
+ it('40. pan forward clamps at the data end, preserving the width', async () => {
417
+ const el = await mount({ series: DT_SERIES, navigatorControls: true });
418
+ nav(el).zoomBy(0.5); // width 4d → [T0+2d, T0+6d]
419
+ await el.updateComplete;
420
+ const seen = selectionSpy(el);
421
+ nav(el).panBy(1); // [T0+3d, T0+7d]
422
+ nav(el).panBy(1); // [T0+4d, T0+8d] (hits end)
423
+ nav(el).panBy(1); // clamped, stays [T0+4d, T0+8d]
424
+ await el.updateComplete;
425
+ const w = seen[seen.length - 1];
426
+ expect(w).to.deep.equal({ min: T0 + 4 * DAY, max: DT_MAX });
427
+ expect(w.max - w.min).to.equal(4 * DAY);
428
+ });
429
+ it('41. once zoomed in the detail pane becomes draggable', async () => {
430
+ const el = await mount({ series: DT_SERIES, navigatorControls: true });
431
+ nav(el).zoomBy(0.5);
432
+ await el.updateComplete;
433
+ expect(detailPane(el).classList.contains('detail-container--pannable')).to.be.true;
434
+ });
435
+ it('42. zoom in stops at one point step and disables the zoom-in button', async () => {
436
+ const el = await mount({ series: DT_SERIES, navigatorControls: true });
437
+ // 8d → 4d → 2d → 1d (= pointStep)
438
+ nav(el).zoomBy(0.5);
439
+ nav(el).zoomBy(0.5);
440
+ nav(el).zoomBy(0.5);
441
+ await el.updateComplete;
442
+ const atStep = nav(el)._window;
443
+ expect(atStep.max - atStep.min).to.equal(DAY);
444
+ expect(isDisabled(btn(el, 'Zoom in'))).to.be.true;
445
+ // Vice versa of 43f: now + is the greyed one and − is the normal one.
446
+ const zin = btn(el, 'Zoom in');
447
+ const zout = btn(el, 'Zoom out');
448
+ expect(isDisabled(zout), 'zoom out enabled').to.be.false;
449
+ expect(getComputedStyle(zin).backgroundColor, 'disabled + fill').to.not.equal(getComputedStyle(zout).backgroundColor);
450
+ expect(getComputedStyle(zin).color, 'disabled + icon colour').to.not.equal(getComputedStyle(zout).color);
451
+ // A further zoom-in must not shrink below the point step.
452
+ const seen = selectionSpy(el);
453
+ nav(el).zoomBy(0.5);
454
+ await el.updateComplete;
455
+ const after = nav(el)._window;
456
+ expect(after.max - after.min).to.equal(DAY);
457
+ if (seen.length)
458
+ expect(seen[seen.length - 1].max - seen[seen.length - 1].min).to.equal(DAY);
459
+ });
460
+ it('43. dragging the detail pane pans like a map, keeping the width', async () => {
461
+ const el = await mount({ series: DT_SERIES, navigatorControls: true });
462
+ nav(el).zoomBy(0.5); // [T0+2d, T0+6d]; 4d over 400px = 1d per 100px
463
+ await el.updateComplete;
464
+ const seen = selectionSpy(el);
465
+ await dragDetail(el, 100); // drag right → content follows → earlier window
466
+ expect(seen[seen.length - 1]).to.deep.equal({ min: T0 + 1 * DAY, max: T0 + 5 * DAY });
467
+ await dragDetail(el, -200); // drag left → later window
468
+ expect(nav(el)._window).to.deep.equal({ min: T0 + 3 * DAY, max: T0 + 7 * DAY });
469
+ });
470
+ it('43b. a drag clamps at the data edge and a tiny move does nothing', async () => {
471
+ const el = await mount({ series: DT_SERIES, navigatorControls: true });
472
+ nav(el).zoomBy(0.5);
473
+ await el.updateComplete;
474
+ await dragDetail(el, 2); // under the 4px threshold
475
+ expect(nav(el)._window).to.deep.equal({ min: T0 + 2 * DAY, max: T0 + 6 * DAY });
476
+ await dragDetail(el, -5000);
477
+ expect(nav(el)._window).to.deep.equal({ min: T0 + 4 * DAY, max: DT_MAX });
478
+ });
479
+ it('43c. dragging does nothing at full range', async () => {
480
+ const el = await mount({ series: DT_SERIES, navigatorControls: true });
481
+ const seen = selectionSpy(el);
482
+ await dragDetail(el, 100);
483
+ expect(seen).to.have.length(0);
484
+ });
485
+ it('43d. keyboard on the focused chart: arrows pan, + / − zoom', async () => {
486
+ const el = await mount({ series: DT_SERIES, navigatorControls: true });
487
+ const pane = detailPane(el);
488
+ expect(pane.getAttribute('tabindex')).to.equal('0');
489
+ const key = (k) => pane.dispatchEvent(new KeyboardEvent('keydown', { key: k, bubbles: true, cancelable: true }));
490
+ key('+');
491
+ await el.updateComplete;
492
+ expect(nav(el)._window).to.deep.equal({ min: T0 + 2 * DAY, max: T0 + 6 * DAY });
493
+ key('ArrowRight');
494
+ await el.updateComplete;
495
+ expect(nav(el)._window).to.deep.equal({ min: T0 + 3 * DAY, max: T0 + 7 * DAY });
496
+ key('ArrowLeft');
497
+ key('-');
498
+ await el.updateComplete;
499
+ expect(nav(el)._window).to.deep.equal({ min: DT_MIN, max: DT_MAX });
500
+ });
501
+ it('43f. the chart reserves right spacing for the zoom control, and the buttons are native and opaque', async () => {
502
+ const plain = await mount({ series: DT_SERIES });
503
+ expect(detailOpts(plain).chart.spacingRight).to.be.undefined;
504
+ const el = await mount({ series: DT_SERIES, navigatorControls: true });
505
+ expect(detailOpts(el).chart.spacingRight).to.equal(48);
506
+ const only = await mount({ series: DT_SERIES, navigatorControls: true, masterOnly: true });
507
+ expect(masterOpts(only).chart.spacingRight).to.equal(48);
508
+ const out = btn(el, 'Zoom out'); // disabled at full range
509
+ expect(out.tagName).to.equal('BUTTON');
510
+ expect(getComputedStyle(out).opacity).to.equal('1');
511
+ expect(getComputedStyle(navigatorPart(el)).backgroundColor).to.not.equal('rgba(0, 0, 0, 0)');
512
+ // Disabled zoom-out is greyed: its fill differs from the enabled zoom-in's.
513
+ const inBtn = btn(el, 'Zoom in');
514
+ expect(getComputedStyle(out).backgroundColor, 'disabled fill').to.not.equal(getComputedStyle(inBtn).backgroundColor);
515
+ // Icons follow their button's colour (no fixed glyph colour), so the disabled icon greys out too.
516
+ for (const b of [inBtn, out])
517
+ expect(b.querySelector('nile-glyph').getAttribute('color')).to.equal('currentColor');
518
+ expect(getComputedStyle(out).color, 'disabled icon colour').to.not.equal(getComputedStyle(inBtn).color);
519
+ });
520
+ it('43e. without navigator-controls the chart is not focusable and keys do nothing', async () => {
521
+ const el = await mount({ series: DT_SERIES });
522
+ const pane = detailPane(el);
523
+ expect(pane.hasAttribute('tabindex')).to.be.false;
524
+ const seen = selectionSpy(el);
525
+ pane.dispatchEvent(new KeyboardEvent('keydown', { key: '+', bubbles: true }));
526
+ expect(seen).to.have.length(0);
527
+ });
528
+ it('44. resetZoom restores the full window and the controls', async () => {
529
+ const el = await mount({ series: DT_SERIES, navigatorControls: true });
530
+ nav(el).zoomBy(0.5);
531
+ await el.updateComplete;
532
+ const seen = selectionSpy(el);
533
+ el.resetZoom();
534
+ await el.updateComplete;
535
+ expect(seen[seen.length - 1]).to.deep.equal({ min: DT_MIN, max: DT_MAX });
536
+ expect(nav(el)._window).to.deep.equal({ min: DT_MIN, max: DT_MAX });
537
+ // back at full range → zoom out / pan disabled again
538
+ expect(isDisabled(btn(el, 'Zoom out'))).to.be.true;
539
+ });
540
+ it('45. a master drag selection updates the window and the zoom-out state', async () => {
541
+ const el = await mount({ series: DT_SERIES, navigatorControls: true });
542
+ expect(isDisabled(btn(el, 'Zoom out')), 'full range').to.be.true;
543
+ host(el).applySelection(T0 + 1 * DAY, T0 + 5 * DAY);
544
+ await el.updateComplete;
545
+ expect(nav(el)._window).to.deep.equal({ min: T0 + 1 * DAY, max: T0 + 5 * DAY });
546
+ expect(isDisabled(btn(el, 'Zoom out')), 'zoomed').to.be.false;
547
+ });
548
+ it('48. a control step refilters every detail series in master+detail mode', async () => {
549
+ const el = await mount({ series: DT_SERIES, navigatorControls: true });
550
+ nav(el).zoomBy(0.5); // [T0+2d, T0+6d] → points at 2,3,4,5,6 days = 5 per series
551
+ await el.updateComplete;
552
+ expect(detailSeries(el).map(pointCount)).to.deep.equal([5, 5]);
553
+ });
554
+ });
555
+ describe('NileMasterDetailChart — navigator icon buttons', () => {
556
+ it('56. each button shows only an icon and is named by title and aria-label', async () => {
557
+ const el = await mount({ series: DT_SERIES, navigatorControls: true });
558
+ for (const label of ['Zoom in', 'Zoom out']) {
559
+ const b = btn(el, label);
560
+ expect(b, label).to.not.be.null;
561
+ expect(b.getAttribute('title'), label).to.equal(label);
562
+ expect(b.textContent.trim(), label).to.equal('');
563
+ expect(b.querySelector('nile-glyph'), label).to.not.be.null;
564
+ }
565
+ });
566
+ });
567
+ describe('NileMasterDetailChart — navigator default window', () => {
568
+ it('49. a fraction opens on that share of the range, ending at the latest data', async () => {
569
+ const el = await mount({ series: DT_SERIES, navigatorControls: true, navigatorDefaultWindow: '0.25' });
570
+ expect(nav(el)._window).to.deep.equal({ min: DT_MAX - 2 * DAY, max: DT_MAX });
571
+ });
572
+ it('50. a duration opens on that span on a datetime axis', async () => {
573
+ const el = await mount({ series: DT_SERIES, navigatorControls: true, navigatorDefaultWindow: '3d' });
574
+ expect(nav(el)._window).to.deep.equal({ min: DT_MAX - 3 * DAY, max: DT_MAX });
575
+ });
576
+ it('51. zoom out is enabled and the chart is draggable on load', async () => {
577
+ const el = await mount({ series: DT_SERIES, navigatorControls: true, navigatorDefaultWindow: '0.5' });
578
+ expect(isDisabled(btn(el, 'Zoom out')), 'zoom out').to.be.false;
579
+ expect(detailPane(el).classList.contains('detail-container--pannable'), 'pannable').to.be.true;
580
+ });
581
+ it('52. selection-min / selection-max win over the default window', async () => {
582
+ const el = await mount({
583
+ series: DT_SERIES, navigatorControls: true, navigatorDefaultWindow: '0.25',
584
+ selectionMin: T0 + DAY, selectionMax: T0 + 3 * DAY,
585
+ });
586
+ expect(nav(el)._window).to.deep.equal({ min: T0 + DAY, max: T0 + 3 * DAY });
587
+ });
588
+ it('53. is ignored without navigator-controls, and when empty or invalid', async () => {
589
+ for (const props of [
590
+ { navigatorDefaultWindow: '0.25' },
591
+ { navigatorControls: true, navigatorDefaultWindow: '' },
592
+ { navigatorControls: true, navigatorDefaultWindow: 'soon' },
593
+ { navigatorControls: true, navigatorDefaultWindow: '2' },
594
+ { navigatorControls: true, navigatorDefaultWindow: '30d' },
595
+ ]) {
596
+ const el = await mount({ series: DT_SERIES, ...props });
597
+ expect(nav(el)._window, JSON.stringify(props)).to.deep.equal({ min: DT_MIN, max: DT_MAX });
598
+ }
599
+ });
600
+ it('54. a duration is ignored on a non-datetime axis', async () => {
601
+ const el = await mount({ series: DT_SERIES, navigatorControls: true, navigatorDefaultWindow: '3d', xAxisType: 'linear' });
602
+ expect(nav(el)._window).to.deep.equal({ min: DT_MIN, max: DT_MAX });
603
+ });
604
+ it('55. resetZoom returns to the full range', async () => {
605
+ const el = await mount({ series: DT_SERIES, navigatorControls: true, navigatorDefaultWindow: '0.25' });
606
+ el.resetZoom();
607
+ await el.updateComplete;
608
+ expect(nav(el)._window).to.deep.equal({ min: DT_MIN, max: DT_MAX });
609
+ });
610
+ });
611
+ describe('NileMasterDetailChart — navigator snapping, log scale, categories, small data', () => {
612
+ const xsOf = (series) => new Set(series.flatMap((s) => s.data.map((p) => p.x)));
613
+ const EIGHT = [{ name: 'A', data: Array.from({ length: 8 }, (_, i) => ({ x: T0 + i * DAY, y: i })) }];
614
+ it('57. a zoom that lands between points snaps both edges to data points', async () => {
615
+ const el = await mount({ series: EIGHT, navigatorControls: true });
616
+ nav(el).zoomBy(0.5); // centre 3.5d, width 3.5d → 1.75d..5.25d → snaps to 2d..5d
617
+ await el.updateComplete;
618
+ const w = nav(el)._window;
619
+ expect(xsOf(EIGHT).has(w.min) && xsOf(EIGHT).has(w.max), JSON.stringify(w)).to.be.true;
620
+ expect(w).to.deep.equal({ min: T0 + 2 * DAY, max: T0 + 5 * DAY });
621
+ });
622
+ it('58. pan always moves at least one data point', async () => {
623
+ const el = await mount({ series: EIGHT, navigatorControls: true, selectionMin: T0, selectionMax: T0 + DAY });
624
+ nav(el).panBy(1); // 25% of one step would snap back; it moves one point instead
625
+ await el.updateComplete;
626
+ expect(nav(el)._window).to.deep.equal({ min: T0 + DAY, max: T0 + 2 * DAY });
627
+ });
628
+ it('59. a drag that lands between points snaps to data points', async () => {
629
+ const el = await mount({ series: EIGHT, navigatorControls: true, selectionMin: T0, selectionMax: T0 + 2 * DAY });
630
+ await dragDetail(el, -330); // 2d over 400px → shift ≈ 1.65d → snaps to 2d
631
+ expect(nav(el)._window).to.deep.equal({ min: T0 + 2 * DAY, max: T0 + 4 * DAY });
632
+ });
633
+ it('60. the default window snaps to data points', async () => {
634
+ const el = await mount({ series: DT_SERIES, navigatorControls: true, navigatorDefaultWindow: '0.3' });
635
+ expect(nav(el)._window).to.deep.equal({ min: DT_MAX - 2 * DAY, max: DT_MAX }); // 2.4d → 2d
636
+ });
637
+ it('61. on a logarithmic axis pan and zoom work on the log scale', async () => {
638
+ const LOG = [{ name: 'A', data: Array.from({ length: 9 }, (_, i) => ({ x: 10 ** i, y: i })) }];
639
+ const el = await mount({ series: LOG, navigatorControls: true, xAxisType: 'logarithmic' });
640
+ nav(el).zoomBy(0.5); // decades 0..8 → 2..6
641
+ await el.updateComplete;
642
+ expect(nav(el)._window).to.deep.equal({ min: 1e2, max: 1e6 });
643
+ nav(el).panBy(1); // 25% of 4 decades = 1 decade
644
+ await el.updateComplete;
645
+ expect(nav(el)._window).to.deep.equal({ min: 1e3, max: 1e7 });
646
+ });
647
+ it('63. no control bar with fewer than two distinct x values', async () => {
648
+ for (const data of [[], [{ x: T0, y: 1 }], [{ x: T0, y: 1 }, { x: T0, y: 2 }]]) {
649
+ const el = await mount({ data, navigatorControls: true });
650
+ expect(navigatorPart(el), JSON.stringify(data)).to.be.null;
651
+ }
652
+ const two = await mount({ data: [{ x: T0, y: 1 }, { x: T0 + DAY, y: 2 }], navigatorControls: true });
653
+ expect(navigatorPart(two)).to.not.be.null;
654
+ });
261
655
  });
262
656
  //# sourceMappingURL=nile-master-detail-chart.test.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aquera/nile-visualization",
3
- "version": "2.9.47",
3
+ "version": "2.9.49",
4
4
  "description": "A visualization Library for the Nile Design System",
5
5
  "license": "MIT",
6
6
  "author": "Aquera Inc",