@aquera/nile-visualization 2.9.48 → 2.9.50
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 +6 -0
- package/dist/src/internal/types/chart-master-detail-config.type.d.ts +4 -1
- package/dist/src/nile-chart/nile-chart-config.d.ts +4 -1
- package/dist/src/nile-chart/nile-chart.js +2 -1
- package/dist/src/nile-master-detail-chart/nile-master-detail-chart.css.js +109 -16
- package/dist/src/nile-master-detail-chart/nile-master-detail-chart.d.ts +36 -21
- package/dist/src/nile-master-detail-chart/nile-master-detail-chart.js +185 -56
- package/dist/src/nile-master-detail-chart/nile-master-detail-chart.test.js +171 -63
- package/package.json +1 -1
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.50 (November 20, 2026)
|
|
40
|
+
- Nile Master-Detail Chart: the window slider and the ‹ / › pan buttons are back as independent opt-in properties, separate from the + / − control: `navigator-slider` and `navigator-pan-buttons` (`navigatorSlider` / `navigatorPanButtons` in `<nile-chart>` config). Either renders a bar under the master pane (‹ slider ›, each piece only when its property is on); use any combination with `navigator-controls`, which is unchanged. `navigator-default-window` now applies when any of the three is on. The slider is a `nile-slider`, so apps register `@aquera/nile-elements`. New CSS parts `navigator-bar`, `navigator-slider`, `navigator-pan-button` (UIF-1433)
|
|
41
|
+
|
|
42
|
+
#### Version 2.9.49 (November 20, 2026)
|
|
43
|
+
- 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)
|
|
44
|
+
|
|
39
45
|
#### Version 2.9.48 (November 20, 2026)
|
|
40
46
|
- 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
47
|
|
|
@@ -15,7 +15,10 @@ export interface ChartMasterDetailConfigType {
|
|
|
15
15
|
masterOnly?: boolean;
|
|
16
16
|
masterCollapsible?: boolean;
|
|
17
17
|
navigatorControls?: boolean;
|
|
18
|
-
|
|
18
|
+
/** Slider under the master pane that positions the visible window. Independent of `navigatorControls`. */
|
|
19
|
+
navigatorSlider?: boolean;
|
|
20
|
+
/** ‹ / › pan buttons under the master pane. Independent of `navigatorControls`. */
|
|
21
|
+
navigatorPanButtons?: boolean;
|
|
19
22
|
/** Opening window with navigator controls: a fraction (`0.25`) or a duration (`7d`, `12h`, `30m`, `2w`). */
|
|
20
23
|
navigatorDefaultWindow?: string;
|
|
21
24
|
xAxisType?: MasterDetailXAxisType;
|
|
@@ -423,7 +423,10 @@ export interface NileMasterDetailChartConfig extends NileChartConfigBase {
|
|
|
423
423
|
masterOnly?: boolean;
|
|
424
424
|
masterCollapsible?: boolean;
|
|
425
425
|
navigatorControls?: boolean;
|
|
426
|
-
|
|
426
|
+
/** Slider under the master pane that positions the visible window. Independent of `navigatorControls`. */
|
|
427
|
+
navigatorSlider?: boolean;
|
|
428
|
+
/** ‹ / › pan buttons under the master pane. Independent of `navigatorControls`. */
|
|
429
|
+
navigatorPanButtons?: boolean;
|
|
427
430
|
/** Opening window with navigator controls: a fraction (`0.25`) or a duration (`7d`, `12h`, `30m`, `2w`). */
|
|
428
431
|
navigatorDefaultWindow?: string;
|
|
429
432
|
xAxisType?: 'datetime' | 'linear' | 'logarithmic' | 'category';
|
|
@@ -1643,7 +1643,8 @@ 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
|
-
.
|
|
1646
|
+
.navigatorSlider=${config.navigatorSlider ?? false}
|
|
1647
|
+
.navigatorPanButtons=${config.navigatorPanButtons ?? false}
|
|
1647
1648
|
.navigatorDefaultWindow=${config.navigatorDefaultWindow ?? ''}
|
|
1648
1649
|
.xAxisType=${config.xAxisType ?? 'datetime'}
|
|
1649
1650
|
.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,33 +99,77 @@ 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
|
-
|
|
124
|
-
|
|
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;
|
|
125
156
|
}
|
|
126
157
|
|
|
127
|
-
/*
|
|
158
|
+
/* Slider / pan-button bar under the master pane (navigator-slider, navigator-pan-buttons). */
|
|
159
|
+
.navigator-bar {
|
|
160
|
+
flex: 0 0 auto;
|
|
161
|
+
display: flex;
|
|
162
|
+
flex-wrap: nowrap;
|
|
163
|
+
align-items: center;
|
|
164
|
+
gap: var(--nile-spacing-2, var(--ng-spacing-2, 8px));
|
|
165
|
+
padding-top: var(--nile-spacing-2, var(--ng-spacing-2, 8px));
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
.navigator-bar-spacer {
|
|
169
|
+
flex: 1 1 auto;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/* Half the thumb plus a gap, so the thumb at either end clears the buttons. */
|
|
128
173
|
.navigator-slider {
|
|
129
174
|
flex: 1 1 160px;
|
|
130
175
|
min-width: 120px;
|
|
@@ -134,11 +179,59 @@ export const styles = css `
|
|
|
134
179
|
--nile-slider-width: 100%;
|
|
135
180
|
}
|
|
136
181
|
|
|
137
|
-
.navigator-
|
|
182
|
+
.navigator-pan-button {
|
|
183
|
+
flex: 0 0 auto;
|
|
184
|
+
display: flex;
|
|
185
|
+
align-items: center;
|
|
186
|
+
justify-content: center;
|
|
187
|
+
box-sizing: border-box;
|
|
188
|
+
width: var(--nile-height-32px, var(--ng-height-32px, 32px));
|
|
189
|
+
height: var(--nile-height-32px, var(--ng-height-32px, 32px));
|
|
190
|
+
padding: 0;
|
|
191
|
+
margin: 0;
|
|
192
|
+
background: var(--nile-colors-white-base, var(--ng-colors-bg-primary, Canvas));
|
|
193
|
+
border: var(--nile-border-width-1, var(--ng-stroke-width-1, 1px)) solid
|
|
194
|
+
var(--nile-colors-neutral-400, var(--ng-colors-border-secondary));
|
|
195
|
+
border-radius: var(--nile-radius-sm, var(--ng-radius-md, 8px));
|
|
196
|
+
box-shadow: var(--nile-box-shadow-1, var(--ng-shadow-xs));
|
|
138
197
|
color: var(--nile-colors-neutral-700, var(--ng-colors-text-secondary-700));
|
|
139
|
-
|
|
198
|
+
cursor: pointer;
|
|
199
|
+
transition: background 150ms ease, color 150ms ease;
|
|
140
200
|
}
|
|
141
201
|
|
|
202
|
+
.navigator-pan-button:hover:not(:disabled) {
|
|
203
|
+
background: var(--nile-colors-dark-200, var(--ng-colors-bg-secondary-hover));
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
.navigator-pan-button:focus-visible {
|
|
207
|
+
outline: var(--nile-border-width-2, var(--ng-stroke-width-2, 2px)) solid
|
|
208
|
+
var(--nile-colors-primary-600, var(--ng-colors-border-brand));
|
|
209
|
+
outline-offset: 2px;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
.navigator-pan-button:disabled {
|
|
213
|
+
background: var(--nile-colors-neutral-100, var(--ng-colors-bg-tertiary, color-mix(in srgb, CanvasText 6%, Canvas)));
|
|
214
|
+
color: var(--nile-colors-neutral-400, var(--ng-colors-fg-disabled, GrayText));
|
|
215
|
+
cursor: not-allowed;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/* Drag-to-pan on the detail pane once zoomed in; vertical touch scroll still scrolls the page. */
|
|
219
|
+
.detail-container--pannable {
|
|
220
|
+
cursor: grab;
|
|
221
|
+
touch-action: pan-y;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
.detail-container--panning {
|
|
225
|
+
cursor: grabbing;
|
|
226
|
+
user-select: none;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
.detail-container:focus-visible,
|
|
230
|
+
.master-container:focus-visible {
|
|
231
|
+
outline: var(--nile-border-width-2, var(--ng-stroke-width-2, 2px)) solid
|
|
232
|
+
var(--nile-colors-primary-600, var(--ng-colors-border-brand));
|
|
233
|
+
outline-offset: -2px;
|
|
234
|
+
}
|
|
142
235
|
|
|
143
236
|
.chart-loading {
|
|
144
237
|
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;
|
|
@@ -65,16 +54,28 @@ export declare class NileMasterDetailChart extends NileElement {
|
|
|
65
54
|
masterType: MasterDetailSeriesType;
|
|
66
55
|
masterOnly: boolean;
|
|
67
56
|
masterCollapsible: boolean;
|
|
57
|
+
/** Map-style + / − zoom over the chart's top-right corner, drag-to-pan and keyboard pan / zoom. */
|
|
68
58
|
navigatorControls: boolean;
|
|
69
|
-
navigatorHint: string;
|
|
70
59
|
/**
|
|
71
|
-
*
|
|
60
|
+
* A slider under the master pane that moves the visible window along the data. Independent of
|
|
61
|
+
* `navigator-controls` and `navigator-pan-buttons`; disabled while the window covers the full range.
|
|
62
|
+
*/
|
|
63
|
+
navigatorSlider: boolean;
|
|
64
|
+
/**
|
|
65
|
+
* ‹ / › buttons under the master pane that pan the window by 25% of its width. Independent of
|
|
66
|
+
* `navigator-controls` and `navigator-slider`.
|
|
67
|
+
*/
|
|
68
|
+
navigatorPanButtons: boolean;
|
|
69
|
+
/**
|
|
70
|
+
* Opening window when any navigator feature (`navigator-controls`, `navigator-slider`, `navigator-pan-buttons`) is on and no `selection-min` / `selection-max` is set:
|
|
72
71
|
* a fraction of the range (`0.25`) or, on a datetime axis, a duration (`30m`, `12h`, `7d`, `2w`),
|
|
73
72
|
* ending at the latest data. Empty opens on the full range.
|
|
74
73
|
*/
|
|
75
74
|
navigatorDefaultWindow: string;
|
|
76
75
|
private _window;
|
|
77
|
-
/**
|
|
76
|
+
/** True when any navigator feature is on. */
|
|
77
|
+
private get _anyNavigator();
|
|
78
|
+
/** Re-renders only when a navigator is shown, so plain charts skip the extra update. */
|
|
78
79
|
private _trackWindow;
|
|
79
80
|
height: string;
|
|
80
81
|
masterHeight: string | number;
|
|
@@ -150,11 +151,25 @@ export declare class NileMasterDetailChart extends NileElement {
|
|
|
150
151
|
/** Scale the window around its centre: `0.5` zooms in, `2` zooms out; at least one data point per step. */
|
|
151
152
|
zoomBy(factor: number): void;
|
|
152
153
|
private get _navState();
|
|
154
|
+
/** Slider (0–1000) maps to where the window's left edge sits in the free room; the width is kept. */
|
|
153
155
|
private _onSliderChange;
|
|
154
|
-
|
|
155
|
-
|
|
156
|
+
/** Drag-to-pan on the detail pane: the window follows the pointer, keeping its width. */
|
|
157
|
+
private get _canDragPan();
|
|
158
|
+
private _onPanStart;
|
|
159
|
+
private _onPanMove;
|
|
160
|
+
private _onPanEnd;
|
|
161
|
+
/** Arrow keys pan, + / − zoom, when the chart pane has focus. */
|
|
162
|
+
private _onNavKeydown;
|
|
163
|
+
/**
|
|
164
|
+
* A native button inside one solid, joined control: disabled stays opaque (only the icon dims), so the
|
|
165
|
+
* chart never shows through, and the cluster keeps a single border with a hairline divider.
|
|
166
|
+
*/
|
|
156
167
|
private _navButton;
|
|
157
|
-
private
|
|
168
|
+
private _panButton;
|
|
169
|
+
/** Bar under the master pane: optional ‹ pan, slider, › pan — each part on its own property. */
|
|
170
|
+
private _renderNavigatorBar;
|
|
171
|
+
/** Map-style + / − zoom buttons, overlaid on the top-right corner of the chart. */
|
|
172
|
+
private _renderZoomControls;
|
|
158
173
|
private initCharts;
|
|
159
174
|
private destroyCharts;
|
|
160
175
|
render(): TemplateResult | typeof nothing;
|
|
@@ -29,10 +29,17 @@ export const MASTER_DETAIL_X_AXIS_TYPES = ['datetime', 'linear', 'logarithmic',
|
|
|
29
29
|
* @csspart detail-container - The detail chart.
|
|
30
30
|
* @csspart master-container - The master (overview) strip.
|
|
31
31
|
* @csspart master-toggle - The show/hide button for the master strip (`master-collapsible`).
|
|
32
|
-
* @csspart navigator - The
|
|
33
|
-
* @csspart navigator-
|
|
34
|
-
* @csspart navigator-
|
|
32
|
+
* @csspart navigator - The map-style zoom buttons (+ / −) over the top-right corner of the chart (`navigator-controls`).
|
|
33
|
+
* @csspart navigator-button - Each zoom button (`Zoom in`, `Zoom out`) inside the `navigator` control.
|
|
34
|
+
* @csspart navigator-bar - The bar under the master pane holding the slider and / or pan buttons
|
|
35
|
+
* (`navigator-slider`, `navigator-pan-buttons`).
|
|
36
|
+
* @csspart navigator-slider - The `nile-slider` that positions the window (`navigator-slider`).
|
|
37
|
+
* @csspart navigator-pan-button - Each pan button (`Pan back`, `Pan forward`) in the bar (`navigator-pan-buttons`).
|
|
38
|
+
*
|
|
39
|
+
* @dependency nile-slider - `navigator-slider` renders a `nile-slider` from `@aquera/nile-elements`; register it in the app.
|
|
35
40
|
*/
|
|
41
|
+
/** Right spacing (px) reserved on the chart under the zoom control: 32px control + 8px offset + 8px gap. */
|
|
42
|
+
const NAV_CONTROL_GUTTER = 48;
|
|
36
43
|
let NileMasterDetailChart = class NileMasterDetailChart extends NileElement {
|
|
37
44
|
constructor() {
|
|
38
45
|
super(...arguments);
|
|
@@ -42,6 +49,10 @@ let NileMasterDetailChart = class NileMasterDetailChart extends NileElement {
|
|
|
42
49
|
this.resizeObserver = null;
|
|
43
50
|
this.zoomed = false;
|
|
44
51
|
this.masterCollapsed = false;
|
|
52
|
+
/** True while a drag-to-pan gesture is moving the window (drives the grabbing cursor). */
|
|
53
|
+
this._panning = false;
|
|
54
|
+
this._drag = null;
|
|
55
|
+
this._dragFrame = 0;
|
|
45
56
|
this.config = null;
|
|
46
57
|
this.chartTitle = '';
|
|
47
58
|
this.chartSubtitle = '';
|
|
@@ -59,10 +70,20 @@ let NileMasterDetailChart = class NileMasterDetailChart extends NileElement {
|
|
|
59
70
|
this.masterType = 'area';
|
|
60
71
|
this.masterOnly = false;
|
|
61
72
|
this.masterCollapsible = false;
|
|
73
|
+
/** Map-style + / − zoom over the chart's top-right corner, drag-to-pan and keyboard pan / zoom. */
|
|
62
74
|
this.navigatorControls = false;
|
|
63
|
-
this.navigatorHint = '';
|
|
64
75
|
/**
|
|
65
|
-
*
|
|
76
|
+
* A slider under the master pane that moves the visible window along the data. Independent of
|
|
77
|
+
* `navigator-controls` and `navigator-pan-buttons`; disabled while the window covers the full range.
|
|
78
|
+
*/
|
|
79
|
+
this.navigatorSlider = false;
|
|
80
|
+
/**
|
|
81
|
+
* ‹ / › buttons under the master pane that pan the window by 25% of its width. Independent of
|
|
82
|
+
* `navigator-controls` and `navigator-slider`.
|
|
83
|
+
*/
|
|
84
|
+
this.navigatorPanButtons = false;
|
|
85
|
+
/**
|
|
86
|
+
* Opening window when any navigator feature (`navigator-controls`, `navigator-slider`, `navigator-pan-buttons`) is on and no `selection-min` / `selection-max` is set:
|
|
66
87
|
* a fraction of the range (`0.25`) or, on a datetime axis, a duration (`30m`, `12h`, `7d`, `2w`),
|
|
67
88
|
* ending at the latest data. Empty opens on the full range.
|
|
68
89
|
*/
|
|
@@ -110,10 +131,14 @@ let NileMasterDetailChart = class NileMasterDetailChart extends NileElement {
|
|
|
110
131
|
this.masterChart?.reflow();
|
|
111
132
|
}
|
|
112
133
|
}
|
|
113
|
-
/**
|
|
134
|
+
/** True when any navigator feature is on. */
|
|
135
|
+
get _anyNavigator() {
|
|
136
|
+
return this.navigatorControls || this.navigatorSlider || this.navigatorPanButtons;
|
|
137
|
+
}
|
|
138
|
+
/** Re-renders only when a navigator is shown, so plain charts skip the extra update. */
|
|
114
139
|
_trackWindow(min, max) {
|
|
115
140
|
this._window = { min, max };
|
|
116
|
-
if (this.
|
|
141
|
+
if (this._anyNavigator)
|
|
117
142
|
this.requestUpdate();
|
|
118
143
|
}
|
|
119
144
|
_cssLength(val) {
|
|
@@ -200,6 +225,9 @@ let NileMasterDetailChart = class NileMasterDetailChart extends NileElement {
|
|
|
200
225
|
'selectionMin',
|
|
201
226
|
'selectionMax',
|
|
202
227
|
'navigatorDefaultWindow',
|
|
228
|
+
'navigatorControls',
|
|
229
|
+
'navigatorSlider',
|
|
230
|
+
'navigatorPanButtons',
|
|
203
231
|
'detailTitle',
|
|
204
232
|
'masterTitle',
|
|
205
233
|
'maskFill',
|
|
@@ -371,7 +399,7 @@ let NileMasterDetailChart = class NileMasterDetailChart extends NileElement {
|
|
|
371
399
|
}
|
|
372
400
|
defaultSelection() {
|
|
373
401
|
const { dataMin, dataMax } = this.dataExtremes();
|
|
374
|
-
if (this.
|
|
402
|
+
if (this._anyNavigator && this.selectionMin == null && this.selectionMax == null) {
|
|
375
403
|
const win = this._defaultWindow();
|
|
376
404
|
if (win)
|
|
377
405
|
return win;
|
|
@@ -400,7 +428,8 @@ let NileMasterDetailChart = class NileMasterDetailChart extends NileElement {
|
|
|
400
428
|
shared: true,
|
|
401
429
|
};
|
|
402
430
|
const merged = deepMerge({
|
|
403
|
-
|
|
431
|
+
// Keep the plot clear of the + / − zoom control in the top-right corner.
|
|
432
|
+
chart: { type: this.detailType, reflow: true, spacingRight: this.navigatorControls ? NAV_CONTROL_GUTTER : undefined },
|
|
404
433
|
title: { text: this.detailTitle || undefined },
|
|
405
434
|
xAxis: {
|
|
406
435
|
type: this.xAxisType,
|
|
@@ -449,6 +478,7 @@ let NileMasterDetailChart = class NileMasterDetailChart extends NileElement {
|
|
|
449
478
|
// masterOnly fills the container, so its auto margins already reserve
|
|
450
479
|
// room — leave that mode untouched.
|
|
451
480
|
marginBottom: mo ? undefined : 30,
|
|
481
|
+
spacingRight: mo && this.navigatorControls ? NAV_CONTROL_GUTTER : undefined,
|
|
452
482
|
zoomType: 'x',
|
|
453
483
|
events: {
|
|
454
484
|
selection(event) {
|
|
@@ -701,6 +731,7 @@ let NileMasterDetailChart = class NileMasterDetailChart extends NileElement {
|
|
|
701
731
|
sliderValue: room > 0 ? Math.round(((this._toScale(xs[cur.lo]) - sMin) / room) * 1000) : 0,
|
|
702
732
|
};
|
|
703
733
|
}
|
|
734
|
+
/** Slider (0–1000) maps to where the window's left edge sits in the free room; the width is kept. */
|
|
704
735
|
_onSliderChange(event) {
|
|
705
736
|
const cur = this._windowIndices();
|
|
706
737
|
if (!cur)
|
|
@@ -715,58 +746,120 @@ let NileMasterDetailChart = class NileMasterDetailChart extends NileElement {
|
|
|
715
746
|
const a = sMin + room * (value / 1000);
|
|
716
747
|
this._setWindow(this._fromScale(a), this._fromScale(a + width));
|
|
717
748
|
}
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
749
|
+
/** Drag-to-pan on the detail pane: the window follows the pointer, keeping its width. */
|
|
750
|
+
get _canDragPan() {
|
|
751
|
+
return this.navigatorControls && !this.masterOnly && this._allXs().length >= 2;
|
|
752
|
+
}
|
|
753
|
+
_onPanStart(e) {
|
|
754
|
+
if (!this._canDragPan || e.button !== 0 || !e.isPrimary || this._navState.full)
|
|
755
|
+
return;
|
|
756
|
+
const cur = this._windowIndices();
|
|
757
|
+
const len = this.detailChart?.xAxis[0]?.len;
|
|
758
|
+
if (!cur || !len)
|
|
759
|
+
return;
|
|
760
|
+
const xs = this._allXs();
|
|
761
|
+
const a = this._toScale(xs[cur.lo]);
|
|
762
|
+
const b = this._toScale(xs[cur.hi]);
|
|
763
|
+
this._drag = { id: e.pointerId, x: e.clientX, a, b, perPx: (b - a) / len, active: false };
|
|
764
|
+
}
|
|
765
|
+
_onPanMove(e) {
|
|
766
|
+
const d = this._drag;
|
|
767
|
+
if (!d || e.pointerId !== d.id)
|
|
768
|
+
return;
|
|
769
|
+
const dx = e.clientX - d.x;
|
|
770
|
+
if (!d.active) {
|
|
771
|
+
// A small threshold keeps plain clicks / taps on points working.
|
|
772
|
+
if (Math.abs(dx) < 4)
|
|
773
|
+
return;
|
|
774
|
+
d.active = true;
|
|
775
|
+
this._panning = true;
|
|
776
|
+
try {
|
|
777
|
+
e.currentTarget.setPointerCapture(e.pointerId);
|
|
778
|
+
}
|
|
779
|
+
catch {
|
|
780
|
+
// Pointer already released (or synthetic) — panning still follows move events.
|
|
781
|
+
}
|
|
727
782
|
}
|
|
728
|
-
|
|
783
|
+
e.preventDefault();
|
|
784
|
+
const shift = -dx * d.perPx;
|
|
785
|
+
cancelAnimationFrame(this._dragFrame);
|
|
786
|
+
this._dragFrame = requestAnimationFrame(() => this._setWindow(this._fromScale(d.a + shift), this._fromScale(d.b + shift)));
|
|
787
|
+
}
|
|
788
|
+
_onPanEnd(e) {
|
|
789
|
+
if (!this._drag || e.pointerId !== this._drag.id)
|
|
790
|
+
return;
|
|
791
|
+
this._drag = null;
|
|
792
|
+
this._panning = false;
|
|
729
793
|
}
|
|
730
|
-
/**
|
|
794
|
+
/** Arrow keys pan, + / − zoom, when the chart pane has focus. */
|
|
795
|
+
_onNavKeydown(e) {
|
|
796
|
+
if (!this.navigatorControls || e.altKey || e.ctrlKey || e.metaKey)
|
|
797
|
+
return;
|
|
798
|
+
const key = e.key;
|
|
799
|
+
if (key === 'ArrowLeft')
|
|
800
|
+
this.panBy(-1);
|
|
801
|
+
else if (key === 'ArrowRight')
|
|
802
|
+
this.panBy(1);
|
|
803
|
+
else if (key === '+' || key === '=')
|
|
804
|
+
this.zoomBy(0.5);
|
|
805
|
+
else if (key === '-' || key === '_')
|
|
806
|
+
this.zoomBy(2);
|
|
807
|
+
else
|
|
808
|
+
return;
|
|
809
|
+
e.preventDefault();
|
|
810
|
+
}
|
|
811
|
+
/**
|
|
812
|
+
* A native button inside one solid, joined control: disabled stays opaque (only the icon dims), so the
|
|
813
|
+
* chart never shows through, and the cluster keeps a single border with a hairline divider.
|
|
814
|
+
*/
|
|
731
815
|
_navButton(icon, label, disabled, onClick) {
|
|
732
|
-
return html `<
|
|
816
|
+
return html `<button
|
|
817
|
+
type="button"
|
|
733
818
|
class="navigator-button"
|
|
734
|
-
|
|
735
|
-
size="sm"
|
|
819
|
+
part="navigator-button"
|
|
736
820
|
aria-label=${label}
|
|
737
821
|
title=${label}
|
|
738
822
|
?disabled=${disabled}
|
|
739
823
|
@click=${onClick}
|
|
740
|
-
><nile-glyph name=${icon} method="stroke" size="16"></nile-glyph></
|
|
824
|
+
><nile-glyph name=${icon} method="stroke" size="16" color="currentColor"></nile-glyph></button>`;
|
|
825
|
+
}
|
|
826
|
+
_panButton(icon, label, disabled, direction) {
|
|
827
|
+
return html `<button
|
|
828
|
+
type="button"
|
|
829
|
+
class="navigator-pan-button"
|
|
830
|
+
part="navigator-pan-button"
|
|
831
|
+
aria-label=${label}
|
|
832
|
+
title=${label}
|
|
833
|
+
?disabled=${disabled}
|
|
834
|
+
@click=${() => this.panBy(direction)}
|
|
835
|
+
><nile-glyph name=${icon} method="stroke" size="16" color="currentColor"></nile-glyph></button>`;
|
|
741
836
|
}
|
|
742
|
-
|
|
837
|
+
/** Bar under the master pane: optional ‹ pan, slider, › pan — each part on its own property. */
|
|
838
|
+
_renderNavigatorBar() {
|
|
743
839
|
const nav = this._navState;
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
? html ` · <span class="navigator-hint" part="navigator-hint">${this.navigatorHint}</span>`
|
|
768
|
-
: nothing}
|
|
769
|
-
</div>
|
|
840
|
+
return html `<div class="navigator-bar" part="navigator-bar" role="toolbar" aria-label="Chart navigation">
|
|
841
|
+
${this.navigatorPanButtons ? this._panButton('ng-chevron-left', 'Pan back', nav.atStart, -1) : nothing}
|
|
842
|
+
${this.navigatorSlider
|
|
843
|
+
? keyed(`${nav.sliderValue}:${nav.full}`, html `<nile-slider
|
|
844
|
+
class="navigator-slider"
|
|
845
|
+
part="navigator-slider"
|
|
846
|
+
aria-label="Visible range position"
|
|
847
|
+
.minValue=${0}
|
|
848
|
+
.maxValue=${1000}
|
|
849
|
+
.value=${nav.sliderValue}
|
|
850
|
+
?disabled=${nav.full}
|
|
851
|
+
@nile-change-end=${this._onSliderChange}
|
|
852
|
+
></nile-slider>`)
|
|
853
|
+
: html `<span class="navigator-bar-spacer"></span>`}
|
|
854
|
+
${this.navigatorPanButtons ? this._panButton('ng-chevron-right', 'Pan forward', nav.atEnd, 1) : nothing}
|
|
855
|
+
</div>`;
|
|
856
|
+
}
|
|
857
|
+
/** Map-style + / − zoom buttons, overlaid on the top-right corner of the chart. */
|
|
858
|
+
_renderZoomControls() {
|
|
859
|
+
const nav = this._navState;
|
|
860
|
+
return html `<div class="navigator" part="navigator" role="toolbar" aria-label="Chart zoom" aria-orientation="vertical">
|
|
861
|
+
${this._navButton('ng-plus', 'Zoom in', nav.atMinWidth, () => this.zoomBy(0.5))}
|
|
862
|
+
${this._navButton('ng-minus', 'Zoom out', nav.full, () => this.zoomBy(2))}
|
|
770
863
|
</div>`;
|
|
771
864
|
}
|
|
772
865
|
async initCharts() {
|
|
@@ -814,10 +907,32 @@ let NileMasterDetailChart = class NileMasterDetailChart extends NileElement {
|
|
|
814
907
|
if (!this._typesValid)
|
|
815
908
|
return nothing;
|
|
816
909
|
const masterHidden = !this.masterOnly && this.masterCollapsed;
|
|
910
|
+
const enoughData = this._allXs().length >= 2;
|
|
911
|
+
const showNav = this.navigatorControls && enoughData;
|
|
912
|
+
const showBar = (this.navigatorSlider || this.navigatorPanButtons) && enoughData;
|
|
913
|
+
const pannable = showNav && !this.masterOnly && !this._navState.full;
|
|
914
|
+
const navLabel = 'Chart. Arrow keys pan, plus and minus zoom.';
|
|
915
|
+
const detailClasses = [
|
|
916
|
+
'detail-container',
|
|
917
|
+
masterHidden ? 'detail-container--grow' : '',
|
|
918
|
+
pannable ? 'detail-container--pannable' : '',
|
|
919
|
+
this._panning ? 'detail-container--panning' : '',
|
|
920
|
+
].join(' ');
|
|
817
921
|
return html `<div class="chart-stack">
|
|
818
922
|
${this.masterOnly
|
|
819
923
|
? null
|
|
820
|
-
: html `<div
|
|
924
|
+
: html `<div
|
|
925
|
+
class=${detailClasses}
|
|
926
|
+
part="detail-container"
|
|
927
|
+
tabindex=${showNav ? '0' : nothing}
|
|
928
|
+
role=${showNav ? 'region' : nothing}
|
|
929
|
+
aria-label=${showNav ? navLabel : nothing}
|
|
930
|
+
@keydown=${this._onNavKeydown}
|
|
931
|
+
@pointerdown=${this._onPanStart}
|
|
932
|
+
@pointermove=${this._onPanMove}
|
|
933
|
+
@pointerup=${this._onPanEnd}
|
|
934
|
+
@pointercancel=${this._onPanEnd}
|
|
935
|
+
></div>
|
|
821
936
|
${this.masterCollapsible
|
|
822
937
|
? html `<nile-lite-tooltip content=${this.masterCollapsed ? 'Show master' : 'Hide master'} placement="top">
|
|
823
938
|
<button
|
|
@@ -832,8 +947,16 @@ let NileMasterDetailChart = class NileMasterDetailChart extends NileElement {
|
|
|
832
947
|
</button>
|
|
833
948
|
</nile-lite-tooltip>`
|
|
834
949
|
: null}`}
|
|
835
|
-
<div
|
|
836
|
-
|
|
950
|
+
<div
|
|
951
|
+
class="master-container ${masterHidden ? 'master-container--collapsed' : ''}"
|
|
952
|
+
part="master-container"
|
|
953
|
+
tabindex=${showNav && this.masterOnly ? '0' : nothing}
|
|
954
|
+
role=${showNav && this.masterOnly ? 'region' : nothing}
|
|
955
|
+
aria-label=${showNav && this.masterOnly ? navLabel : nothing}
|
|
956
|
+
@keydown=${this.masterOnly ? this._onNavKeydown : nothing}
|
|
957
|
+
></div>
|
|
958
|
+
${showNav ? this._renderZoomControls() : nothing}
|
|
959
|
+
${showBar ? this._renderNavigatorBar() : nothing}
|
|
837
960
|
</div>`;
|
|
838
961
|
}
|
|
839
962
|
};
|
|
@@ -847,6 +970,9 @@ __decorate([
|
|
|
847
970
|
__decorate([
|
|
848
971
|
state()
|
|
849
972
|
], NileMasterDetailChart.prototype, "masterCollapsed", void 0);
|
|
973
|
+
__decorate([
|
|
974
|
+
state()
|
|
975
|
+
], NileMasterDetailChart.prototype, "_panning", void 0);
|
|
850
976
|
__decorate([
|
|
851
977
|
property({ type: Object })
|
|
852
978
|
], NileMasterDetailChart.prototype, "config", void 0);
|
|
@@ -887,8 +1013,11 @@ __decorate([
|
|
|
887
1013
|
property({ type: Boolean, reflect: true, attribute: 'navigator-controls' })
|
|
888
1014
|
], NileMasterDetailChart.prototype, "navigatorControls", void 0);
|
|
889
1015
|
__decorate([
|
|
890
|
-
property({ type:
|
|
891
|
-
], NileMasterDetailChart.prototype, "
|
|
1016
|
+
property({ type: Boolean, reflect: true, attribute: 'navigator-slider' })
|
|
1017
|
+
], NileMasterDetailChart.prototype, "navigatorSlider", void 0);
|
|
1018
|
+
__decorate([
|
|
1019
|
+
property({ type: Boolean, reflect: true, attribute: 'navigator-pan-buttons' })
|
|
1020
|
+
], NileMasterDetailChart.prototype, "navigatorPanButtons", void 0);
|
|
892
1021
|
__decorate([
|
|
893
1022
|
property({ type: String, attribute: 'navigator-default-window' })
|
|
894
1023
|
], 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 });
|
|
@@ -606,4 +653,65 @@ describe('NileMasterDetailChart — navigator snapping, log scale, categories, s
|
|
|
606
653
|
expect(navigatorPart(two)).to.not.be.null;
|
|
607
654
|
});
|
|
608
655
|
});
|
|
656
|
+
describe('NileMasterDetailChart — independent slider and pan buttons', () => {
|
|
657
|
+
const bar = (el) => el.shadowRoot.querySelector('[part~="navigator-bar"]');
|
|
658
|
+
const slider = (el) => el.shadowRoot.querySelector('[part~="navigator-bar"] nile-slider');
|
|
659
|
+
const panBtn = (el, label) => el.shadowRoot.querySelector(`[part~="navigator-bar"] [aria-label="${label}"]`);
|
|
660
|
+
const win = (el) => el._window;
|
|
661
|
+
it('S1. renders no bar by default, nor with navigator-controls alone', async () => {
|
|
662
|
+
expect(bar(await mount({ series: DT_SERIES }))).to.be.null;
|
|
663
|
+
expect(bar(await mount({ series: DT_SERIES, navigatorControls: true }))).to.be.null;
|
|
664
|
+
});
|
|
665
|
+
it('S2. navigator-slider alone: slider, no pan buttons, no + / − control', async () => {
|
|
666
|
+
const el = await mount({ series: DT_SERIES, navigatorSlider: true });
|
|
667
|
+
expect(slider(el)).to.not.be.null;
|
|
668
|
+
expect(panBtn(el, 'Pan back')).to.be.null;
|
|
669
|
+
expect(panBtn(el, 'Pan forward')).to.be.null;
|
|
670
|
+
expect(navigatorPart(el)).to.be.null;
|
|
671
|
+
});
|
|
672
|
+
it('S3. navigator-pan-buttons alone: ‹ › buttons, no slider, no + / − control', async () => {
|
|
673
|
+
const el = await mount({ series: DT_SERIES, navigatorPanButtons: true });
|
|
674
|
+
expect(panBtn(el, 'Pan back')).to.not.be.null;
|
|
675
|
+
expect(panBtn(el, 'Pan forward')).to.not.be.null;
|
|
676
|
+
expect(slider(el)).to.be.null;
|
|
677
|
+
expect(navigatorPart(el)).to.be.null;
|
|
678
|
+
});
|
|
679
|
+
it('S4. all three together: + / − overlay plus bar with ‹ slider ›, in that order', async () => {
|
|
680
|
+
const el = await mount({ series: DT_SERIES, navigatorControls: true, navigatorSlider: true, navigatorPanButtons: true });
|
|
681
|
+
expect(navigatorPart(el)).to.not.be.null;
|
|
682
|
+
const kids = [...bar(el).children].map((c) => c.getAttribute('aria-label'));
|
|
683
|
+
expect(kids).to.deep.equal(['Pan back', 'Visible range position', 'Pan forward']);
|
|
684
|
+
});
|
|
685
|
+
it('S5. full range: slider and both pan buttons disabled', async () => {
|
|
686
|
+
const el = await mount({ series: DT_SERIES, navigatorSlider: true, navigatorPanButtons: true });
|
|
687
|
+
expect(isDisabled(slider(el))).to.be.true;
|
|
688
|
+
expect(panBtn(el, 'Pan back').disabled).to.be.true;
|
|
689
|
+
expect(panBtn(el, 'Pan forward').disabled).to.be.true;
|
|
690
|
+
});
|
|
691
|
+
it('S6. navigator-default-window applies with only the slider on', async () => {
|
|
692
|
+
const el = await mount({ series: DT_SERIES, navigatorSlider: true, navigatorDefaultWindow: '2d' });
|
|
693
|
+
expect(win(el)).to.deep.equal({ min: DT_MAX - 2 * DAY, max: DT_MAX });
|
|
694
|
+
expect(isDisabled(slider(el))).to.be.false;
|
|
695
|
+
});
|
|
696
|
+
it('S7. pan back button moves the window earlier and enables pan forward', async () => {
|
|
697
|
+
const el = await mount({ series: DT_SERIES, navigatorPanButtons: true, navigatorDefaultWindow: '2d' });
|
|
698
|
+
expect(panBtn(el, 'Pan forward').disabled).to.be.true;
|
|
699
|
+
const seen = selectionSpy(el);
|
|
700
|
+
panBtn(el, 'Pan back').click();
|
|
701
|
+
await el.updateComplete;
|
|
702
|
+
expect(win(el)).to.deep.equal({ min: DT_MAX - 3 * DAY, max: DT_MAX - DAY });
|
|
703
|
+
expect(seen.length).to.equal(1);
|
|
704
|
+
expect(panBtn(el, 'Pan forward').disabled).to.be.false;
|
|
705
|
+
});
|
|
706
|
+
it('S8. moving the slider to 0 puts the window at the start, keeping its width', async () => {
|
|
707
|
+
const el = await mount({ series: DT_SERIES, navigatorSlider: true, navigatorDefaultWindow: '2d' });
|
|
708
|
+
slider(el).dispatchEvent(new CustomEvent('nile-change-end', { detail: { value: 0 } }));
|
|
709
|
+
await el.updateComplete;
|
|
710
|
+
expect(win(el)).to.deep.equal({ min: DT_MIN, max: DT_MIN + 2 * DAY });
|
|
711
|
+
});
|
|
712
|
+
it('S9. the bar shows in master-only mode', async () => {
|
|
713
|
+
const el = await mount({ series: DT_SERIES, masterOnly: true, navigatorSlider: true, navigatorPanButtons: true });
|
|
714
|
+
expect(bar(el)).to.not.be.null;
|
|
715
|
+
});
|
|
716
|
+
});
|
|
609
717
|
//# sourceMappingURL=nile-master-detail-chart.test.js.map
|