@aquera/nile-visualization 2.9.53 → 2.9.54
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 +5 -0
- package/dist/src/index.d.ts +1 -1
- package/dist/src/internal/types/chart-master-detail-config.type.d.ts +11 -1
- package/dist/src/nile-chart/nile-chart-config.d.ts +11 -1
- package/dist/src/nile-chart/nile-chart.js +6 -1
- package/dist/src/nile-master-detail-chart/index.d.ts +1 -1
- package/dist/src/nile-master-detail-chart/nile-master-detail-chart.css.js +151 -4
- package/dist/src/nile-master-detail-chart/nile-master-detail-chart.d.ts +67 -1
- package/dist/src/nile-master-detail-chart/nile-master-detail-chart.js +357 -11
- package/dist/src/nile-master-detail-chart/nile-master-detail-chart.test.js +350 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -36,6 +36,11 @@ 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.54 (November 23, 2026)
|
|
40
|
+
- Nile Master-Detail Chart: the `navigator-slider` thumb no longer shows its internal 0–1000 position in a tooltip (UIF-1439)
|
|
41
|
+
- Nile Master-Detail Chart: new `navigator-handles` (`navigatorHandles` in `<nile-chart>` config) overlays draggable grips on the master window — edge grips resize, the body moves it (width kept); keyboard-focusable `role="slider"` thumbs (← / → one point, Shift ±10%, Home/End to the bounds). Works in master+detail and `master-only`, turns on `navigator-default-window`, reuses `nile-chart-selection`. New CSS parts `navigator-handle`, `navigator-window`. Off by default (UIF-1439)
|
|
42
|
+
- Nile Master-Detail Chart: new `navigator-handle-variant="labeled"` (edge line, grip and a value pill above each edge, e.g. `Feb 11`), `navigator-handle-label="active|always"` (default `active`: pills only on hover / focus / drag), `navigator-handle-label-format` (Highcharts date format of the pills, default `%b %e`; close pills are pushed apart) and `navigator-mask="frost"` (a translucent blur over the master outside the window instead of `mask-fill`; tune with `--nile-master-detail-frost-tint` / `--nile-master-detail-frost-blur`). All additive, also `<nile-chart>` config keys. New CSS parts `navigator-handle-label`, `navigator-mask` (UIF-1439)
|
|
43
|
+
|
|
39
44
|
#### Version 2.9.53 (November 21, 2026)
|
|
40
45
|
- Nile KPI Chart: `sparkline-position` for the compact variant. `right` gives a small card with the sparkline beside the value (about 45% of the width, 48–120 px, 32 px tall, not full-bleed), a 24–32 px value and no 160 px minimum height; `bottom` (default) is unchanged. Also `sparklinePosition` in `<nile-chart>` KPI config (UIF-1436)
|
|
41
46
|
|
package/dist/src/index.d.ts
CHANGED
|
@@ -40,7 +40,7 @@ export type { BoxplotBox, BoxplotSeriesData } from './nile-boxplot-chart/index.j
|
|
|
40
40
|
export { NileTimelineChart } from './nile-timeline-chart/index.js';
|
|
41
41
|
export type { TimelineEvent } from './nile-timeline-chart/index.js';
|
|
42
42
|
export { NileMasterDetailChart } from './nile-master-detail-chart/index.js';
|
|
43
|
-
export type { MasterDetailPoint, MasterDetailSeries, MasterDetailSeriesType, MasterDetailStacking } from './nile-master-detail-chart/index.js';
|
|
43
|
+
export type { MasterDetailPoint, MasterDetailSeries, MasterDetailSeriesType, MasterDetailStacking, MasterDetailHandleVariant, MasterDetailHandleLabel, MasterDetailMask } from './nile-master-detail-chart/index.js';
|
|
44
44
|
export { NileDumbbellChart } from './nile-dumbbell-chart/index.js';
|
|
45
45
|
export type { DumbbellPoint } from './nile-dumbbell-chart/index.js';
|
|
46
46
|
export { NileDumbbellLowerChart } from './nile-dumbbell-lower-chart/index.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Options } from 'highcharts';
|
|
2
|
-
import type { MasterDetailPoint, MasterDetailSeries, MasterDetailSeriesType, MasterDetailStacking, MasterDetailXAxisType } from '../../nile-master-detail-chart/nile-master-detail-chart.js';
|
|
2
|
+
import type { MasterDetailPoint, MasterDetailSeries, MasterDetailSeriesType, MasterDetailStacking, MasterDetailXAxisType, MasterDetailHandleVariant, MasterDetailHandleLabel, MasterDetailMask } from '../../nile-master-detail-chart/nile-master-detail-chart.js';
|
|
3
3
|
export interface ChartMasterDetailConfigType {
|
|
4
4
|
type: 'master-detail';
|
|
5
5
|
/** Single-series shorthand. Optional when `series` is given. */
|
|
@@ -29,6 +29,16 @@ export interface ChartMasterDetailConfigType {
|
|
|
29
29
|
navigatorZoomStep?: number;
|
|
30
30
|
/** Opening window with navigator controls: a fraction (`0.25`) or a duration (`7d`, `12h`, `30m`, `2w`). */
|
|
31
31
|
navigatorDefaultWindow?: string;
|
|
32
|
+
/** Draggable grips on the master window: edge grips resize, the body moves it (width kept). Off by default. */
|
|
33
|
+
navigatorHandles?: boolean;
|
|
34
|
+
/** Look of the handles: `pill` (default) or `labeled` (edge line, grip and value pill). */
|
|
35
|
+
navigatorHandleVariant?: MasterDetailHandleVariant;
|
|
36
|
+
/** When `labeled` handles show their value pills: `active` (default: hover, focus, drag) or `always`. */
|
|
37
|
+
navigatorHandleLabel?: MasterDetailHandleLabel;
|
|
38
|
+
/** Highcharts date format for the `labeled` pills on a datetime axis (default `%b %e`). */
|
|
39
|
+
navigatorHandleLabelFormat?: string;
|
|
40
|
+
/** Shading outside the master window: `solid` (default, `mask-fill`) or `frost` (blurred and faded). */
|
|
41
|
+
navigatorMask?: MasterDetailMask;
|
|
32
42
|
xAxisType?: MasterDetailXAxisType;
|
|
33
43
|
xAxisMin?: number | null;
|
|
34
44
|
xAxisMax?: number | null;
|
|
@@ -28,7 +28,7 @@ import type { HistogramSamples } from '../nile-histogram-chart/nile-histogram-ch
|
|
|
28
28
|
import type { BellcurveSamples } from '../nile-bellcurve-chart/nile-bellcurve-chart.js';
|
|
29
29
|
import type { BoxplotSeriesData } from '../nile-boxplot-chart/nile-boxplot-chart.js';
|
|
30
30
|
import type { TimelineEvent } from '../nile-timeline-chart/nile-timeline-chart.js';
|
|
31
|
-
import type { MasterDetailPoint, MasterDetailSeries, MasterDetailStacking } from '../nile-master-detail-chart/nile-master-detail-chart.js';
|
|
31
|
+
import type { MasterDetailPoint, MasterDetailSeries, MasterDetailStacking, MasterDetailHandleVariant, MasterDetailHandleLabel, MasterDetailMask } from '../nile-master-detail-chart/nile-master-detail-chart.js';
|
|
32
32
|
import type { DumbbellPoint } from '../nile-dumbbell-chart/nile-dumbbell-chart.js';
|
|
33
33
|
import type { FanLinePoint, FanUncertaintyBand } from '../nile-fan-chart/nile-fan-chart.js';
|
|
34
34
|
import type { FunnelDataPoint } from '../nile-funnel-chart/nile-funnel-chart.js';
|
|
@@ -437,6 +437,16 @@ export interface NileMasterDetailChartConfig extends NileChartConfigBase {
|
|
|
437
437
|
navigatorZoomStep?: number;
|
|
438
438
|
/** Opening window with navigator controls: a fraction (`0.25`) or a duration (`7d`, `12h`, `30m`, `2w`). */
|
|
439
439
|
navigatorDefaultWindow?: string;
|
|
440
|
+
/** Draggable grips on the master window: edge grips resize, the body moves it (width kept). Off by default. */
|
|
441
|
+
navigatorHandles?: boolean;
|
|
442
|
+
/** Look of the handles: `pill` (default) or `labeled` (edge line, grip and value pill). */
|
|
443
|
+
navigatorHandleVariant?: MasterDetailHandleVariant;
|
|
444
|
+
/** When `labeled` handles show their value pills: `active` (default: hover, focus, drag) or `always`. */
|
|
445
|
+
navigatorHandleLabel?: MasterDetailHandleLabel;
|
|
446
|
+
/** Highcharts date format for the `labeled` pills on a datetime axis (default `%b %e`). */
|
|
447
|
+
navigatorHandleLabelFormat?: string;
|
|
448
|
+
/** Shading outside the master window: `solid` (default, `mask-fill`) or `frost` (blurred and faded). */
|
|
449
|
+
navigatorMask?: MasterDetailMask;
|
|
440
450
|
xAxisType?: 'datetime' | 'linear' | 'logarithmic' | 'category';
|
|
441
451
|
xAxisMin?: number | null;
|
|
442
452
|
xAxisMax?: number | null;
|
|
@@ -1670,7 +1670,7 @@ let NileChart = NileChart_1 = class NileChart extends NileElement {
|
|
|
1670
1670
|
case 'master-detail':
|
|
1671
1671
|
return html `<nile-master-detail-chart
|
|
1672
1672
|
part="chart master-detail-chart"
|
|
1673
|
-
exportparts="detail-container: master-detail-detail-container, master-container: master-detail-master-container, master-toggle: master-detail-master-toggle, navigator: master-detail-navigator, navigator-button: master-detail-navigator-button, navigator-bar: master-detail-navigator-bar, navigator-slider: master-detail-navigator-slider, navigator-pan-button: master-detail-navigator-pan-button"
|
|
1673
|
+
exportparts="detail-container: master-detail-detail-container, master-container: master-detail-master-container, master-toggle: master-detail-master-toggle, navigator: master-detail-navigator, navigator-button: master-detail-navigator-button, navigator-bar: master-detail-navigator-bar, navigator-slider: master-detail-navigator-slider, navigator-pan-button: master-detail-navigator-pan-button, navigator-handle: master-detail-navigator-handle, navigator-window: master-detail-navigator-window, navigator-handle-label: master-detail-navigator-handle-label, navigator-mask: master-detail-navigator-mask"
|
|
1674
1674
|
.data=${config.data ?? []}
|
|
1675
1675
|
.series=${config.series ?? []}
|
|
1676
1676
|
.stacking=${config.stacking ?? ''}
|
|
@@ -1689,6 +1689,11 @@ let NileChart = NileChart_1 = class NileChart extends NileElement {
|
|
|
1689
1689
|
.navigatorSliderLive=${config.navigatorSliderLive ?? false}
|
|
1690
1690
|
.navigatorZoomStep=${config.navigatorZoomStep ?? 2}
|
|
1691
1691
|
.navigatorDefaultWindow=${config.navigatorDefaultWindow ?? ''}
|
|
1692
|
+
.navigatorHandles=${config.navigatorHandles ?? false}
|
|
1693
|
+
.navigatorHandleVariant=${config.navigatorHandleVariant ?? 'pill'}
|
|
1694
|
+
.navigatorHandleLabel=${config.navigatorHandleLabel ?? 'active'}
|
|
1695
|
+
.navigatorHandleLabelFormat=${config.navigatorHandleLabelFormat ?? '%b %e'}
|
|
1696
|
+
.navigatorMask=${config.navigatorMask ?? 'solid'}
|
|
1692
1697
|
.xAxisType=${config.xAxisType ?? 'datetime'}
|
|
1693
1698
|
.xAxisMin=${config.xAxisMin ?? null}
|
|
1694
1699
|
.xAxisMax=${config.xAxisMax ?? null}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { NileMasterDetailChart } from './nile-master-detail-chart.js';
|
|
2
|
-
export type { MasterDetailPoint, MasterDetailSeries, MasterDetailSeriesType, MasterDetailStacking } from './nile-master-detail-chart.js';
|
|
2
|
+
export type { MasterDetailPoint, MasterDetailSeries, MasterDetailSeriesType, MasterDetailStacking, MasterDetailHandleVariant, MasterDetailHandleLabel, MasterDetailMask } from './nile-master-detail-chart.js';
|
|
@@ -44,28 +44,175 @@ export const styles = css `
|
|
|
44
44
|
the detail pane. Cap it at a share of the stack so the detail always wins:
|
|
45
45
|
tall cards are unaffected (the px value stays smaller than the cap), short
|
|
46
46
|
ones scale the master down instead of squeezing the detail out. */
|
|
47
|
-
|
|
47
|
+
/* Positioned wrapper so the draggable grip overlay can anchor to the master plot. */
|
|
48
|
+
.master-wrap {
|
|
49
|
+
position: relative;
|
|
48
50
|
flex: 0 0 auto;
|
|
49
51
|
height: min(
|
|
50
52
|
var(--nile-master-detail-master-height, var(--nile-height-100px, var(--ng-height-100px))),
|
|
51
53
|
40%
|
|
52
54
|
);
|
|
53
55
|
width: 100%;
|
|
54
|
-
overflow: hidden;
|
|
55
56
|
opacity: 1;
|
|
56
57
|
transition: height 220ms ease, opacity 180ms ease;
|
|
57
58
|
}
|
|
58
59
|
|
|
59
|
-
|
|
60
|
+
.master-container {
|
|
61
|
+
height: 100%;
|
|
62
|
+
width: 100%;
|
|
63
|
+
overflow: hidden;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
:host([master-only]) .master-wrap {
|
|
60
67
|
flex: 1 1 auto;
|
|
61
68
|
min-height: 0;
|
|
62
69
|
height: 100%;
|
|
63
70
|
}
|
|
64
|
-
|
|
71
|
+
|
|
72
|
+
.master-wrap--collapsed {
|
|
65
73
|
height: 0;
|
|
66
74
|
opacity: 0;
|
|
67
75
|
pointer-events: none;
|
|
68
76
|
}
|
|
77
|
+
.master-container--collapsed {
|
|
78
|
+
pointer-events: none;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/* Draggable window grips, overlaid on the master plot; only the grips and body take pointer events,
|
|
82
|
+
so the master's drag-to-select on the masked area keeps working. */
|
|
83
|
+
.navigator-overlay {
|
|
84
|
+
position: absolute;
|
|
85
|
+
inset: 0;
|
|
86
|
+
pointer-events: none;
|
|
87
|
+
z-index: 1;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.navigator-handle {
|
|
91
|
+
position: absolute;
|
|
92
|
+
z-index: 1;
|
|
93
|
+
width: var(--nile-spacing-3xl, var(--ng-spacing-3xl, 24px));
|
|
94
|
+
transform: translateX(-50%);
|
|
95
|
+
pointer-events: auto;
|
|
96
|
+
cursor: ew-resize;
|
|
97
|
+
touch-action: none;
|
|
98
|
+
display: flex;
|
|
99
|
+
align-items: center;
|
|
100
|
+
justify-content: center;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/* The visual grip: a narrow rounded pill centred in the wider hit target. */
|
|
104
|
+
.navigator-handle::before {
|
|
105
|
+
content: '';
|
|
106
|
+
width: var(--nile-spacing-2, var(--ng-spacing-2, 8px));
|
|
107
|
+
height: 100%;
|
|
108
|
+
background: var(--nile-colors-white-base, var(--ng-colors-bg-primary, Canvas));
|
|
109
|
+
border: var(--nile-border-width-1, var(--ng-stroke-width-1, 1px)) solid
|
|
110
|
+
var(--nile-colors-neutral-400, var(--ng-colors-border-secondary));
|
|
111
|
+
border-radius: var(--nile-radius-sm, var(--ng-radius-md, 4px));
|
|
112
|
+
box-shadow: var(--nile-box-shadow-1, var(--ng-shadow-xs));
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
.navigator-handle:focus-visible {
|
|
116
|
+
outline: var(--nile-border-width-2, var(--ng-stroke-width-2, 2px)) solid
|
|
117
|
+
var(--nile-colors-primary-600, var(--ng-colors-border-brand));
|
|
118
|
+
outline-offset: 2px;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
.navigator-window {
|
|
122
|
+
position: absolute;
|
|
123
|
+
pointer-events: auto;
|
|
124
|
+
cursor: grab;
|
|
125
|
+
touch-action: none;
|
|
126
|
+
background: transparent;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
.navigator-window:active {
|
|
130
|
+
cursor: grabbing;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
.navigator-mask {
|
|
134
|
+
position: absolute;
|
|
135
|
+
pointer-events: none;
|
|
136
|
+
background: color-mix(
|
|
137
|
+
in srgb,
|
|
138
|
+
var(--nile-colors-white-base, var(--ng-colors-bg-primary)) var(--nile-master-detail-frost-tint, 45%),
|
|
139
|
+
transparent
|
|
140
|
+
);
|
|
141
|
+
-webkit-backdrop-filter: blur(var(--nile-master-detail-frost-blur, 1px));
|
|
142
|
+
backdrop-filter: blur(var(--nile-master-detail-frost-blur, 1px));
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/* labeled: a full-height brand line, a grip centred on it and a value pill above the plot. */
|
|
146
|
+
.navigator-overlay--labeled .navigator-handle::before {
|
|
147
|
+
position: absolute;
|
|
148
|
+
left: 50%;
|
|
149
|
+
top: 0;
|
|
150
|
+
width: var(--nile-border-width-2, var(--ng-stroke-width-2, 2px));
|
|
151
|
+
height: 100%;
|
|
152
|
+
transform: translateX(-50%);
|
|
153
|
+
background: var(--nile-colors-primary-600, var(--ng-colors-bg-brand-solid));
|
|
154
|
+
border: none;
|
|
155
|
+
border-radius: 0;
|
|
156
|
+
box-shadow: none;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
.navigator-handle-grip {
|
|
160
|
+
position: relative;
|
|
161
|
+
box-sizing: border-box;
|
|
162
|
+
width: var(--nile-spacing-lg, var(--ng-spacing-lg, 12px));
|
|
163
|
+
height: min(100%, var(--nile-spacing-3xl, var(--ng-spacing-3xl, 24px)));
|
|
164
|
+
background:
|
|
165
|
+
linear-gradient(
|
|
166
|
+
var(--nile-colors-primary-600, var(--ng-colors-bg-brand-solid)),
|
|
167
|
+
var(--nile-colors-primary-600, var(--ng-colors-bg-brand-solid))
|
|
168
|
+
)
|
|
169
|
+
calc(50% - 2px) 50% / 1px 50% no-repeat,
|
|
170
|
+
linear-gradient(
|
|
171
|
+
var(--nile-colors-primary-600, var(--ng-colors-bg-brand-solid)),
|
|
172
|
+
var(--nile-colors-primary-600, var(--ng-colors-bg-brand-solid))
|
|
173
|
+
)
|
|
174
|
+
calc(50% + 2px) 50% / 1px 50% no-repeat,
|
|
175
|
+
var(--nile-colors-white-base, var(--ng-colors-bg-primary));
|
|
176
|
+
border: var(--nile-border-width-1, var(--ng-stroke-width-1, 1px)) solid
|
|
177
|
+
var(--nile-colors-primary-600, var(--ng-colors-bg-brand-solid));
|
|
178
|
+
border-radius: var(--nile-radius-full, var(--ng-radius-full, 9999px));
|
|
179
|
+
box-shadow: var(--nile-box-shadow-1, var(--ng-shadow-xs));
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
.navigator-handle-label {
|
|
183
|
+
position: absolute;
|
|
184
|
+
bottom: calc(100% + var(--nile-spacing-xs, var(--ng-spacing-xs, 4px)));
|
|
185
|
+
left: 50%;
|
|
186
|
+
transform: translateX(-50%);
|
|
187
|
+
padding: var(--nile-spacing-xxs, var(--ng-spacing-xxs, 2px)) var(--nile-spacing-md, var(--ng-spacing-md, 8px));
|
|
188
|
+
white-space: nowrap;
|
|
189
|
+
font-family: var(--nile-font-family-sans-serif, var(--ng-font-family-body));
|
|
190
|
+
font-size: var(--nile-type-scale-2, var(--ng-font-size-text-xs, 12px));
|
|
191
|
+
font-weight: var(--nile-font-weight-semi-bold, var(--ng-font-weight-semibold, 600));
|
|
192
|
+
line-height: 1.5;
|
|
193
|
+
color: var(--nile-colors-white-base, var(--ng-colors-text-white));
|
|
194
|
+
background: var(--nile-colors-primary-600, var(--ng-colors-bg-brand-solid));
|
|
195
|
+
border-radius: var(--nile-radius-full, var(--ng-radius-full, 9999px));
|
|
196
|
+
pointer-events: none;
|
|
197
|
+
transition: opacity var(--nile-transition-duration-default, 150ms) ease;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
.navigator-overlay--label-active .navigator-handle-label {
|
|
201
|
+
opacity: 0;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
.navigator-overlay--label-active .navigator-handle:hover .navigator-handle-label,
|
|
205
|
+
.navigator-overlay--label-active .navigator-handle:focus-visible .navigator-handle-label,
|
|
206
|
+
.navigator-overlay--label-active .navigator-handle:active .navigator-handle-label,
|
|
207
|
+
.navigator-overlay--label-active:has(.navigator-window:active) .navigator-handle-label {
|
|
208
|
+
opacity: 1;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
@media (prefers-reduced-motion: reduce) {
|
|
212
|
+
.navigator-handle-label {
|
|
213
|
+
transition: none;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
69
216
|
|
|
70
217
|
.master-toggle {
|
|
71
218
|
display: flex;
|
|
@@ -17,12 +17,15 @@ export interface MasterDetailSeries {
|
|
|
17
17
|
export declare const MASTER_DETAIL_STACKING: readonly ["normal", "percent"];
|
|
18
18
|
/** `''` (or any unknown value) means no stacking. */
|
|
19
19
|
export type MasterDetailStacking = (typeof MASTER_DETAIL_STACKING)[number] | '';
|
|
20
|
+
export type MasterDetailHandleVariant = 'pill' | 'labeled';
|
|
21
|
+
export type MasterDetailHandleLabel = 'always' | 'active';
|
|
22
|
+
export type MasterDetailMask = 'solid' | 'frost';
|
|
20
23
|
export declare const MASTER_DETAIL_SERIES_TYPES: readonly ["area", "line", "spline", "areaspline", "column", "bar"];
|
|
21
24
|
export type MasterDetailSeriesType = (typeof MASTER_DETAIL_SERIES_TYPES)[number];
|
|
22
25
|
export declare const MASTER_DETAIL_X_AXIS_TYPES: readonly ["datetime", "linear", "logarithmic", "category"];
|
|
23
26
|
export type MasterDetailXAxisType = (typeof MASTER_DETAIL_X_AXIS_TYPES)[number];
|
|
24
27
|
/** Every CSS part `nile-master-detail-chart` renders; `nile-chart` re-exports them as `master-detail-<part>`. */
|
|
25
|
-
export declare const MASTER_DETAIL_CHART_PARTS: readonly ["detail-container", "master-container", "master-toggle", "navigator", "navigator-button", "navigator-bar", "navigator-slider", "navigator-pan-button"];
|
|
28
|
+
export declare const MASTER_DETAIL_CHART_PARTS: readonly ["detail-container", "master-container", "master-toggle", "navigator", "navigator-button", "navigator-bar", "navigator-slider", "navigator-pan-button", "navigator-handle", "navigator-window", "navigator-handle-label", "navigator-mask"];
|
|
26
29
|
/**
|
|
27
30
|
* @tag nile-master-detail-chart
|
|
28
31
|
* @summary A detail chart above an overview (master) strip; dragging on the strip zooms the detail.
|
|
@@ -40,7 +43,14 @@ export declare const MASTER_DETAIL_CHART_PARTS: readonly ["detail-container", "m
|
|
|
40
43
|
* (`navigator-slider`, `navigator-pan-buttons`).
|
|
41
44
|
* @csspart navigator-slider - The `nile-slider` that positions the window (`navigator-slider`).
|
|
42
45
|
* @csspart navigator-pan-button - Each pan button (`Pan back`, `Pan forward`) in the bar (`navigator-pan-buttons`).
|
|
46
|
+
* @csspart navigator-handle - Each draggable edge grip on the master window (`navigator-handles`).
|
|
47
|
+
* @csspart navigator-window - The draggable window body between the grips (`navigator-handles`).
|
|
48
|
+
* @csspart navigator-handle-label - The value pill above each `labeled` grip (`navigator-handle-variant="labeled"`).
|
|
49
|
+
* @csspart navigator-mask - Each frosted area outside the window on the master pane (`navigator-mask="frost"`).
|
|
43
50
|
*
|
|
51
|
+
* @cssproperty --nile-master-detail-frost-tint - How much surface colour covers the master outside the window
|
|
52
|
+
* with `navigator-mask="frost"`: `0%` is clear, `100%` hides it. Default `45%`.
|
|
53
|
+
* @cssproperty --nile-master-detail-frost-blur - Blur behind the `frost` mask. Default `1px`; `0` turns it off.
|
|
44
54
|
* @dependency nile-slider - `navigator-slider` renders a `nile-slider` from `@aquera/nile-elements`; register it in the app.
|
|
45
55
|
*/
|
|
46
56
|
export declare class NileMasterDetailChart extends NileElement {
|
|
@@ -58,6 +68,9 @@ export declare class NileMasterDetailChart extends NileElement {
|
|
|
58
68
|
private _panning;
|
|
59
69
|
private _drag;
|
|
60
70
|
private _dragFrame;
|
|
71
|
+
/** Live grip-drag gesture: which edge (or the body), the pointer id, and the master-axis geometry at grab. */
|
|
72
|
+
private _grip;
|
|
73
|
+
private _gripFrame;
|
|
61
74
|
private toggleMasterCollapsed;
|
|
62
75
|
config: SeparatedChartConfigInputType | null;
|
|
63
76
|
chartTitle: string;
|
|
@@ -113,6 +126,35 @@ export declare class NileMasterDetailChart extends NileElement {
|
|
|
113
126
|
* ending at the latest data. Empty opens on the full range.
|
|
114
127
|
*/
|
|
115
128
|
navigatorDefaultWindow: string;
|
|
129
|
+
/**
|
|
130
|
+
* Draggable grips on the master window: an edge grip on each side resizes the window (the other edge
|
|
131
|
+
* stays put, grips never cross), the body between them moves it keeping its width. Each grip is a
|
|
132
|
+
* keyboard-focusable `role="slider"` thumb. Works in master+detail and `master-only`. Turns on
|
|
133
|
+
* `navigator-default-window`.
|
|
134
|
+
*/
|
|
135
|
+
navigatorHandles: boolean;
|
|
136
|
+
/**
|
|
137
|
+
* Look of the `navigator-handles` grips: `pill` (default) is a small rounded grip; `labeled` is a
|
|
138
|
+
* full-height edge line with a grip and a pill above it showing the edge's value.
|
|
139
|
+
*/
|
|
140
|
+
navigatorHandleVariant: MasterDetailHandleVariant;
|
|
141
|
+
/**
|
|
142
|
+
* When the `labeled` handles show their value pills: `active` (default) — only while a grip is hovered,
|
|
143
|
+
* focused or dragged, or the window is dragged — or `always`.
|
|
144
|
+
*/
|
|
145
|
+
navigatorHandleLabel: MasterDetailHandleLabel;
|
|
146
|
+
/**
|
|
147
|
+
* Highcharts date format for the `labeled` handles' pills on a datetime axis, e.g. `%b %e` (default,
|
|
148
|
+
* `Jun 15`), `%e %b %Y` (`15 Jun 2026`) or `%H:%M`. Other axes show the formatted value.
|
|
149
|
+
*/
|
|
150
|
+
navigatorHandleLabelFormat: string;
|
|
151
|
+
/**
|
|
152
|
+
* How the master pane shades the range outside the window: `solid` (default) fills it with `mask-fill`;
|
|
153
|
+
* `frost` blurs and fades it so the window stands out.
|
|
154
|
+
*/
|
|
155
|
+
navigatorMask: MasterDetailMask;
|
|
156
|
+
private get _labeledHandles();
|
|
157
|
+
private get _frostMask();
|
|
116
158
|
private _window;
|
|
117
159
|
/** True when any navigator feature is on. */
|
|
118
160
|
private get _anyNavigator();
|
|
@@ -153,6 +195,8 @@ export declare class NileMasterDetailChart extends NileElement {
|
|
|
153
195
|
disconnectedCallback(): void;
|
|
154
196
|
protected firstUpdated(): void;
|
|
155
197
|
protected updated(changedProperties: PropertyValues): void;
|
|
198
|
+
/** Applies a handle-look or mask change to the master without resetting the window. */
|
|
199
|
+
private _restyleMaster;
|
|
156
200
|
private setupResizeObserver;
|
|
157
201
|
/** `series` when given, else one series built from `data` / `seriesName` / `seriesColor`. */
|
|
158
202
|
private get _seriesList();
|
|
@@ -220,6 +264,24 @@ export declare class NileMasterDetailChart extends NileElement {
|
|
|
220
264
|
private _onPanStart;
|
|
221
265
|
private _onPanMove;
|
|
222
266
|
private _onPanEnd;
|
|
267
|
+
/** Grip step for Shift + arrow: ~10% of the data points, at least one. */
|
|
268
|
+
private get _gripShiftStep();
|
|
269
|
+
/** Moves one window edge to data index `index`, clamped so the grips stay at least one point apart. */
|
|
270
|
+
private _resizeWindow;
|
|
271
|
+
/** The master x-axis, when the chart exists. */
|
|
272
|
+
private get _masterAxis();
|
|
273
|
+
/** Positions the two grips and the body over the master plot from the current window. No-op when off. */
|
|
274
|
+
private _positionHandles;
|
|
275
|
+
/** Centres each value pill on its edge, pushes the two apart when they would overlap, and keeps both inside the master. */
|
|
276
|
+
private _placeLabels;
|
|
277
|
+
private _onGripStart;
|
|
278
|
+
private _onGripMove;
|
|
279
|
+
private _onGripEnd;
|
|
280
|
+
private _onGripKeydown;
|
|
281
|
+
/** An x value as a `labeled` grip's pill shows it: `navigator-handle-label-format` on a datetime axis. */
|
|
282
|
+
private _formatShortX;
|
|
283
|
+
/** Formats an x value for a grip's `aria-valuetext`: a date on a datetime axis, else the raw value. */
|
|
284
|
+
private _formatX;
|
|
223
285
|
/** Arrow keys pan, + / − zoom, when the chart pane has focus. */
|
|
224
286
|
private _onNavKeydown;
|
|
225
287
|
/**
|
|
@@ -232,6 +294,10 @@ export declare class NileMasterDetailChart extends NileElement {
|
|
|
232
294
|
private _currentSliderKey;
|
|
233
295
|
/** Bar under the master pane: optional ‹ pan, slider, › pan — each part on its own property. */
|
|
234
296
|
private _renderNavigatorBar;
|
|
297
|
+
/** Draggable grips over the master window: an edge grip each side plus the movable body between them. */
|
|
298
|
+
private _renderOverlay;
|
|
299
|
+
private _renderGrip;
|
|
300
|
+
private _renderHandles;
|
|
235
301
|
/** Map-style + / − zoom buttons, overlaid on the top-right corner of the chart. */
|
|
236
302
|
private _renderZoomControls;
|
|
237
303
|
private initCharts;
|
|
@@ -28,11 +28,17 @@ export const MASTER_DETAIL_CHART_PARTS = [
|
|
|
28
28
|
'navigator-bar',
|
|
29
29
|
'navigator-slider',
|
|
30
30
|
'navigator-pan-button',
|
|
31
|
+
'navigator-handle',
|
|
32
|
+
'navigator-window',
|
|
33
|
+
'navigator-handle-label',
|
|
34
|
+
'navigator-mask',
|
|
31
35
|
];
|
|
32
36
|
/** Duration units accepted by `navigator-default-window`, `navigator-pan-step` and `navigator-slider-step`. */
|
|
33
37
|
const DURATION_UNITS = { m: 6e4, h: 36e5, d: 864e5, w: 6048e5 };
|
|
34
38
|
/** Right spacing (px) reserved on the chart under the zoom control: 32px control + 8px offset + 8px gap. */
|
|
35
39
|
const NAV_CONTROL_GUTTER = 48;
|
|
40
|
+
/** Room (px) reserved above the master plot for the `labeled` handles' value pills. */
|
|
41
|
+
const LABEL_ROOM = 26;
|
|
36
42
|
/**
|
|
37
43
|
* @tag nile-master-detail-chart
|
|
38
44
|
* @summary A detail chart above an overview (master) strip; dragging on the strip zooms the detail.
|
|
@@ -50,7 +56,14 @@ const NAV_CONTROL_GUTTER = 48;
|
|
|
50
56
|
* (`navigator-slider`, `navigator-pan-buttons`).
|
|
51
57
|
* @csspart navigator-slider - The `nile-slider` that positions the window (`navigator-slider`).
|
|
52
58
|
* @csspart navigator-pan-button - Each pan button (`Pan back`, `Pan forward`) in the bar (`navigator-pan-buttons`).
|
|
59
|
+
* @csspart navigator-handle - Each draggable edge grip on the master window (`navigator-handles`).
|
|
60
|
+
* @csspart navigator-window - The draggable window body between the grips (`navigator-handles`).
|
|
61
|
+
* @csspart navigator-handle-label - The value pill above each `labeled` grip (`navigator-handle-variant="labeled"`).
|
|
62
|
+
* @csspart navigator-mask - Each frosted area outside the window on the master pane (`navigator-mask="frost"`).
|
|
53
63
|
*
|
|
64
|
+
* @cssproperty --nile-master-detail-frost-tint - How much surface colour covers the master outside the window
|
|
65
|
+
* with `navigator-mask="frost"`: `0%` is clear, `100%` hides it. Default `45%`.
|
|
66
|
+
* @cssproperty --nile-master-detail-frost-blur - Blur behind the `frost` mask. Default `1px`; `0` turns it off.
|
|
54
67
|
* @dependency nile-slider - `navigator-slider` renders a `nile-slider` from `@aquera/nile-elements`; register it in the app.
|
|
55
68
|
*/
|
|
56
69
|
let NileMasterDetailChart = class NileMasterDetailChart extends NileElement {
|
|
@@ -66,6 +79,9 @@ let NileMasterDetailChart = class NileMasterDetailChart extends NileElement {
|
|
|
66
79
|
this._panning = false;
|
|
67
80
|
this._drag = null;
|
|
68
81
|
this._dragFrame = 0;
|
|
82
|
+
/** Live grip-drag gesture: which edge (or the body), the pointer id, and the master-axis geometry at grab. */
|
|
83
|
+
this._grip = null;
|
|
84
|
+
this._gripFrame = 0;
|
|
69
85
|
this.config = null;
|
|
70
86
|
this.chartTitle = '';
|
|
71
87
|
this.chartSubtitle = '';
|
|
@@ -120,6 +136,33 @@ let NileMasterDetailChart = class NileMasterDetailChart extends NileElement {
|
|
|
120
136
|
* ending at the latest data. Empty opens on the full range.
|
|
121
137
|
*/
|
|
122
138
|
this.navigatorDefaultWindow = '';
|
|
139
|
+
/**
|
|
140
|
+
* Draggable grips on the master window: an edge grip on each side resizes the window (the other edge
|
|
141
|
+
* stays put, grips never cross), the body between them moves it keeping its width. Each grip is a
|
|
142
|
+
* keyboard-focusable `role="slider"` thumb. Works in master+detail and `master-only`. Turns on
|
|
143
|
+
* `navigator-default-window`.
|
|
144
|
+
*/
|
|
145
|
+
this.navigatorHandles = false;
|
|
146
|
+
/**
|
|
147
|
+
* Look of the `navigator-handles` grips: `pill` (default) is a small rounded grip; `labeled` is a
|
|
148
|
+
* full-height edge line with a grip and a pill above it showing the edge's value.
|
|
149
|
+
*/
|
|
150
|
+
this.navigatorHandleVariant = 'pill';
|
|
151
|
+
/**
|
|
152
|
+
* When the `labeled` handles show their value pills: `active` (default) — only while a grip is hovered,
|
|
153
|
+
* focused or dragged, or the window is dragged — or `always`.
|
|
154
|
+
*/
|
|
155
|
+
this.navigatorHandleLabel = 'active';
|
|
156
|
+
/**
|
|
157
|
+
* Highcharts date format for the `labeled` handles' pills on a datetime axis, e.g. `%b %e` (default,
|
|
158
|
+
* `Jun 15`), `%e %b %Y` (`15 Jun 2026`) or `%H:%M`. Other axes show the formatted value.
|
|
159
|
+
*/
|
|
160
|
+
this.navigatorHandleLabelFormat = '%b %e';
|
|
161
|
+
/**
|
|
162
|
+
* How the master pane shades the range outside the window: `solid` (default) fills it with `mask-fill`;
|
|
163
|
+
* `frost` blurs and fades it so the window stands out.
|
|
164
|
+
*/
|
|
165
|
+
this.navigatorMask = 'solid';
|
|
123
166
|
this._window = null;
|
|
124
167
|
this.height = '600px';
|
|
125
168
|
this.masterHeight = 100;
|
|
@@ -167,15 +210,23 @@ let NileMasterDetailChart = class NileMasterDetailChart extends NileElement {
|
|
|
167
210
|
this.masterChart?.reflow();
|
|
168
211
|
}
|
|
169
212
|
}
|
|
213
|
+
get _labeledHandles() {
|
|
214
|
+
return this.navigatorHandles && this.navigatorHandleVariant === 'labeled';
|
|
215
|
+
}
|
|
216
|
+
get _frostMask() {
|
|
217
|
+
return this.navigatorMask === 'frost';
|
|
218
|
+
}
|
|
170
219
|
/** True when any navigator feature is on. */
|
|
171
220
|
get _anyNavigator() {
|
|
172
|
-
return this.navigatorControls || this.navigatorSlider || this.navigatorPanButtons;
|
|
221
|
+
return this.navigatorControls || this.navigatorSlider || this.navigatorPanButtons || this.navigatorHandles;
|
|
173
222
|
}
|
|
174
223
|
/** Re-renders only when a navigator is shown, so plain charts skip the extra update. */
|
|
175
224
|
_trackWindow(min, max) {
|
|
176
225
|
this._window = { min, max };
|
|
177
226
|
if (this._anyNavigator)
|
|
178
227
|
this.requestUpdate();
|
|
228
|
+
if (this.navigatorHandles || this._frostMask)
|
|
229
|
+
this.updateComplete.then(() => this._positionHandles());
|
|
179
230
|
}
|
|
180
231
|
_cssLength(val) {
|
|
181
232
|
return typeof val === 'number'
|
|
@@ -231,6 +282,8 @@ let NileMasterDetailChart = class NileMasterDetailChart extends NileElement {
|
|
|
231
282
|
this.applyConfig(this.config);
|
|
232
283
|
return;
|
|
233
284
|
}
|
|
285
|
+
if (changedProperties.has('navigatorHandleLabelFormat'))
|
|
286
|
+
this._positionHandles();
|
|
234
287
|
if (changedProperties.has('masterOnly')) {
|
|
235
288
|
this.destroyCharts();
|
|
236
289
|
if (!this.loading)
|
|
@@ -264,6 +317,7 @@ let NileMasterDetailChart = class NileMasterDetailChart extends NileElement {
|
|
|
264
317
|
'navigatorControls',
|
|
265
318
|
'navigatorSlider',
|
|
266
319
|
'navigatorPanButtons',
|
|
320
|
+
'navigatorHandles',
|
|
267
321
|
'detailTitle',
|
|
268
322
|
'masterTitle',
|
|
269
323
|
'maskFill',
|
|
@@ -289,8 +343,12 @@ let NileMasterDetailChart = class NileMasterDetailChart extends NileElement {
|
|
|
289
343
|
return oldV !== newV;
|
|
290
344
|
}
|
|
291
345
|
};
|
|
292
|
-
if (!props.some(reallyChanged))
|
|
346
|
+
if (!props.some(reallyChanged)) {
|
|
347
|
+
if (changedProperties.has('navigatorHandleVariant') || changedProperties.has('navigatorMask')) {
|
|
348
|
+
this._restyleMaster();
|
|
349
|
+
}
|
|
293
350
|
return;
|
|
351
|
+
}
|
|
294
352
|
if (this.loading) {
|
|
295
353
|
this.destroyCharts();
|
|
296
354
|
return;
|
|
@@ -313,6 +371,15 @@ let NileMasterDetailChart = class NileMasterDetailChart extends NileElement {
|
|
|
313
371
|
this.initCharts();
|
|
314
372
|
}
|
|
315
373
|
}
|
|
374
|
+
/** Applies a handle-look or mask change to the master without resetting the window. */
|
|
375
|
+
_restyleMaster() {
|
|
376
|
+
if (!this.masterChart || this.loading || !this._typesValid)
|
|
377
|
+
return;
|
|
378
|
+
this.masterChart.update(this.buildMasterOptions(), true, true);
|
|
379
|
+
if (this._window)
|
|
380
|
+
this.applySelection(this._window.min, this._window.max);
|
|
381
|
+
this._positionHandles();
|
|
382
|
+
}
|
|
316
383
|
setupResizeObserver() {
|
|
317
384
|
const target = this.detailContainer ?? this.masterContainer;
|
|
318
385
|
if (!target)
|
|
@@ -514,6 +581,7 @@ let NileMasterDetailChart = class NileMasterDetailChart extends NileElement {
|
|
|
514
581
|
// room — leave that mode untouched.
|
|
515
582
|
marginBottom: mo ? undefined : 30,
|
|
516
583
|
spacingRight: mo && this.navigatorControls ? NAV_CONTROL_GUTTER : undefined,
|
|
584
|
+
spacingTop: this._labeledHandles && !this.masterTitle ? 10 + LABEL_ROOM : undefined,
|
|
517
585
|
zoomType: 'x',
|
|
518
586
|
events: {
|
|
519
587
|
selection(event) {
|
|
@@ -536,9 +604,18 @@ let NileMasterDetailChart = class NileMasterDetailChart extends NileElement {
|
|
|
536
604
|
self.setZoomed(true);
|
|
537
605
|
return false;
|
|
538
606
|
},
|
|
607
|
+
redraw() {
|
|
608
|
+
self._positionHandles();
|
|
609
|
+
},
|
|
610
|
+
render() {
|
|
611
|
+
self._positionHandles();
|
|
612
|
+
},
|
|
539
613
|
},
|
|
540
614
|
},
|
|
541
|
-
title: {
|
|
615
|
+
title: {
|
|
616
|
+
text: this.masterTitle || undefined,
|
|
617
|
+
...(this._labeledHandles && this.masterTitle ? { margin: 15 + LABEL_ROOM } : {}),
|
|
618
|
+
},
|
|
542
619
|
// With several series the legend lives on the detail pane, so the master
|
|
543
620
|
// must use the same colours or the overview contradicts it. Inherit the
|
|
544
621
|
// detail palette (`options.colors`, which nile-chart fills from its theme)
|
|
@@ -636,6 +713,8 @@ let NileMasterDetailChart = class NileMasterDetailChart extends NileElement {
|
|
|
636
713
|
const xAxis = this.masterChart.xAxis[0];
|
|
637
714
|
xAxis.removePlotBand('mask-before');
|
|
638
715
|
xAxis.removePlotBand('mask-after');
|
|
716
|
+
if (this._frostMask)
|
|
717
|
+
return;
|
|
639
718
|
if (min > dataMin)
|
|
640
719
|
xAxis.addPlotBand({ id: 'mask-before', from: dataMin, to: min, color: this.maskFill });
|
|
641
720
|
if (max < dataMax)
|
|
@@ -916,6 +995,194 @@ let NileMasterDetailChart = class NileMasterDetailChart extends NileElement {
|
|
|
916
995
|
this._drag = null;
|
|
917
996
|
this._panning = false;
|
|
918
997
|
}
|
|
998
|
+
/** Grip step for Shift + arrow: ~10% of the data points, at least one. */
|
|
999
|
+
get _gripShiftStep() {
|
|
1000
|
+
return Math.max(1, Math.round(this._allXs().length * 0.1));
|
|
1001
|
+
}
|
|
1002
|
+
/** Moves one window edge to data index `index`, clamped so the grips stay at least one point apart. */
|
|
1003
|
+
_resizeWindow(edge, index) {
|
|
1004
|
+
const cur = this._windowIndices();
|
|
1005
|
+
const xs = this._allXs();
|
|
1006
|
+
if (!cur || xs.length < 2)
|
|
1007
|
+
return;
|
|
1008
|
+
const last = xs.length - 1;
|
|
1009
|
+
let { lo, hi } = cur;
|
|
1010
|
+
if (edge === 'start')
|
|
1011
|
+
lo = Math.min(Math.max(0, index), hi - 1);
|
|
1012
|
+
else
|
|
1013
|
+
hi = Math.max(Math.min(last, index), lo + 1);
|
|
1014
|
+
if (lo === cur.lo && hi === cur.hi)
|
|
1015
|
+
return;
|
|
1016
|
+
this._applyWindow(lo, hi);
|
|
1017
|
+
}
|
|
1018
|
+
/** The master x-axis, when the chart exists. */
|
|
1019
|
+
get _masterAxis() {
|
|
1020
|
+
return this.masterChart?.xAxis?.[0] ?? null;
|
|
1021
|
+
}
|
|
1022
|
+
/** Positions the two grips and the body over the master plot from the current window. No-op when off. */
|
|
1023
|
+
_positionHandles() {
|
|
1024
|
+
if (!(this.navigatorHandles || this._frostMask) || this.masterCollapsed)
|
|
1025
|
+
return;
|
|
1026
|
+
const chart = this.masterChart;
|
|
1027
|
+
const ax = this._masterAxis;
|
|
1028
|
+
const cur = this._windowIndices();
|
|
1029
|
+
if (!chart || !ax || typeof ax.toPixels !== 'function' || !cur)
|
|
1030
|
+
return;
|
|
1031
|
+
const xs = this._allXs();
|
|
1032
|
+
const left = ax.toPixels(xs[cur.lo], false);
|
|
1033
|
+
const right = ax.toPixels(xs[cur.hi], false);
|
|
1034
|
+
const top = chart.plotTop ?? 0;
|
|
1035
|
+
const height = chart.plotHeight ?? 0;
|
|
1036
|
+
const grips = this.renderRoot.querySelectorAll('[part~="navigator-handle"]');
|
|
1037
|
+
const body = this.renderRoot.querySelector('[part~="navigator-window"]');
|
|
1038
|
+
grips.forEach(g => {
|
|
1039
|
+
const px = g.dataset.edge === 'end' ? right : left;
|
|
1040
|
+
g.style.left = `${px}px`;
|
|
1041
|
+
g.style.top = `${top}px`;
|
|
1042
|
+
g.style.height = `${height}px`;
|
|
1043
|
+
});
|
|
1044
|
+
this._placeLabels(grips, left, right);
|
|
1045
|
+
if (body) {
|
|
1046
|
+
body.style.left = `${left}px`;
|
|
1047
|
+
body.style.width = `${Math.max(0, right - left)}px`;
|
|
1048
|
+
body.style.top = `${top}px`;
|
|
1049
|
+
body.style.height = `${height}px`;
|
|
1050
|
+
}
|
|
1051
|
+
const plotLeft = chart.plotLeft ?? 0;
|
|
1052
|
+
const plotRight = plotLeft + (chart.plotWidth ?? 0);
|
|
1053
|
+
this.renderRoot.querySelectorAll('[part~="navigator-mask"]').forEach(m => {
|
|
1054
|
+
const [from, to] = m.dataset.side === 'after' ? [right, plotRight] : [plotLeft, left];
|
|
1055
|
+
m.style.left = `${from}px`;
|
|
1056
|
+
m.style.width = `${Math.max(0, to - from)}px`;
|
|
1057
|
+
m.style.top = `${top}px`;
|
|
1058
|
+
m.style.height = `${height}px`;
|
|
1059
|
+
});
|
|
1060
|
+
}
|
|
1061
|
+
/** Centres each value pill on its edge, pushes the two apart when they would overlap, and keeps both inside the master. */
|
|
1062
|
+
_placeLabels(grips, left, right) {
|
|
1063
|
+
const width = grips[0]?.offsetParent?.clientWidth ?? 0;
|
|
1064
|
+
const labelOf = (edge) => Array.from(grips)
|
|
1065
|
+
.find(g => g.dataset.edge === edge)
|
|
1066
|
+
?.querySelector('[part~="navigator-handle-label"]') ?? null;
|
|
1067
|
+
const start = labelOf('start');
|
|
1068
|
+
const end = labelOf('end');
|
|
1069
|
+
if (!start || !end || !width)
|
|
1070
|
+
return;
|
|
1071
|
+
const ws = start.offsetWidth;
|
|
1072
|
+
const we = end.offsetWidth;
|
|
1073
|
+
const gap = 4;
|
|
1074
|
+
let cs = left;
|
|
1075
|
+
let ce = right;
|
|
1076
|
+
const needed = ws / 2 + we / 2 + gap;
|
|
1077
|
+
if (ce - cs < needed) {
|
|
1078
|
+
const mid = (cs + ce) / 2 + (ws - we) / 4;
|
|
1079
|
+
cs = mid - needed / 2;
|
|
1080
|
+
ce = mid + needed / 2;
|
|
1081
|
+
}
|
|
1082
|
+
const under = Math.max(0, ws / 2 - cs);
|
|
1083
|
+
cs += under;
|
|
1084
|
+
ce += under;
|
|
1085
|
+
const over = Math.max(0, ce + we / 2 - width);
|
|
1086
|
+
cs -= over;
|
|
1087
|
+
ce -= over;
|
|
1088
|
+
start.style.marginLeft = cs !== left ? `${cs - left}px` : '';
|
|
1089
|
+
end.style.marginLeft = ce !== right ? `${ce - right}px` : '';
|
|
1090
|
+
}
|
|
1091
|
+
_onGripStart(e, edge) {
|
|
1092
|
+
if (e.button !== 0 || !e.isPrimary)
|
|
1093
|
+
return;
|
|
1094
|
+
const cur = this._windowIndices();
|
|
1095
|
+
const ax = this._masterAxis;
|
|
1096
|
+
const len = ax?.len;
|
|
1097
|
+
if (!cur || !len)
|
|
1098
|
+
return;
|
|
1099
|
+
const xs = this._allXs();
|
|
1100
|
+
const a = this._toScale(xs[cur.lo]);
|
|
1101
|
+
const b = this._toScale(xs[cur.hi]);
|
|
1102
|
+
const span = this._toScale(xs[xs.length - 1]) - this._toScale(xs[0]);
|
|
1103
|
+
this._grip = { id: e.pointerId, edge, x: e.clientX, a, b, perPx: span / len, active: false };
|
|
1104
|
+
// Capture at once: a narrow grip loses the pointer before the 4px threshold otherwise.
|
|
1105
|
+
try {
|
|
1106
|
+
e.currentTarget.setPointerCapture(e.pointerId);
|
|
1107
|
+
}
|
|
1108
|
+
catch {
|
|
1109
|
+
// Synthetic pointers can't be captured; the gesture still follows move events.
|
|
1110
|
+
}
|
|
1111
|
+
}
|
|
1112
|
+
_onGripMove(e) {
|
|
1113
|
+
const g = this._grip;
|
|
1114
|
+
if (!g || e.pointerId !== g.id)
|
|
1115
|
+
return;
|
|
1116
|
+
const dx = e.clientX - g.x;
|
|
1117
|
+
if (!g.active) {
|
|
1118
|
+
if (Math.abs(dx) < 4)
|
|
1119
|
+
return;
|
|
1120
|
+
g.active = true;
|
|
1121
|
+
try {
|
|
1122
|
+
e.currentTarget.setPointerCapture(e.pointerId);
|
|
1123
|
+
}
|
|
1124
|
+
catch {
|
|
1125
|
+
// Pointer already released (or synthetic) — the gesture still follows move events.
|
|
1126
|
+
}
|
|
1127
|
+
}
|
|
1128
|
+
e.preventDefault();
|
|
1129
|
+
cancelAnimationFrame(this._gripFrame);
|
|
1130
|
+
this._gripFrame = requestAnimationFrame(() => {
|
|
1131
|
+
const xs = this._allXs();
|
|
1132
|
+
const perPx = g.perPx;
|
|
1133
|
+
if (g.edge === 'body') {
|
|
1134
|
+
const shift = dx * perPx;
|
|
1135
|
+
this._setWindow(this._fromScale(g.a + shift), this._fromScale(g.b + shift));
|
|
1136
|
+
}
|
|
1137
|
+
else {
|
|
1138
|
+
const scale = (g.edge === 'start' ? g.a : g.b) + dx * perPx;
|
|
1139
|
+
this._resizeWindow(g.edge, this._nearestIndex(xs, this._fromScale(scale)));
|
|
1140
|
+
}
|
|
1141
|
+
});
|
|
1142
|
+
}
|
|
1143
|
+
_onGripEnd(e) {
|
|
1144
|
+
if (!this._grip || e.pointerId !== this._grip.id)
|
|
1145
|
+
return;
|
|
1146
|
+
this._grip = null;
|
|
1147
|
+
cancelAnimationFrame(this._gripFrame);
|
|
1148
|
+
}
|
|
1149
|
+
_onGripKeydown(e, edge) {
|
|
1150
|
+
if (e.altKey || e.ctrlKey || e.metaKey)
|
|
1151
|
+
return;
|
|
1152
|
+
const cur = this._windowIndices();
|
|
1153
|
+
const xs = this._allXs();
|
|
1154
|
+
if (!cur || xs.length < 2)
|
|
1155
|
+
return;
|
|
1156
|
+
const last = xs.length - 1;
|
|
1157
|
+
const idx = edge === 'start' ? cur.lo : cur.hi;
|
|
1158
|
+
const step = e.shiftKey ? this._gripShiftStep : 1;
|
|
1159
|
+
let next;
|
|
1160
|
+
if (e.key === 'ArrowLeft')
|
|
1161
|
+
next = idx - step;
|
|
1162
|
+
else if (e.key === 'ArrowRight')
|
|
1163
|
+
next = idx + step;
|
|
1164
|
+
else if (e.key === 'Home')
|
|
1165
|
+
next = edge === 'start' ? 0 : cur.lo + 1;
|
|
1166
|
+
else if (e.key === 'End')
|
|
1167
|
+
next = edge === 'start' ? cur.hi - 1 : last;
|
|
1168
|
+
else
|
|
1169
|
+
return;
|
|
1170
|
+
e.preventDefault();
|
|
1171
|
+
this._resizeWindow(edge, next);
|
|
1172
|
+
}
|
|
1173
|
+
/** An x value as a `labeled` grip's pill shows it: `navigator-handle-label-format` on a datetime axis. */
|
|
1174
|
+
_formatShortX(v) {
|
|
1175
|
+
if (this.xAxisType === 'datetime' && this._hc?.dateFormat) {
|
|
1176
|
+
return this._hc.dateFormat(this.navigatorHandleLabelFormat || '%b %e', v);
|
|
1177
|
+
}
|
|
1178
|
+
return this._formatX(v);
|
|
1179
|
+
}
|
|
1180
|
+
/** Formats an x value for a grip's `aria-valuetext`: a date on a datetime axis, else the raw value. */
|
|
1181
|
+
_formatX(v) {
|
|
1182
|
+
if (this.xAxisType === 'datetime' && this._hc?.dateFormat)
|
|
1183
|
+
return this._hc.dateFormat('%e %b %Y', v);
|
|
1184
|
+
return String(v);
|
|
1185
|
+
}
|
|
919
1186
|
/** Arrow keys pan, + / − zoom, when the chart pane has focus. */
|
|
920
1187
|
_onNavKeydown(e) {
|
|
921
1188
|
if (!this.navigatorControls || e.altKey || e.ctrlKey || e.metaKey)
|
|
@@ -975,6 +1242,7 @@ let NileMasterDetailChart = class NileMasterDetailChart extends NileElement {
|
|
|
975
1242
|
class="navigator-slider"
|
|
976
1243
|
part="navigator-slider"
|
|
977
1244
|
aria-label="Visible range position"
|
|
1245
|
+
.valueLabel=${'none'}
|
|
978
1246
|
.minValue=${0}
|
|
979
1247
|
.maxValue=${1000}
|
|
980
1248
|
.value=${nav.sliderValue}
|
|
@@ -986,6 +1254,64 @@ let NileMasterDetailChart = class NileMasterDetailChart extends NileElement {
|
|
|
986
1254
|
${this.navigatorPanButtons ? this._panButton('ng-chevron-right', 'Pan forward', nav.atEnd, 1) : nothing}
|
|
987
1255
|
</div>`;
|
|
988
1256
|
}
|
|
1257
|
+
/** Draggable grips over the master window: an edge grip each side plus the movable body between them. */
|
|
1258
|
+
_renderOverlay(showHandles, showMask) {
|
|
1259
|
+
const overlayClasses = [
|
|
1260
|
+
'navigator-overlay',
|
|
1261
|
+
this._labeledHandles ? 'navigator-overlay--labeled' : '',
|
|
1262
|
+
this._labeledHandles && this.navigatorHandleLabel === 'active' ? 'navigator-overlay--label-active' : '',
|
|
1263
|
+
].join(' ');
|
|
1264
|
+
return html `<div class=${overlayClasses}>
|
|
1265
|
+
${showMask
|
|
1266
|
+
? html `<div class="navigator-mask" part="navigator-mask" data-side="before"></div>
|
|
1267
|
+
<div class="navigator-mask" part="navigator-mask" data-side="after"></div>`
|
|
1268
|
+
: nothing}
|
|
1269
|
+
${showHandles ? this._renderHandles() : nothing}
|
|
1270
|
+
</div>`;
|
|
1271
|
+
}
|
|
1272
|
+
_renderGrip(edge, value, min, max) {
|
|
1273
|
+
const labeled = this._labeledHandles;
|
|
1274
|
+
return html `<div
|
|
1275
|
+
class="navigator-handle"
|
|
1276
|
+
part="navigator-handle"
|
|
1277
|
+
data-edge=${edge}
|
|
1278
|
+
role="slider"
|
|
1279
|
+
tabindex="0"
|
|
1280
|
+
aria-label=${edge === 'start' ? 'Window start' : 'Window end'}
|
|
1281
|
+
aria-valuemin=${min}
|
|
1282
|
+
aria-valuemax=${max}
|
|
1283
|
+
aria-valuenow=${value}
|
|
1284
|
+
aria-valuetext=${this._formatX(value)}
|
|
1285
|
+
@pointerdown=${(e) => this._onGripStart(e, edge)}
|
|
1286
|
+
@pointermove=${this._onGripMove}
|
|
1287
|
+
@pointerup=${this._onGripEnd}
|
|
1288
|
+
@pointercancel=${this._onGripEnd}
|
|
1289
|
+
@keydown=${(e) => this._onGripKeydown(e, edge)}
|
|
1290
|
+
>
|
|
1291
|
+
${labeled
|
|
1292
|
+
? html `<span class="navigator-handle-grip"></span
|
|
1293
|
+
><span class="navigator-handle-label" part="navigator-handle-label" aria-hidden="true"
|
|
1294
|
+
>${this._formatShortX(value)}</span
|
|
1295
|
+
>`
|
|
1296
|
+
: nothing}
|
|
1297
|
+
</div>`;
|
|
1298
|
+
}
|
|
1299
|
+
_renderHandles() {
|
|
1300
|
+
const xs = this._allXs();
|
|
1301
|
+
const cur = this._windowIndices() ?? { lo: 0, hi: xs.length - 1 };
|
|
1302
|
+
const startX = xs[cur.lo];
|
|
1303
|
+
const endX = xs[cur.hi];
|
|
1304
|
+
return html `${this._renderGrip('start', startX, xs[0], endX)}
|
|
1305
|
+
<div
|
|
1306
|
+
class="navigator-window"
|
|
1307
|
+
part="navigator-window"
|
|
1308
|
+
@pointerdown=${(e) => this._onGripStart(e, 'body')}
|
|
1309
|
+
@pointermove=${this._onGripMove}
|
|
1310
|
+
@pointerup=${this._onGripEnd}
|
|
1311
|
+
@pointercancel=${this._onGripEnd}
|
|
1312
|
+
></div>
|
|
1313
|
+
${this._renderGrip('end', endX, startX, xs[xs.length - 1])}`;
|
|
1314
|
+
}
|
|
989
1315
|
/** Map-style + / − zoom buttons, overlaid on the top-right corner of the chart. */
|
|
990
1316
|
_renderZoomControls() {
|
|
991
1317
|
const nav = this._navState;
|
|
@@ -1042,6 +1368,8 @@ let NileMasterDetailChart = class NileMasterDetailChart extends NileElement {
|
|
|
1042
1368
|
const enoughData = this._allXs().length >= 2;
|
|
1043
1369
|
const showNav = this.navigatorControls && enoughData;
|
|
1044
1370
|
const showBar = (this.navigatorSlider || this.navigatorPanButtons) && enoughData;
|
|
1371
|
+
const showHandles = this.navigatorHandles && enoughData && !masterHidden;
|
|
1372
|
+
const showMask = this._frostMask && enoughData && !masterHidden && !this.masterOnly;
|
|
1045
1373
|
const pannable = showNav && !this.masterOnly && !this._navState.full;
|
|
1046
1374
|
const navLabel = 'Chart. Arrow keys pan, plus and minus zoom.';
|
|
1047
1375
|
const detailClasses = [
|
|
@@ -1079,14 +1407,17 @@ let NileMasterDetailChart = class NileMasterDetailChart extends NileElement {
|
|
|
1079
1407
|
</button>
|
|
1080
1408
|
</nile-lite-tooltip>`
|
|
1081
1409
|
: null}`}
|
|
1082
|
-
<div
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1410
|
+
<div class="master-wrap ${masterHidden ? 'master-wrap--collapsed' : ''}">
|
|
1411
|
+
<div
|
|
1412
|
+
class="master-container ${masterHidden ? 'master-container--collapsed' : ''}"
|
|
1413
|
+
part="master-container"
|
|
1414
|
+
tabindex=${showNav && this.masterOnly ? '0' : nothing}
|
|
1415
|
+
role=${showNav && this.masterOnly ? 'region' : nothing}
|
|
1416
|
+
aria-label=${showNav && this.masterOnly ? navLabel : nothing}
|
|
1417
|
+
@keydown=${this.masterOnly ? this._onNavKeydown : nothing}
|
|
1418
|
+
></div>
|
|
1419
|
+
${showHandles || showMask ? this._renderOverlay(showHandles, showMask) : nothing}
|
|
1420
|
+
</div>
|
|
1090
1421
|
${showNav ? this._renderZoomControls() : nothing}
|
|
1091
1422
|
${showBar ? this._renderNavigatorBar() : nothing}
|
|
1092
1423
|
</div>`;
|
|
@@ -1165,6 +1496,21 @@ __decorate([
|
|
|
1165
1496
|
__decorate([
|
|
1166
1497
|
property({ type: String, attribute: 'navigator-default-window' })
|
|
1167
1498
|
], NileMasterDetailChart.prototype, "navigatorDefaultWindow", void 0);
|
|
1499
|
+
__decorate([
|
|
1500
|
+
property({ type: Boolean, reflect: true, attribute: 'navigator-handles' })
|
|
1501
|
+
], NileMasterDetailChart.prototype, "navigatorHandles", void 0);
|
|
1502
|
+
__decorate([
|
|
1503
|
+
property({ type: String, reflect: true, attribute: 'navigator-handle-variant' })
|
|
1504
|
+
], NileMasterDetailChart.prototype, "navigatorHandleVariant", void 0);
|
|
1505
|
+
__decorate([
|
|
1506
|
+
property({ type: String, reflect: true, attribute: 'navigator-handle-label' })
|
|
1507
|
+
], NileMasterDetailChart.prototype, "navigatorHandleLabel", void 0);
|
|
1508
|
+
__decorate([
|
|
1509
|
+
property({ type: String, attribute: 'navigator-handle-label-format' })
|
|
1510
|
+
], NileMasterDetailChart.prototype, "navigatorHandleLabelFormat", void 0);
|
|
1511
|
+
__decorate([
|
|
1512
|
+
property({ type: String, reflect: true, attribute: 'navigator-mask' })
|
|
1513
|
+
], NileMasterDetailChart.prototype, "navigatorMask", void 0);
|
|
1168
1514
|
__decorate([
|
|
1169
1515
|
property({ type: String })
|
|
1170
1516
|
], NileMasterDetailChart.prototype, "height", void 0);
|
|
@@ -45,6 +45,13 @@ function makeAxis() {
|
|
|
45
45
|
return {
|
|
46
46
|
min: undefined,
|
|
47
47
|
max: undefined,
|
|
48
|
+
// Geometry the navigator-handle overlay reads to position the grips. The
|
|
49
|
+
// identity toPixels + 400px plot width let `_positionHandles` run without
|
|
50
|
+
// throwing; the handle assertions check `_window`/parts, not pixel maths.
|
|
51
|
+
len: 400,
|
|
52
|
+
toPixels(v) {
|
|
53
|
+
return v;
|
|
54
|
+
},
|
|
48
55
|
setExtremes(min, max) {
|
|
49
56
|
this.min = min;
|
|
50
57
|
this.max = max;
|
|
@@ -71,6 +78,9 @@ function makeChart(options) {
|
|
|
71
78
|
options,
|
|
72
79
|
series: (options.series || []).map(makeSeries),
|
|
73
80
|
xAxis: [makeAxis()],
|
|
81
|
+
// Vertical plot box the handle overlay centres its grips in.
|
|
82
|
+
plotTop: 0,
|
|
83
|
+
plotHeight: 40,
|
|
74
84
|
get legend() {
|
|
75
85
|
return { options: chart.options.legend || {} };
|
|
76
86
|
},
|
|
@@ -95,8 +105,11 @@ function makeChart(options) {
|
|
|
95
105
|
function fakeDateFormat(format, timestamp) {
|
|
96
106
|
const d = new Date(timestamp);
|
|
97
107
|
const pad = (n) => String(n).padStart(2, '0');
|
|
108
|
+
const MONTHS = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
|
|
98
109
|
return format
|
|
99
110
|
.replace(/%Y/g, String(d.getUTCFullYear()))
|
|
111
|
+
.replace(/%b/g, MONTHS[d.getUTCMonth()])
|
|
112
|
+
.replace(/%e/g, String(d.getUTCDate())) // space-padded day in real Highcharts; the day digits are what the handle valuetext test distinguishes
|
|
100
113
|
.replace(/%m/g, pad(d.getUTCMonth() + 1))
|
|
101
114
|
.replace(/%d/g, pad(d.getUTCDate()))
|
|
102
115
|
.replace(/%H/g, pad(d.getUTCHours()))
|
|
@@ -832,10 +845,347 @@ describe('NileMasterDetailChart — navigator step controls', () => {
|
|
|
832
845
|
expect(inner.navigatorZoomStep).to.equal(3);
|
|
833
846
|
});
|
|
834
847
|
});
|
|
848
|
+
const hnd = (el) => el;
|
|
849
|
+
const handles = (el) => [...el.shadowRoot.querySelectorAll('[part~="navigator-handle"]')];
|
|
850
|
+
const grip = (el, edge) => el.shadowRoot.querySelector(`[part~="navigator-handle"][data-edge="${edge}"]`);
|
|
851
|
+
const windowBody = (el) => el.shadowRoot.querySelector('[part~="navigator-window"]');
|
|
852
|
+
/** Fire a keydown on a grip and settle the resulting update. */
|
|
853
|
+
async function pressGrip(el, edge, key, shiftKey = false) {
|
|
854
|
+
grip(el, edge).dispatchEvent(new KeyboardEvent('keydown', { key, shiftKey, bubbles: true, cancelable: true }));
|
|
855
|
+
await el.updateComplete;
|
|
856
|
+
}
|
|
857
|
+
// 20 evenly spaced datetime points so Shift+Arrow (~10% of the count) moves > 1 point.
|
|
858
|
+
const H20_DATA = Array.from({ length: 20 }, (_, i) => ({ x: T0 + i * DAY, y: i }));
|
|
859
|
+
const H20_SERIES = [{ name: 'Wide', data: H20_DATA, color: '#0000ff' }];
|
|
860
|
+
describe('NileMasterDetailChart — navigator handles', () => {
|
|
861
|
+
it('H1. renders no grips or body without navigator-handles', async () => {
|
|
862
|
+
const el = await mount({ series: DT_SERIES });
|
|
863
|
+
expect(handles(el)).to.have.length(0);
|
|
864
|
+
expect(windowBody(el)).to.be.null;
|
|
865
|
+
});
|
|
866
|
+
it('H2. navigator-handles renders two grips (start/end) and one window body', async () => {
|
|
867
|
+
const el = await mount({ series: DT_SERIES, navigatorHandles: true });
|
|
868
|
+
expect(handles(el)).to.have.length(2);
|
|
869
|
+
expect(grip(el, 'start')).to.not.be.null;
|
|
870
|
+
expect(grip(el, 'end')).to.not.be.null;
|
|
871
|
+
expect(windowBody(el)).to.not.be.null;
|
|
872
|
+
});
|
|
873
|
+
it('H3. grips are role=slider, tabindex 0, labelled Window start / Window end', async () => {
|
|
874
|
+
const el = await mount({ series: DT_SERIES, navigatorHandles: true });
|
|
875
|
+
for (const [edge, label] of [['start', 'Window start'], ['end', 'Window end']]) {
|
|
876
|
+
const g = grip(el, edge);
|
|
877
|
+
expect(g.getAttribute('role'), edge).to.equal('slider');
|
|
878
|
+
expect(g.getAttribute('tabindex'), edge).to.equal('0');
|
|
879
|
+
expect(g.getAttribute('aria-label'), edge).to.equal(label);
|
|
880
|
+
}
|
|
881
|
+
});
|
|
882
|
+
it('H4. grips expose aria-valuenow / valuemin / valuemax / valuetext', async () => {
|
|
883
|
+
const el = await mount({ series: DT_SERIES, navigatorHandles: true });
|
|
884
|
+
for (const edge of ['start', 'end']) {
|
|
885
|
+
const g = grip(el, edge);
|
|
886
|
+
for (const attr of ['aria-valuenow', 'aria-valuemin', 'aria-valuemax', 'aria-valuetext']) {
|
|
887
|
+
expect(g.hasAttribute(attr), `${edge} ${attr}`).to.be.true;
|
|
888
|
+
}
|
|
889
|
+
}
|
|
890
|
+
});
|
|
891
|
+
it('H5. renders the grips in master-only mode', async () => {
|
|
892
|
+
const el = await mount({ series: DT_SERIES, navigatorHandles: true, masterOnly: true });
|
|
893
|
+
expect(handles(el)).to.have.length(2);
|
|
894
|
+
expect(windowBody(el)).to.not.be.null;
|
|
895
|
+
});
|
|
896
|
+
it('H6. renders no grips with fewer than two data points', async () => {
|
|
897
|
+
for (const data of [[], [{ x: T0, y: 1 }]]) {
|
|
898
|
+
const el = await mount({ data, navigatorHandles: true });
|
|
899
|
+
expect(handles(el), JSON.stringify(data)).to.have.length(0);
|
|
900
|
+
}
|
|
901
|
+
});
|
|
902
|
+
it('H7. renders no grips while the master is collapsed', async () => {
|
|
903
|
+
const el = await mount({ series: DT_SERIES, navigatorHandles: true, masterCollapsible: true });
|
|
904
|
+
expect(handles(el), 'expanded').to.have.length(2);
|
|
905
|
+
el.masterCollapsed = true;
|
|
906
|
+
await el.updateComplete;
|
|
907
|
+
expect(handles(el), 'collapsed').to.have.length(0);
|
|
908
|
+
});
|
|
909
|
+
it('H8. navigator-handles reflects to the attribute', async () => {
|
|
910
|
+
const el = await mount({ series: DT_SERIES, navigatorHandles: true });
|
|
911
|
+
expect(el.hasAttribute('navigator-handles')).to.be.true;
|
|
912
|
+
});
|
|
913
|
+
it('H9. counts as a navigator feature: navigator-default-window applies with only handles on', async () => {
|
|
914
|
+
const el = await mount({ series: DT_SERIES, navigatorHandles: true, navigatorDefaultWindow: '3d' });
|
|
915
|
+
expect(hnd(el)._window).to.deep.equal({ min: DT_MAX - 3 * DAY, max: DT_MAX });
|
|
916
|
+
});
|
|
917
|
+
it('H10. ArrowRight on the start grip moves only the start edge one point', async () => {
|
|
918
|
+
const el = await mount({ series: DT_SERIES, navigatorHandles: true });
|
|
919
|
+
const seen = selectionSpy(el);
|
|
920
|
+
await pressGrip(el, 'start', 'ArrowRight');
|
|
921
|
+
expect(hnd(el)._window).to.deep.equal({ min: T0 + DAY, max: DT_MAX });
|
|
922
|
+
expect(seen[seen.length - 1]).to.deep.equal({ min: T0 + DAY, max: DT_MAX });
|
|
923
|
+
});
|
|
924
|
+
it('H11. ArrowLeft on the end grip moves only the end edge one point', async () => {
|
|
925
|
+
const el = await mount({ series: DT_SERIES, navigatorHandles: true });
|
|
926
|
+
const seen = selectionSpy(el);
|
|
927
|
+
await pressGrip(el, 'end', 'ArrowLeft');
|
|
928
|
+
expect(hnd(el)._window).to.deep.equal({ min: DT_MIN, max: DT_MAX - DAY });
|
|
929
|
+
expect(seen[seen.length - 1]).to.deep.equal({ min: DT_MIN, max: DT_MAX - DAY });
|
|
930
|
+
});
|
|
931
|
+
it('H12. ArrowLeft on the start grip clamps at the data start', async () => {
|
|
932
|
+
const el = await mount({ series: DT_SERIES, navigatorHandles: true });
|
|
933
|
+
await pressGrip(el, 'start', 'ArrowLeft');
|
|
934
|
+
expect(hnd(el)._window).to.deep.equal({ min: DT_MIN, max: DT_MAX });
|
|
935
|
+
});
|
|
936
|
+
it('H13. Shift+Arrow moves about 10% of the point count (> 1 point)', async () => {
|
|
937
|
+
// 20 points → Shift step = max(1, round(20 * 0.1)) = 2 points.
|
|
938
|
+
const el = await mount({ series: H20_SERIES, navigatorHandles: true });
|
|
939
|
+
await pressGrip(el, 'start', 'ArrowRight', true);
|
|
940
|
+
expect(hnd(el)._window).to.deep.equal({ min: T0 + 2 * DAY, max: T0 + 19 * DAY });
|
|
941
|
+
});
|
|
942
|
+
it('H14. Home / End move the start grip to its furthest allowed positions', async () => {
|
|
943
|
+
const el = await mount({ series: DT_SERIES, navigatorHandles: true });
|
|
944
|
+
hnd(el)._resizeWindow('start', 3);
|
|
945
|
+
await el.updateComplete;
|
|
946
|
+
await pressGrip(el, 'start', 'End'); // furthest right = end grip (index 8) − 1 = 7
|
|
947
|
+
expect(hnd(el)._window).to.deep.equal({ min: T0 + 7 * DAY, max: DT_MAX });
|
|
948
|
+
await pressGrip(el, 'start', 'Home'); // back to the data start
|
|
949
|
+
expect(hnd(el)._window).to.deep.equal({ min: DT_MIN, max: DT_MAX });
|
|
950
|
+
});
|
|
951
|
+
it('H15. Home / End move the end grip to its furthest allowed positions', async () => {
|
|
952
|
+
const el = await mount({ series: DT_SERIES, navigatorHandles: true });
|
|
953
|
+
hnd(el)._resizeWindow('end', 5);
|
|
954
|
+
await el.updateComplete;
|
|
955
|
+
await pressGrip(el, 'end', 'Home'); // furthest left = start grip (index 0) + 1 = 1
|
|
956
|
+
expect(hnd(el)._window).to.deep.equal({ min: DT_MIN, max: T0 + DAY });
|
|
957
|
+
await pressGrip(el, 'end', 'End'); // back to the data end
|
|
958
|
+
expect(hnd(el)._window).to.deep.equal({ min: DT_MIN, max: DT_MAX });
|
|
959
|
+
});
|
|
960
|
+
it('H16. the grips never cross — they stay at least one point apart', async () => {
|
|
961
|
+
const el = await mount({ series: DT_SERIES, navigatorHandles: true });
|
|
962
|
+
// Drive the start grip toward the end; it must stop one interval short.
|
|
963
|
+
hnd(el)._resizeWindow('start', 8);
|
|
964
|
+
await el.updateComplete;
|
|
965
|
+
const w = hnd(el)._window;
|
|
966
|
+
expect(w).to.deep.equal({ min: T0 + 7 * DAY, max: DT_MAX });
|
|
967
|
+
// One more step is a no-op (already adjacent to the end grip).
|
|
968
|
+
const seen = selectionSpy(el);
|
|
969
|
+
hnd(el)._resizeWindow('start', 8);
|
|
970
|
+
await el.updateComplete;
|
|
971
|
+
expect(hnd(el)._window).to.deep.equal({ min: T0 + 7 * DAY, max: DT_MAX });
|
|
972
|
+
if (seen.length)
|
|
973
|
+
expect(hnd(el)._window).to.deep.equal(seen[seen.length - 1]);
|
|
974
|
+
});
|
|
975
|
+
it('H17. _resizeWindow clamps an out-of-range index into the data range', async () => {
|
|
976
|
+
const el = await mount({ series: DT_SERIES, navigatorHandles: true });
|
|
977
|
+
hnd(el)._resizeWindow('end', 999); // past the last point → clamps to the data end
|
|
978
|
+
await el.updateComplete;
|
|
979
|
+
expect(hnd(el)._window).to.deep.equal({ min: DT_MIN, max: DT_MAX });
|
|
980
|
+
hnd(el)._resizeWindow('start', -5); // before the first point → clamps to the data start
|
|
981
|
+
await el.updateComplete;
|
|
982
|
+
expect(hnd(el)._window).to.deep.equal({ min: DT_MIN, max: DT_MAX });
|
|
983
|
+
});
|
|
984
|
+
it('H18. aria-valuenow / valuetext on a grip update after a move', async () => {
|
|
985
|
+
const el = await mount({ series: DT_SERIES, navigatorHandles: true });
|
|
986
|
+
const g = grip(el, 'start');
|
|
987
|
+
const now0 = g.getAttribute('aria-valuenow');
|
|
988
|
+
const text0 = g.getAttribute('aria-valuetext');
|
|
989
|
+
await pressGrip(el, 'start', 'ArrowRight');
|
|
990
|
+
const g2 = grip(el, 'start');
|
|
991
|
+
expect(g2.getAttribute('aria-valuenow'), 'valuenow changed').to.not.equal(now0);
|
|
992
|
+
expect(g2.getAttribute('aria-valuetext'), 'valuetext changed').to.not.equal(text0);
|
|
993
|
+
expect(g2.getAttribute('aria-valuenow')).to.equal(String(T0 + DAY));
|
|
994
|
+
});
|
|
995
|
+
it('H19. dragging the window body keeps the window width', async () => {
|
|
996
|
+
// Pointer→pixel mapping through the fake chart is approximate, so this asserts
|
|
997
|
+
// width preservation (and range clamping) only; the exact body-move offset and
|
|
998
|
+
// its nile-chart-selection are verified in the real-browser visual check.
|
|
999
|
+
const el = await mount({ series: DT_SERIES, navigatorHandles: true, navigatorDefaultWindow: '4d' });
|
|
1000
|
+
const before = hnd(el)._window;
|
|
1001
|
+
const width0 = before.max - before.min;
|
|
1002
|
+
const body = windowBody(el);
|
|
1003
|
+
const opts = { pointerId: 7, isPrimary: true, button: 0, bubbles: true, composed: true };
|
|
1004
|
+
body.dispatchEvent(new PointerEvent('pointerdown', { ...opts, clientX: 200 }));
|
|
1005
|
+
body.dispatchEvent(new PointerEvent('pointermove', { ...opts, clientX: 140 }));
|
|
1006
|
+
body.dispatchEvent(new PointerEvent('pointermove', { ...opts, clientX: 80 }));
|
|
1007
|
+
await new Promise((r) => requestAnimationFrame(() => r(null)));
|
|
1008
|
+
body.dispatchEvent(new PointerEvent('pointerup', { ...opts, clientX: 80 }));
|
|
1009
|
+
await el.updateComplete;
|
|
1010
|
+
const after = hnd(el)._window;
|
|
1011
|
+
expect(after.max - after.min, 'width preserved').to.equal(width0);
|
|
1012
|
+
expect(after.min, 'clamped to data range').to.be.at.least(DT_MIN);
|
|
1013
|
+
expect(after.max, 'clamped to data range').to.be.at.most(DT_MAX);
|
|
1014
|
+
});
|
|
1015
|
+
it('H20. MASTER_DETAIL_CHART_PARTS includes the two handle parts', () => {
|
|
1016
|
+
expect(MASTER_DETAIL_CHART_PARTS).to.include('navigator-handle');
|
|
1017
|
+
expect(MASTER_DETAIL_CHART_PARTS).to.include('navigator-window');
|
|
1018
|
+
});
|
|
1019
|
+
it('H21. <nile-chart> passes navigatorHandles through to the inner chart', async () => {
|
|
1020
|
+
const el = await fixture(html `<nile-chart style="display:block;width:600px;height:400px"></nile-chart>`);
|
|
1021
|
+
el.config = { chart: { type: 'master-detail', series: SERIES, navigatorHandles: true } };
|
|
1022
|
+
await el.updateComplete;
|
|
1023
|
+
await el.updateComplete;
|
|
1024
|
+
const inner = el.shadowRoot.querySelector('nile-master-detail-chart');
|
|
1025
|
+
expect(inner, 'inner master-detail chart should render').to.exist;
|
|
1026
|
+
expect(inner.navigatorHandles).to.be.true;
|
|
1027
|
+
});
|
|
1028
|
+
});
|
|
1029
|
+
// --- labeled handles, label visibility, frost mask ---------------------------
|
|
1030
|
+
const overlay = (el) => el.shadowRoot.querySelector('.navigator-overlay');
|
|
1031
|
+
const handleLabel = (el, edge) => grip(el, edge).querySelector('[part~="navigator-handle-label"]');
|
|
1032
|
+
const masks = (el) => [...el.shadowRoot.querySelectorAll('[part~="navigator-mask"]')];
|
|
1033
|
+
const masterBands = (el) => host(el).masterChart.xAxis[0]._bands;
|
|
1034
|
+
describe('NileMasterDetailChart — labeled handles', () => {
|
|
1035
|
+
it('L1. navigatorHandleVariant defaults to pill and renders no label', async () => {
|
|
1036
|
+
const el = await mount({ series: DT_SERIES, navigatorHandles: true });
|
|
1037
|
+
expect(el.navigatorHandleVariant).to.equal('pill');
|
|
1038
|
+
expect(handleLabel(el, 'start')).to.be.null;
|
|
1039
|
+
expect(handleLabel(el, 'end')).to.be.null;
|
|
1040
|
+
});
|
|
1041
|
+
it('L2. navigator-handle-variant reflects to the attribute', async () => {
|
|
1042
|
+
const el = await mount({ series: DT_SERIES, navigatorHandles: true, navigatorHandleVariant: 'labeled' });
|
|
1043
|
+
expect(el.getAttribute('navigator-handle-variant')).to.equal('labeled');
|
|
1044
|
+
});
|
|
1045
|
+
it('L3. labeled grips carry a grip span and an aria-hidden value label', async () => {
|
|
1046
|
+
const el = await mount({ series: DT_SERIES, navigatorHandles: true, navigatorHandleVariant: 'labeled' });
|
|
1047
|
+
for (const edge of ['start', 'end']) {
|
|
1048
|
+
const g = grip(el, edge);
|
|
1049
|
+
expect(g.querySelector('.navigator-handle-grip'), edge).to.not.be.null;
|
|
1050
|
+
const label = handleLabel(el, edge);
|
|
1051
|
+
expect(label, edge).to.not.be.null;
|
|
1052
|
+
expect(label.getAttribute('aria-hidden'), edge).to.equal('true');
|
|
1053
|
+
}
|
|
1054
|
+
});
|
|
1055
|
+
it('L4. the label shows the short edge value (dateFormat %b %e)', async () => {
|
|
1056
|
+
const el = await mount({ series: DT_SERIES, navigatorHandles: true, navigatorHandleVariant: 'labeled' });
|
|
1057
|
+
expect(handleLabel(el, 'start').textContent.trim()).to.equal(fakeDateFormat('%b %e', DT_MIN));
|
|
1058
|
+
expect(handleLabel(el, 'end').textContent.trim()).to.equal(fakeDateFormat('%b %e', DT_MAX));
|
|
1059
|
+
});
|
|
1060
|
+
it('L5. the label text updates after a keyboard move of that grip', async () => {
|
|
1061
|
+
const el = await mount({ series: DT_SERIES, navigatorHandles: true, navigatorHandleVariant: 'labeled' });
|
|
1062
|
+
const before = handleLabel(el, 'start').textContent.trim();
|
|
1063
|
+
await pressGrip(el, 'start', 'ArrowRight');
|
|
1064
|
+
const after = handleLabel(el, 'start').textContent.trim();
|
|
1065
|
+
expect(after).to.not.equal(before);
|
|
1066
|
+
expect(after).to.equal(fakeDateFormat('%b %e', T0 + DAY));
|
|
1067
|
+
});
|
|
1068
|
+
it('L6. navigatorHandleLabel defaults to active (navigator-overlay--label-active); always drops the class', async () => {
|
|
1069
|
+
const active = await mount({ series: DT_SERIES, navigatorHandles: true, navigatorHandleVariant: 'labeled' });
|
|
1070
|
+
expect(active.navigatorHandleLabel).to.equal('active');
|
|
1071
|
+
expect(active.getAttribute('navigator-handle-label')).to.equal('active');
|
|
1072
|
+
expect(overlay(active).classList.contains('navigator-overlay--label-active')).to.be.true;
|
|
1073
|
+
const always = await mount({
|
|
1074
|
+
series: DT_SERIES, navigatorHandles: true, navigatorHandleVariant: 'labeled', navigatorHandleLabel: 'always',
|
|
1075
|
+
});
|
|
1076
|
+
expect(overlay(always).classList.contains('navigator-overlay--label-active')).to.be.false;
|
|
1077
|
+
});
|
|
1078
|
+
it('L7. label-active is ignored for pill handles', async () => {
|
|
1079
|
+
const el = await mount({ series: DT_SERIES, navigatorHandles: true, navigatorHandleLabel: 'active' });
|
|
1080
|
+
expect(overlay(el).classList.contains('navigator-overlay--label-active')).to.be.false;
|
|
1081
|
+
});
|
|
1082
|
+
it('L8. labeled reserves spacingTop 36 above the master when there is no title', async () => {
|
|
1083
|
+
const el = await mount({ series: DT_SERIES, navigatorHandles: true, navigatorHandleVariant: 'labeled' });
|
|
1084
|
+
expect(masterOpts(el).chart.spacingTop).to.equal(36);
|
|
1085
|
+
});
|
|
1086
|
+
it('L9. labeled with a master title reserves title margin 41 instead', async () => {
|
|
1087
|
+
const el = await mount({
|
|
1088
|
+
series: DT_SERIES, navigatorHandles: true, navigatorHandleVariant: 'labeled', masterTitle: 'Overview',
|
|
1089
|
+
});
|
|
1090
|
+
expect(masterOpts(el).chart.spacingTop).to.be.undefined;
|
|
1091
|
+
expect(masterOpts(el).title.margin).to.equal(41);
|
|
1092
|
+
});
|
|
1093
|
+
it('L10. pill handles reserve no room above the master', async () => {
|
|
1094
|
+
const el = await mount({ series: DT_SERIES, navigatorHandles: true });
|
|
1095
|
+
expect(masterOpts(el).chart.spacingTop).to.be.undefined;
|
|
1096
|
+
});
|
|
1097
|
+
it('L11. navigatorHandleLabelFormat sets the pill text and updates it when changed', async () => {
|
|
1098
|
+
const el = await mount({
|
|
1099
|
+
series: DT_SERIES, navigatorHandles: true, navigatorHandleVariant: 'labeled', navigatorHandleLabelFormat: '%e %b %Y',
|
|
1100
|
+
});
|
|
1101
|
+
expect(el.navigatorHandleLabelFormat).to.equal('%e %b %Y');
|
|
1102
|
+
expect(handleLabel(el, 'start').textContent.trim()).to.equal(fakeDateFormat('%e %b %Y', DT_MIN));
|
|
1103
|
+
el.navigatorHandleLabelFormat = '%d/%m';
|
|
1104
|
+
await el.updateComplete;
|
|
1105
|
+
expect(handleLabel(el, 'end').textContent.trim()).to.equal(fakeDateFormat('%d/%m', DT_MAX));
|
|
1106
|
+
});
|
|
1107
|
+
it('L12. changing the label mode, handle look or mask keeps the current window', async () => {
|
|
1108
|
+
const el = await mount({ series: DT_SERIES, navigatorHandles: true, navigatorDefaultWindow: '3d' });
|
|
1109
|
+
await pressGrip(el, 'start', 'ArrowLeft');
|
|
1110
|
+
const before = { ...nav(el)._window };
|
|
1111
|
+
el.navigatorHandleLabel = 'always';
|
|
1112
|
+
await el.updateComplete;
|
|
1113
|
+
el.navigatorHandleVariant = 'labeled';
|
|
1114
|
+
await el.updateComplete;
|
|
1115
|
+
el.navigatorMask = 'frost';
|
|
1116
|
+
await el.updateComplete;
|
|
1117
|
+
expect(nav(el)._window).to.deep.equal(before);
|
|
1118
|
+
expect(masterBands(el).has('mask-before')).to.be.false;
|
|
1119
|
+
expect(masterOpts(el).chart.spacingTop).to.equal(36);
|
|
1120
|
+
});
|
|
1121
|
+
});
|
|
1122
|
+
describe('NileMasterDetailChart — frost mask', () => {
|
|
1123
|
+
it('M1. navigatorMask defaults to solid and renders no mask elements', async () => {
|
|
1124
|
+
const el = await mount({ series: DT_SERIES, navigatorHandles: true, navigatorDefaultWindow: '3d' });
|
|
1125
|
+
expect(el.navigatorMask).to.equal('solid');
|
|
1126
|
+
expect(masks(el)).to.have.length(0);
|
|
1127
|
+
});
|
|
1128
|
+
it('M2. navigator-mask reflects to the attribute', async () => {
|
|
1129
|
+
const el = await mount({ series: DT_SERIES, navigatorMask: 'frost' });
|
|
1130
|
+
expect(el.getAttribute('navigator-mask')).to.equal('frost');
|
|
1131
|
+
});
|
|
1132
|
+
it('M3. frost renders two mask elements with before / after sides, even without handles', async () => {
|
|
1133
|
+
const el = await mount({ series: DT_SERIES, navigatorMask: 'frost' });
|
|
1134
|
+
const m = masks(el);
|
|
1135
|
+
expect(m).to.have.length(2);
|
|
1136
|
+
expect(m.map((n) => n.dataset.side)).to.deep.equal(['before', 'after']);
|
|
1137
|
+
expect(handles(el)).to.have.length(0);
|
|
1138
|
+
});
|
|
1139
|
+
it('M4. frost adds no mask-before / mask-after plot bands on the master axis', async () => {
|
|
1140
|
+
const el = await mount({ series: DT_SERIES, navigatorHandles: true, navigatorMask: 'frost', navigatorDefaultWindow: '3d' });
|
|
1141
|
+
expect(masterBands(el).has('mask-before')).to.be.false;
|
|
1142
|
+
expect(masterBands(el).has('mask-after')).to.be.false;
|
|
1143
|
+
});
|
|
1144
|
+
it('M5. solid keeps the plot bands and renders no mask elements', async () => {
|
|
1145
|
+
const el = await mount({ series: DT_SERIES, navigatorHandles: true });
|
|
1146
|
+
host(el).applySelection(T0 + 2 * DAY, T0 + 6 * DAY);
|
|
1147
|
+
await el.updateComplete;
|
|
1148
|
+
expect(masterBands(el).has('mask-before')).to.be.true;
|
|
1149
|
+
expect(masterBands(el).has('mask-after')).to.be.true;
|
|
1150
|
+
expect(masks(el)).to.have.length(0);
|
|
1151
|
+
});
|
|
1152
|
+
it('M6. no mask elements in master-only mode', async () => {
|
|
1153
|
+
const el = await mount({ series: DT_SERIES, navigatorMask: 'frost', masterOnly: true });
|
|
1154
|
+
expect(masks(el)).to.have.length(0);
|
|
1155
|
+
});
|
|
1156
|
+
it('M7. no mask elements while the master is collapsed', async () => {
|
|
1157
|
+
const el = await mount({ series: DT_SERIES, navigatorMask: 'frost', masterCollapsible: true });
|
|
1158
|
+
expect(masks(el), 'expanded').to.have.length(2);
|
|
1159
|
+
el.masterCollapsed = true;
|
|
1160
|
+
await el.updateComplete;
|
|
1161
|
+
expect(masks(el), 'collapsed').to.have.length(0);
|
|
1162
|
+
});
|
|
1163
|
+
it('M8. MASTER_DETAIL_CHART_PARTS includes the label and mask parts', () => {
|
|
1164
|
+
expect(MASTER_DETAIL_CHART_PARTS).to.include('navigator-handle-label');
|
|
1165
|
+
expect(MASTER_DETAIL_CHART_PARTS).to.include('navigator-mask');
|
|
1166
|
+
});
|
|
1167
|
+
it('M9. <nile-chart> passes the labeled / label / mask keys through', async () => {
|
|
1168
|
+
const el = await fixture(html `<nile-chart style="display:block;width:600px;height:400px"></nile-chart>`);
|
|
1169
|
+
el.config = {
|
|
1170
|
+
chart: {
|
|
1171
|
+
type: 'master-detail', series: SERIES, navigatorHandles: true,
|
|
1172
|
+
navigatorHandleVariant: 'labeled', navigatorHandleLabel: 'active', navigatorMask: 'frost',
|
|
1173
|
+
},
|
|
1174
|
+
};
|
|
1175
|
+
await el.updateComplete;
|
|
1176
|
+
await el.updateComplete;
|
|
1177
|
+
const inner = el.shadowRoot.querySelector('nile-master-detail-chart');
|
|
1178
|
+
expect(inner, 'inner master-detail chart should render').to.exist;
|
|
1179
|
+
expect(inner.navigatorHandleVariant).to.equal('labeled');
|
|
1180
|
+
expect(inner.navigatorHandleLabel).to.equal('active');
|
|
1181
|
+
expect(inner.navigatorMask).to.equal('frost');
|
|
1182
|
+
});
|
|
1183
|
+
});
|
|
835
1184
|
describe('NileMasterDetailChart — CSS parts', () => {
|
|
836
1185
|
it('MASTER_DETAIL_CHART_PARTS lists exactly the parts it renders', async () => {
|
|
837
1186
|
const el = await mount({
|
|
838
1187
|
series: DT_SERIES, navigatorControls: true, navigatorSlider: true, navigatorPanButtons: true,
|
|
1188
|
+
navigatorHandles: true, navigatorHandleVariant: 'labeled', navigatorMask: 'frost',
|
|
839
1189
|
masterCollapsible: true, navigatorDefaultWindow: '2d',
|
|
840
1190
|
});
|
|
841
1191
|
const seen = new Set([...el.shadowRoot.querySelectorAll('[part]')].flatMap((n) => n.getAttribute('part').split(/\s+/)));
|