@aquera/nile-visualization 2.9.48 → 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 +3 -0
- package/dist/src/internal/types/chart-master-detail-config.type.d.ts +0 -1
- package/dist/src/nile-chart/nile-chart-config.d.ts +0 -1
- package/dist/src/nile-chart/nile-chart.js +0 -1
- package/dist/src/nile-master-detail-chart/nile-master-detail-chart.css.js +57 -24
- package/dist/src/nile-master-detail-chart/nile-master-detail-chart.d.ts +17 -20
- package/dist/src/nile-master-detail-chart/nile-master-detail-chart.js +115 -72
- package/dist/src/nile-master-detail-chart/nile-master-detail-chart.test.js +110 -63
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -36,6 +36,9 @@ 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
|
+
|
|
39
42
|
#### Version 2.9.48 (November 20, 2026)
|
|
40
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)
|
|
41
44
|
|
|
@@ -15,7 +15,6 @@ export interface ChartMasterDetailConfigType {
|
|
|
15
15
|
masterOnly?: boolean;
|
|
16
16
|
masterCollapsible?: boolean;
|
|
17
17
|
navigatorControls?: boolean;
|
|
18
|
-
navigatorHint?: string;
|
|
19
18
|
/** Opening window with navigator controls: a fraction (`0.25`) or a duration (`7d`, `12h`, `30m`, `2w`). */
|
|
20
19
|
navigatorDefaultWindow?: string;
|
|
21
20
|
xAxisType?: MasterDetailXAxisType;
|
|
@@ -423,7 +423,6 @@ export interface NileMasterDetailChartConfig extends NileChartConfigBase {
|
|
|
423
423
|
masterOnly?: boolean;
|
|
424
424
|
masterCollapsible?: boolean;
|
|
425
425
|
navigatorControls?: boolean;
|
|
426
|
-
navigatorHint?: string;
|
|
427
426
|
/** Opening window with navigator controls: a fraction (`0.25`) or a duration (`7d`, `12h`, `30m`, `2w`). */
|
|
428
427
|
navigatorDefaultWindow?: string;
|
|
429
428
|
xAxisType?: 'datetime' | 'linear' | 'logarithmic' | 'category';
|
|
@@ -1643,7 +1643,6 @@ let NileChart = NileChart_1 = class NileChart extends NileElement {
|
|
|
1643
1643
|
.masterOnly=${config.masterOnly ?? false}
|
|
1644
1644
|
.masterCollapsible=${config.masterCollapsible ?? false}
|
|
1645
1645
|
.navigatorControls=${config.navigatorControls ?? false}
|
|
1646
|
-
.navigatorHint=${config.navigatorHint ?? ''}
|
|
1647
1646
|
.navigatorDefaultWindow=${config.navigatorDefaultWindow ?? ''}
|
|
1648
1647
|
.xAxisType=${config.xAxisType ?? 'datetime'}
|
|
1649
1648
|
.xAxisMin=${config.xAxisMin ?? 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,47 +99,79 @@ 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. */
|
|
101
105
|
.navigator {
|
|
102
|
-
|
|
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;
|
|
103
110
|
display: flex;
|
|
104
111
|
flex-direction: column;
|
|
105
|
-
|
|
106
|
-
|
|
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));
|
|
107
118
|
}
|
|
108
119
|
|
|
109
|
-
.navigator-
|
|
120
|
+
.navigator-button {
|
|
110
121
|
display: flex;
|
|
111
|
-
flex-wrap: nowrap;
|
|
112
122
|
align-items: center;
|
|
113
|
-
|
|
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;
|
|
114
134
|
}
|
|
115
135
|
|
|
116
|
-
.navigator-
|
|
117
|
-
|
|
118
|
-
|
|
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));
|
|
119
139
|
}
|
|
120
140
|
|
|
121
|
-
.navigator-button
|
|
122
|
-
|
|
123
|
-
padding-inline: 0;
|
|
124
|
-
justify-content: center;
|
|
141
|
+
.navigator-button:hover:not(:disabled) {
|
|
142
|
+
background: var(--nile-colors-dark-200, var(--ng-colors-bg-secondary-hover));
|
|
125
143
|
}
|
|
126
144
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
margin-inline: calc(
|
|
132
|
-
var(--nile-spacing-lg, var(--ng-spacing-2xl, 24px)) / 2 + var(--nile-spacing-xs, var(--ng-spacing-xs, 4px))
|
|
133
|
-
);
|
|
134
|
-
--nile-slider-width: 100%;
|
|
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;
|
|
135
149
|
}
|
|
136
150
|
|
|
137
|
-
.
|
|
138
|
-
|
|
139
|
-
|
|
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;
|
|
140
156
|
}
|
|
141
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
|
+
}
|
|
142
175
|
|
|
143
176
|
.chart-loading {
|
|
144
177
|
display: flex;
|
|
@@ -21,21 +21,6 @@ export declare const MASTER_DETAIL_SERIES_TYPES: readonly ["area", "line", "spli
|
|
|
21
21
|
export type MasterDetailSeriesType = (typeof MASTER_DETAIL_SERIES_TYPES)[number];
|
|
22
22
|
export declare const MASTER_DETAIL_X_AXIS_TYPES: readonly ["datetime", "linear", "logarithmic", "category"];
|
|
23
23
|
export type MasterDetailXAxisType = (typeof MASTER_DETAIL_X_AXIS_TYPES)[number];
|
|
24
|
-
/**
|
|
25
|
-
* @tag nile-master-detail-chart
|
|
26
|
-
* @summary A detail chart above an overview (master) strip; dragging on the strip zooms the detail.
|
|
27
|
-
*
|
|
28
|
-
* @event nile-chart-ready - Charts are created. `detail: { chart }`
|
|
29
|
-
* @event nile-chart-selection - The visible window changed. `detail: { min, max }`
|
|
30
|
-
* @event nile-master-detail-zoom - Zoomed in or back to the full range. `detail: { zoomed }`
|
|
31
|
-
*
|
|
32
|
-
* @csspart detail-container - The detail chart.
|
|
33
|
-
* @csspart master-container - The master (overview) strip.
|
|
34
|
-
* @csspart master-toggle - The show/hide button for the master strip (`master-collapsible`).
|
|
35
|
-
* @csspart navigator - The control bar under the master strip (`navigator-controls`).
|
|
36
|
-
* @csspart navigator-caption - The range readout in the control bar.
|
|
37
|
-
* @csspart navigator-hint - The hint text after the range readout.
|
|
38
|
-
*/
|
|
39
24
|
export declare class NileMasterDetailChart extends NileElement {
|
|
40
25
|
static styles: CSSResultGroup;
|
|
41
26
|
private _hc;
|
|
@@ -47,6 +32,10 @@ export declare class NileMasterDetailChart extends NileElement {
|
|
|
47
32
|
private zoomed;
|
|
48
33
|
private setZoomed;
|
|
49
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;
|
|
50
39
|
private toggleMasterCollapsed;
|
|
51
40
|
config: SeparatedChartConfigInputType | null;
|
|
52
41
|
chartTitle: string;
|
|
@@ -66,7 +55,6 @@ export declare class NileMasterDetailChart extends NileElement {
|
|
|
66
55
|
masterOnly: boolean;
|
|
67
56
|
masterCollapsible: boolean;
|
|
68
57
|
navigatorControls: boolean;
|
|
69
|
-
navigatorHint: string;
|
|
70
58
|
/**
|
|
71
59
|
* Opening window when `navigator-controls` is on and no `selection-min` / `selection-max` is set:
|
|
72
60
|
* a fraction of the range (`0.25`) or, on a datetime axis, a duration (`30m`, `12h`, `7d`, `2w`),
|
|
@@ -150,11 +138,20 @@ export declare class NileMasterDetailChart extends NileElement {
|
|
|
150
138
|
/** Scale the window around its centre: `0.5` zooms in, `2` zooms out; at least one data point per step. */
|
|
151
139
|
zoomBy(factor: number): void;
|
|
152
140
|
private get _navState();
|
|
153
|
-
|
|
154
|
-
private
|
|
155
|
-
|
|
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
|
+
*/
|
|
156
152
|
private _navButton;
|
|
157
|
-
|
|
153
|
+
/** Map-style + / − zoom buttons, overlaid on the top-right corner of the chart. */
|
|
154
|
+
private _renderZoomControls;
|
|
158
155
|
private initCharts;
|
|
159
156
|
private destroyCharts;
|
|
160
157
|
render(): TemplateResult | typeof nothing;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
2
|
import { customElement, property, query, state } from 'lit/decorators.js';
|
|
3
3
|
import { html, nothing } from 'lit';
|
|
4
|
-
import { keyed } from 'lit/directives/keyed.js';
|
|
5
4
|
import { getHighcharts } from '../internal/utils/highcharts-provider.js';
|
|
6
5
|
import NileElement from '../internal/base/nile-element.js';
|
|
7
6
|
import { applySeparatedChartConfig } from '../internal/utils/separated-chart-config.js';
|
|
@@ -29,10 +28,11 @@ export const MASTER_DETAIL_X_AXIS_TYPES = ['datetime', 'linear', 'logarithmic',
|
|
|
29
28
|
* @csspart detail-container - The detail chart.
|
|
30
29
|
* @csspart master-container - The master (overview) strip.
|
|
31
30
|
* @csspart master-toggle - The show/hide button for the master strip (`master-collapsible`).
|
|
32
|
-
* @csspart navigator - The
|
|
33
|
-
* @csspart navigator-
|
|
34
|
-
* @csspart navigator-hint - The hint text after the range readout.
|
|
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.
|
|
35
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;
|
|
36
36
|
let NileMasterDetailChart = class NileMasterDetailChart extends NileElement {
|
|
37
37
|
constructor() {
|
|
38
38
|
super(...arguments);
|
|
@@ -42,6 +42,10 @@ let NileMasterDetailChart = class NileMasterDetailChart extends NileElement {
|
|
|
42
42
|
this.resizeObserver = null;
|
|
43
43
|
this.zoomed = false;
|
|
44
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;
|
|
45
49
|
this.config = null;
|
|
46
50
|
this.chartTitle = '';
|
|
47
51
|
this.chartSubtitle = '';
|
|
@@ -60,7 +64,6 @@ let NileMasterDetailChart = class NileMasterDetailChart extends NileElement {
|
|
|
60
64
|
this.masterOnly = false;
|
|
61
65
|
this.masterCollapsible = false;
|
|
62
66
|
this.navigatorControls = false;
|
|
63
|
-
this.navigatorHint = '';
|
|
64
67
|
/**
|
|
65
68
|
* Opening window when `navigator-controls` is on and no `selection-min` / `selection-max` is set:
|
|
66
69
|
* a fraction of the range (`0.25`) or, on a datetime axis, a duration (`30m`, `12h`, `7d`, `2w`),
|
|
@@ -200,6 +203,7 @@ let NileMasterDetailChart = class NileMasterDetailChart extends NileElement {
|
|
|
200
203
|
'selectionMin',
|
|
201
204
|
'selectionMax',
|
|
202
205
|
'navigatorDefaultWindow',
|
|
206
|
+
'navigatorControls',
|
|
203
207
|
'detailTitle',
|
|
204
208
|
'masterTitle',
|
|
205
209
|
'maskFill',
|
|
@@ -400,7 +404,8 @@ let NileMasterDetailChart = class NileMasterDetailChart extends NileElement {
|
|
|
400
404
|
shared: true,
|
|
401
405
|
};
|
|
402
406
|
const merged = deepMerge({
|
|
403
|
-
|
|
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 },
|
|
404
409
|
title: { text: this.detailTitle || undefined },
|
|
405
410
|
xAxis: {
|
|
406
411
|
type: this.xAxisType,
|
|
@@ -449,6 +454,7 @@ let NileMasterDetailChart = class NileMasterDetailChart extends NileElement {
|
|
|
449
454
|
// masterOnly fills the container, so its auto margins already reserve
|
|
450
455
|
// room — leave that mode untouched.
|
|
451
456
|
marginBottom: mo ? undefined : 30,
|
|
457
|
+
spacingRight: mo && this.navigatorControls ? NAV_CONTROL_GUTTER : undefined,
|
|
452
458
|
zoomType: 'x',
|
|
453
459
|
events: {
|
|
454
460
|
selection(event) {
|
|
@@ -689,84 +695,94 @@ let NileMasterDetailChart = class NileMasterDetailChart extends NileElement {
|
|
|
689
695
|
const xs = this._allXs();
|
|
690
696
|
const last = xs.length - 1;
|
|
691
697
|
const cur = this._windowIndices() ?? { lo: 0, hi: last };
|
|
692
|
-
const sMin = this._toScale(xs[0]);
|
|
693
|
-
const room = this._toScale(xs[last]) - sMin - (this._toScale(xs[cur.hi]) - this._toScale(xs[cur.lo]));
|
|
694
|
-
const atStart = cur.lo <= 0;
|
|
695
|
-
const atEnd = cur.hi >= last;
|
|
696
698
|
return {
|
|
697
|
-
full:
|
|
698
|
-
atStart,
|
|
699
|
-
atEnd,
|
|
699
|
+
full: cur.lo <= 0 && cur.hi >= last,
|
|
700
700
|
atMinWidth: cur.hi - cur.lo <= 1,
|
|
701
|
-
sliderValue: room > 0 ? Math.round(((this._toScale(xs[cur.lo]) - sMin) / room) * 1000) : 0,
|
|
702
701
|
};
|
|
703
702
|
}
|
|
704
|
-
|
|
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;
|
|
705
710
|
const cur = this._windowIndices();
|
|
706
|
-
|
|
711
|
+
const len = this.detailChart?.xAxis[0]?.len;
|
|
712
|
+
if (!cur || !len)
|
|
707
713
|
return;
|
|
708
714
|
const xs = this._allXs();
|
|
709
|
-
const
|
|
710
|
-
const
|
|
711
|
-
|
|
712
|
-
if (room <= 0)
|
|
713
|
-
return;
|
|
714
|
-
const value = Number(event.detail.value) || 0;
|
|
715
|
-
const a = sMin + room * (value / 1000);
|
|
716
|
-
this._setWindow(this._fromScale(a), this._fromScale(a + width));
|
|
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 };
|
|
717
718
|
}
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
if (
|
|
726
|
-
return
|
|
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
|
+
}
|
|
727
736
|
}
|
|
728
|
-
|
|
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();
|
|
729
764
|
}
|
|
730
|
-
/**
|
|
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
|
+
*/
|
|
731
769
|
_navButton(icon, label, disabled, onClick) {
|
|
732
|
-
return html `<
|
|
770
|
+
return html `<button
|
|
771
|
+
type="button"
|
|
733
772
|
class="navigator-button"
|
|
734
|
-
|
|
735
|
-
size="sm"
|
|
773
|
+
part="navigator-button"
|
|
736
774
|
aria-label=${label}
|
|
737
775
|
title=${label}
|
|
738
776
|
?disabled=${disabled}
|
|
739
777
|
@click=${onClick}
|
|
740
|
-
><nile-glyph name=${icon} method="stroke" size="16"></nile-glyph></
|
|
778
|
+
><nile-glyph name=${icon} method="stroke" size="16" color="currentColor"></nile-glyph></button>`;
|
|
741
779
|
}
|
|
742
|
-
|
|
780
|
+
/** Map-style + / − zoom buttons, overlaid on the top-right corner of the chart. */
|
|
781
|
+
_renderZoomControls() {
|
|
743
782
|
const nav = this._navState;
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
return html `<div class="navigator" part="navigator" role="toolbar" aria-label="Chart navigation">
|
|
748
|
-
<div class="navigator-controls">
|
|
749
|
-
${this._navButton('ng-chevron-left', 'Pan back', nav.atStart, () => this.panBy(-1))}
|
|
750
|
-
${keyed(`${nav.sliderValue}:${nav.full}`, html `<nile-slider
|
|
751
|
-
class="navigator-slider"
|
|
752
|
-
aria-label="Visible range position"
|
|
753
|
-
.minValue=${0}
|
|
754
|
-
.maxValue=${1000}
|
|
755
|
-
.value=${nav.sliderValue}
|
|
756
|
-
?disabled=${nav.full}
|
|
757
|
-
@nile-change-end=${this._onSliderChange}
|
|
758
|
-
></nile-slider>`)}
|
|
759
|
-
${this._navButton('ng-chevron-right', 'Pan forward', nav.atEnd, () => this.panBy(1))}
|
|
760
|
-
<div class="navigator-zoom">
|
|
761
|
-
${this._navButton('ng-minus', 'Zoom out', nav.full, () => this.zoomBy(2))}
|
|
762
|
-
${this._navButton('ng-plus', 'Zoom in', nav.atMinWidth, () => this.zoomBy(0.5))}
|
|
763
|
-
</div>
|
|
764
|
-
</div>
|
|
765
|
-
<div class="navigator-caption" part="navigator-caption" aria-live="polite">
|
|
766
|
-
${caption}${this.navigatorHint
|
|
767
|
-
? html ` · <span class="navigator-hint" part="navigator-hint">${this.navigatorHint}</span>`
|
|
768
|
-
: nothing}
|
|
769
|
-
</div>
|
|
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))}
|
|
770
786
|
</div>`;
|
|
771
787
|
}
|
|
772
788
|
async initCharts() {
|
|
@@ -814,10 +830,30 @@ let NileMasterDetailChart = class NileMasterDetailChart extends NileElement {
|
|
|
814
830
|
if (!this._typesValid)
|
|
815
831
|
return nothing;
|
|
816
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(' ');
|
|
817
842
|
return html `<div class="chart-stack">
|
|
818
843
|
${this.masterOnly
|
|
819
844
|
? null
|
|
820
|
-
: html `<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>
|
|
821
857
|
${this.masterCollapsible
|
|
822
858
|
? html `<nile-lite-tooltip content=${this.masterCollapsed ? 'Show master' : 'Hide master'} placement="top">
|
|
823
859
|
<button
|
|
@@ -832,8 +868,15 @@ let NileMasterDetailChart = class NileMasterDetailChart extends NileElement {
|
|
|
832
868
|
</button>
|
|
833
869
|
</nile-lite-tooltip>`
|
|
834
870
|
: null}`}
|
|
835
|
-
<div
|
|
836
|
-
|
|
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}
|
|
837
880
|
</div>`;
|
|
838
881
|
}
|
|
839
882
|
};
|
|
@@ -847,6 +890,9 @@ __decorate([
|
|
|
847
890
|
__decorate([
|
|
848
891
|
state()
|
|
849
892
|
], NileMasterDetailChart.prototype, "masterCollapsed", void 0);
|
|
893
|
+
__decorate([
|
|
894
|
+
state()
|
|
895
|
+
], NileMasterDetailChart.prototype, "_panning", void 0);
|
|
850
896
|
__decorate([
|
|
851
897
|
property({ type: Object })
|
|
852
898
|
], NileMasterDetailChart.prototype, "config", void 0);
|
|
@@ -886,9 +932,6 @@ __decorate([
|
|
|
886
932
|
__decorate([
|
|
887
933
|
property({ type: Boolean, reflect: true, attribute: 'navigator-controls' })
|
|
888
934
|
], NileMasterDetailChart.prototype, "navigatorControls", void 0);
|
|
889
|
-
__decorate([
|
|
890
|
-
property({ type: String, attribute: 'navigator-hint' })
|
|
891
|
-
], NileMasterDetailChart.prototype, "navigatorHint", void 0);
|
|
892
935
|
__decorate([
|
|
893
936
|
property({ type: String, attribute: 'navigator-default-window' })
|
|
894
937
|
], NileMasterDetailChart.prototype, "navigatorDefaultWindow", void 0);
|
|
@@ -275,17 +275,16 @@ describe('NileChart → master-detail passthrough', () => {
|
|
|
275
275
|
expect(inner.series).to.deep.equal(SERIES);
|
|
276
276
|
expect(inner.stacking).to.equal('normal');
|
|
277
277
|
});
|
|
278
|
-
it('27. passes navigatorControls
|
|
278
|
+
it('27. passes navigatorControls and navigatorDefaultWindow down to the inner chart', async () => {
|
|
279
279
|
const el = await fixture(html `<nile-chart style="display:block;width:600px;height:400px"></nile-chart>`);
|
|
280
280
|
el.config = {
|
|
281
|
-
chart: { type: 'master-detail', series: SERIES, navigatorControls: true,
|
|
281
|
+
chart: { type: 'master-detail', series: SERIES, navigatorControls: true, navigatorDefaultWindow: '7d' },
|
|
282
282
|
};
|
|
283
283
|
await el.updateComplete;
|
|
284
284
|
await el.updateComplete;
|
|
285
285
|
const inner = el.shadowRoot.querySelector('nile-master-detail-chart');
|
|
286
286
|
expect(inner, 'inner master-detail chart should render').to.exist;
|
|
287
287
|
expect(inner.navigatorControls).to.be.true;
|
|
288
|
-
expect(inner.navigatorHint).to.equal('drag to zoom');
|
|
289
288
|
expect(inner.navigatorDefaultWindow).to.equal('7d');
|
|
290
289
|
});
|
|
291
290
|
});
|
|
@@ -304,9 +303,20 @@ const DT_SERIES = [
|
|
|
304
303
|
];
|
|
305
304
|
const nav = (el) => el;
|
|
306
305
|
const navigatorPart = (el) => el.shadowRoot.querySelector('[part~="navigator"]');
|
|
307
|
-
const captionPart = (el) => el.shadowRoot.querySelector('[part~="navigator-caption"]');
|
|
308
306
|
const btn = (el, label) => el.shadowRoot.querySelector(`[part~="navigator"] [aria-label="${label}"]`);
|
|
309
|
-
const
|
|
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
|
+
}
|
|
310
320
|
// Every control step goes through applySelection / setExtremes and re-emits
|
|
311
321
|
// `nile-chart-selection { min, max }`. Collect them after mount (the init-time
|
|
312
322
|
// emission has already fired by then).
|
|
@@ -315,43 +325,45 @@ function selectionSpy(el) {
|
|
|
315
325
|
el.addEventListener('nile-chart-selection', (e) => seen.push(e.detail));
|
|
316
326
|
return seen;
|
|
317
327
|
}
|
|
318
|
-
const fmt = (ts) => fakeDateFormat('%Y-%m-%d %H:%M:%S', ts);
|
|
319
328
|
const isDisabled = (node) => !!node && (node.hasAttribute('disabled') || node.disabled === true);
|
|
320
329
|
describe('NileMasterDetailChart — navigator controls', () => {
|
|
321
330
|
it('28. renders no control bar without navigator-controls', async () => {
|
|
322
331
|
const el = await mount({ series: DT_SERIES });
|
|
323
332
|
expect(navigatorPart(el)).to.be.null;
|
|
324
333
|
});
|
|
325
|
-
it('29. renders
|
|
334
|
+
it('29. renders map-style + / − zoom only (no slider, no pan buttons) with navigator-controls', async () => {
|
|
326
335
|
const el = await mount({ series: DT_SERIES, navigatorControls: true });
|
|
327
336
|
expect(navigatorPart(el)).to.not.be.null;
|
|
328
|
-
expect(btn(el, 'Pan back')).to.not.be.null;
|
|
329
|
-
expect(btn(el, 'Pan forward')).to.not.be.null;
|
|
330
337
|
expect(btn(el, 'Zoom in')).to.not.be.null;
|
|
331
338
|
expect(btn(el, 'Zoom out')).to.not.be.null;
|
|
332
|
-
expect(
|
|
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']);
|
|
333
345
|
});
|
|
334
346
|
it('30. renders the control bar in master-only mode', async () => {
|
|
335
347
|
const el = await mount({ series: DT_SERIES, navigatorControls: true, masterOnly: true });
|
|
336
348
|
expect(navigatorPart(el)).to.not.be.null;
|
|
337
349
|
});
|
|
338
|
-
it('31.
|
|
350
|
+
it('31. renders no range caption or hint — the chart only shows the zoom control', async () => {
|
|
339
351
|
const el = await mount({ series: DT_SERIES, navigatorControls: true, navigatorHint: 'blue = clean' });
|
|
340
352
|
expect(navigatorPart(el)).to.not.be.null;
|
|
341
|
-
expect(
|
|
342
|
-
expect(el.shadowRoot.querySelector('[part~="navigator-hint"]')).to.
|
|
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('');
|
|
343
357
|
});
|
|
344
358
|
it('32. navigator-controls reflects to the attribute', async () => {
|
|
345
359
|
const el = await mount({ series: DT_SERIES, navigatorControls: true });
|
|
346
360
|
expect(el.hasAttribute('navigator-controls')).to.be.true;
|
|
347
361
|
});
|
|
348
|
-
it('33. at full range
|
|
362
|
+
it('33. at full range zoom out is disabled, zoom in enabled, and the chart is not draggable', async () => {
|
|
349
363
|
const el = await mount({ series: DT_SERIES, navigatorControls: true });
|
|
350
|
-
expect(isDisabled(btn(el, 'Pan back')), 'pan back').to.be.true;
|
|
351
|
-
expect(isDisabled(btn(el, 'Pan forward')), 'pan forward').to.be.true;
|
|
352
364
|
expect(isDisabled(btn(el, 'Zoom out')), 'zoom out').to.be.true;
|
|
353
|
-
expect(isDisabled(slider(el)), 'slider').to.be.true;
|
|
354
365
|
expect(isDisabled(btn(el, 'Zoom in')), 'zoom in').to.be.false;
|
|
366
|
+
expect(detailPane(el).classList.contains('detail-container--pannable')).to.be.false;
|
|
355
367
|
});
|
|
356
368
|
it('34. zoom in halves the window around its centre and fires nile-chart-selection', async () => {
|
|
357
369
|
const el = await mount({ series: DT_SERIES, navigatorControls: true });
|
|
@@ -414,14 +426,11 @@ describe('NileMasterDetailChart — navigator controls', () => {
|
|
|
414
426
|
expect(w).to.deep.equal({ min: T0 + 4 * DAY, max: DT_MAX });
|
|
415
427
|
expect(w.max - w.min).to.equal(4 * DAY);
|
|
416
428
|
});
|
|
417
|
-
it('41.
|
|
429
|
+
it('41. once zoomed in the detail pane becomes draggable', async () => {
|
|
418
430
|
const el = await mount({ series: DT_SERIES, navigatorControls: true });
|
|
419
431
|
nav(el).zoomBy(0.5);
|
|
420
|
-
nav(el).panBy(1);
|
|
421
|
-
nav(el).panBy(1); // [T0+4d, T0+8d] at end
|
|
422
432
|
await el.updateComplete;
|
|
423
|
-
expect(
|
|
424
|
-
expect(isDisabled(btn(el, 'Pan back'))).to.be.false;
|
|
433
|
+
expect(detailPane(el).classList.contains('detail-container--pannable')).to.be.true;
|
|
425
434
|
});
|
|
426
435
|
it('42. zoom in stops at one point step and disables the zoom-in button', async () => {
|
|
427
436
|
const el = await mount({ series: DT_SERIES, navigatorControls: true });
|
|
@@ -433,6 +442,12 @@ describe('NileMasterDetailChart — navigator controls', () => {
|
|
|
433
442
|
const atStep = nav(el)._window;
|
|
434
443
|
expect(atStep.max - atStep.min).to.equal(DAY);
|
|
435
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);
|
|
436
451
|
// A further zoom-in must not shrink below the point step.
|
|
437
452
|
const seen = selectionSpy(el);
|
|
438
453
|
nav(el).zoomBy(0.5);
|
|
@@ -442,21 +457,75 @@ describe('NileMasterDetailChart — navigator controls', () => {
|
|
|
442
457
|
if (seen.length)
|
|
443
458
|
expect(seen[seen.length - 1].max - seen[seen.length - 1].min).to.equal(DAY);
|
|
444
459
|
});
|
|
445
|
-
it('43.
|
|
460
|
+
it('43. dragging the detail pane pans like a map, keeping the width', async () => {
|
|
446
461
|
const el = await mount({ series: DT_SERIES, navigatorControls: true });
|
|
447
|
-
nav(el).zoomBy(0.5); //
|
|
462
|
+
nav(el).zoomBy(0.5); // [T0+2d, T0+6d]; 4d over 400px = 1d per 100px
|
|
448
463
|
await el.updateComplete;
|
|
449
464
|
const seen = selectionSpy(el);
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
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);
|
|
454
473
|
await el.updateComplete;
|
|
455
|
-
|
|
456
|
-
expect(
|
|
457
|
-
|
|
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);
|
|
458
527
|
});
|
|
459
|
-
it('44. resetZoom restores the full window
|
|
528
|
+
it('44. resetZoom restores the full window and the controls', async () => {
|
|
460
529
|
const el = await mount({ series: DT_SERIES, navigatorControls: true });
|
|
461
530
|
nav(el).zoomBy(0.5);
|
|
462
531
|
await el.updateComplete;
|
|
@@ -467,24 +536,14 @@ describe('NileMasterDetailChart — navigator controls', () => {
|
|
|
467
536
|
expect(nav(el)._window).to.deep.equal({ min: DT_MIN, max: DT_MAX });
|
|
468
537
|
// back at full range → zoom out / pan disabled again
|
|
469
538
|
expect(isDisabled(btn(el, 'Zoom out'))).to.be.true;
|
|
470
|
-
expect(captionPart(el).textContent).to.contain(`${fmt(DT_MIN)} → ${fmt(DT_MAX)}`);
|
|
471
539
|
});
|
|
472
|
-
it('45. a master drag selection updates the window and
|
|
540
|
+
it('45. a master drag selection updates the window and the zoom-out state', async () => {
|
|
473
541
|
const el = await mount({ series: DT_SERIES, navigatorControls: true });
|
|
542
|
+
expect(isDisabled(btn(el, 'Zoom out')), 'full range').to.be.true;
|
|
474
543
|
host(el).applySelection(T0 + 1 * DAY, T0 + 5 * DAY);
|
|
475
|
-
el._window = { min: T0 + 1 * DAY, max: T0 + 5 * DAY };
|
|
476
544
|
await el.updateComplete;
|
|
477
|
-
expect(
|
|
478
|
-
|
|
479
|
-
it('46. caption shows the datetime range on a datetime axis', async () => {
|
|
480
|
-
const el = await mount({ series: DT_SERIES, navigatorControls: true });
|
|
481
|
-
expect(captionPart(el).textContent).to.contain(`${fmt(DT_MIN)} → ${fmt(DT_MAX)}`);
|
|
482
|
-
});
|
|
483
|
-
it('47. caption appends " · hint" when navigator-hint is set', async () => {
|
|
484
|
-
const el = await mount({ series: DT_SERIES, navigatorControls: true, navigatorHint: 'blue = clean' });
|
|
485
|
-
const text = captionPart(el).textContent;
|
|
486
|
-
expect(text).to.contain('·');
|
|
487
|
-
expect(text).to.contain('blue = clean');
|
|
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;
|
|
488
547
|
});
|
|
489
548
|
it('48. a control step refilters every detail series in master+detail mode', async () => {
|
|
490
549
|
const el = await mount({ series: DT_SERIES, navigatorControls: true });
|
|
@@ -496,7 +555,7 @@ describe('NileMasterDetailChart — navigator controls', () => {
|
|
|
496
555
|
describe('NileMasterDetailChart — navigator icon buttons', () => {
|
|
497
556
|
it('56. each button shows only an icon and is named by title and aria-label', async () => {
|
|
498
557
|
const el = await mount({ series: DT_SERIES, navigatorControls: true });
|
|
499
|
-
for (const label of ['
|
|
558
|
+
for (const label of ['Zoom in', 'Zoom out']) {
|
|
500
559
|
const b = btn(el, label);
|
|
501
560
|
expect(b, label).to.not.be.null;
|
|
502
561
|
expect(b.getAttribute('title'), label).to.equal(label);
|
|
@@ -514,12 +573,10 @@ describe('NileMasterDetailChart — navigator default window', () => {
|
|
|
514
573
|
const el = await mount({ series: DT_SERIES, navigatorControls: true, navigatorDefaultWindow: '3d' });
|
|
515
574
|
expect(nav(el)._window).to.deep.equal({ min: DT_MAX - 3 * DAY, max: DT_MAX });
|
|
516
575
|
});
|
|
517
|
-
it('51.
|
|
576
|
+
it('51. zoom out is enabled and the chart is draggable on load', async () => {
|
|
518
577
|
const el = await mount({ series: DT_SERIES, navigatorControls: true, navigatorDefaultWindow: '0.5' });
|
|
519
|
-
expect(isDisabled(slider(el)), 'slider').to.be.false;
|
|
520
|
-
expect(isDisabled(btn(el, 'Pan back')), 'pan back').to.be.false;
|
|
521
578
|
expect(isDisabled(btn(el, 'Zoom out')), 'zoom out').to.be.false;
|
|
522
|
-
expect(
|
|
579
|
+
expect(detailPane(el).classList.contains('detail-container--pannable'), 'pannable').to.be.true;
|
|
523
580
|
});
|
|
524
581
|
it('52. selection-min / selection-max win over the default window', async () => {
|
|
525
582
|
const el = await mount({
|
|
@@ -568,11 +625,9 @@ describe('NileMasterDetailChart — navigator snapping, log scale, categories, s
|
|
|
568
625
|
await el.updateComplete;
|
|
569
626
|
expect(nav(el)._window).to.deep.equal({ min: T0 + DAY, max: T0 + 2 * DAY });
|
|
570
627
|
});
|
|
571
|
-
it('59. a
|
|
628
|
+
it('59. a drag that lands between points snaps to data points', async () => {
|
|
572
629
|
const el = await mount({ series: EIGHT, navigatorControls: true, selectionMin: T0, selectionMax: T0 + 2 * DAY });
|
|
573
|
-
|
|
574
|
-
s.dispatchEvent(new CustomEvent('nile-change-end', { detail: { value: 333 } })); // start ≈ 1.67d → 2d
|
|
575
|
-
await el.updateComplete;
|
|
630
|
+
await dragDetail(el, -330); // 2d over 400px → shift ≈ 1.65d → snaps to 2d
|
|
576
631
|
expect(nav(el)._window).to.deep.equal({ min: T0 + 2 * DAY, max: T0 + 4 * DAY });
|
|
577
632
|
});
|
|
578
633
|
it('60. the default window snaps to data points', async () => {
|
|
@@ -589,14 +644,6 @@ describe('NileMasterDetailChart — navigator snapping, log scale, categories, s
|
|
|
589
644
|
await el.updateComplete;
|
|
590
645
|
expect(nav(el)._window).to.deep.equal({ min: 1e3, max: 1e7 });
|
|
591
646
|
});
|
|
592
|
-
it('62. on a category axis the caption shows category names', async () => {
|
|
593
|
-
const CAT = [{ name: 'A', data: [0, 1, 2, 3].map((x) => ({ x, y: x })) }];
|
|
594
|
-
const el = await mount({ series: CAT, navigatorControls: true, xAxisType: 'category' });
|
|
595
|
-
host(el).detailChart.xAxis[0].categories = ['Mon', 'Tue', 'Wed', 'Thu'];
|
|
596
|
-
el.requestUpdate();
|
|
597
|
-
await el.updateComplete;
|
|
598
|
-
expect(captionPart(el).textContent).to.contain('Mon → Thu');
|
|
599
|
-
});
|
|
600
647
|
it('63. no control bar with fewer than two distinct x values', async () => {
|
|
601
648
|
for (const data of [[], [{ x: T0, y: 1 }], [{ x: T0, y: 1 }, { x: T0, y: 2 }]]) {
|
|
602
649
|
const el = await mount({ data, navigatorControls: true });
|