@aquera/nile-visualization 2.9.46 → 2.9.48
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 -0
- package/dist/src/nile-chart/nile-chart-config.d.ts +4 -0
- package/dist/src/nile-chart/nile-chart-empty.js +3 -3
- package/dist/src/nile-chart/nile-chart.css.js +0 -12
- package/dist/src/nile-chart/nile-chart.d.ts +5 -29
- package/dist/src/nile-chart/nile-chart.js +71 -190
- package/dist/src/nile-kpi-chart/nile-kpi-chart.js +6 -10
- package/dist/src/nile-master-detail-chart/nile-master-detail-chart.css.js +42 -0
- package/dist/src/nile-master-detail-chart/nile-master-detail-chart.d.ts +49 -0
- package/dist/src/nile-master-detail-chart/nile-master-detail-chart.js +275 -2
- package/dist/src/nile-master-detail-chart/nile-master-detail-chart.test.js +348 -1
- package/package.json +1 -1
- package/dist/src/internal/utils/lite-tooltip.d.ts +0 -5
- package/dist/src/internal/utils/lite-tooltip.js +0 -18
|
@@ -89,7 +89,24 @@ function makeChart(options) {
|
|
|
89
89
|
};
|
|
90
90
|
return chart;
|
|
91
91
|
}
|
|
92
|
-
|
|
92
|
+
// Minimal Highcharts.dateFormat stand-in (UTC) so the navigator caption, which
|
|
93
|
+
// formats datetime ranges through `this._hc.dateFormat(...)`, has something to call.
|
|
94
|
+
function fakeDateFormat(format, timestamp) {
|
|
95
|
+
const d = new Date(timestamp);
|
|
96
|
+
const pad = (n) => String(n).padStart(2, '0');
|
|
97
|
+
return format
|
|
98
|
+
.replace(/%Y/g, String(d.getUTCFullYear()))
|
|
99
|
+
.replace(/%m/g, pad(d.getUTCMonth() + 1))
|
|
100
|
+
.replace(/%d/g, pad(d.getUTCDate()))
|
|
101
|
+
.replace(/%H/g, pad(d.getUTCHours()))
|
|
102
|
+
.replace(/%M/g, pad(d.getUTCMinutes()))
|
|
103
|
+
.replace(/%S/g, pad(d.getUTCSeconds()));
|
|
104
|
+
}
|
|
105
|
+
const makeFakeHC = () => ({
|
|
106
|
+
chart: (_c, options) => makeChart(options),
|
|
107
|
+
setOptions() { },
|
|
108
|
+
dateFormat: fakeDateFormat,
|
|
109
|
+
});
|
|
93
110
|
// --- mount helper (injects the fake before first render) ---------------------
|
|
94
111
|
const mounted = [];
|
|
95
112
|
async function mount(props) {
|
|
@@ -258,5 +275,335 @@ describe('NileChart → master-detail passthrough', () => {
|
|
|
258
275
|
expect(inner.series).to.deep.equal(SERIES);
|
|
259
276
|
expect(inner.stacking).to.equal('normal');
|
|
260
277
|
});
|
|
278
|
+
it('27. passes navigatorControls, navigatorHint and navigatorDefaultWindow down to the inner chart', async () => {
|
|
279
|
+
const el = await fixture(html `<nile-chart style="display:block;width:600px;height:400px"></nile-chart>`);
|
|
280
|
+
el.config = {
|
|
281
|
+
chart: { type: 'master-detail', series: SERIES, navigatorControls: true, navigatorHint: 'drag to zoom', navigatorDefaultWindow: '7d' },
|
|
282
|
+
};
|
|
283
|
+
await el.updateComplete;
|
|
284
|
+
await el.updateComplete;
|
|
285
|
+
const inner = el.shadowRoot.querySelector('nile-master-detail-chart');
|
|
286
|
+
expect(inner, 'inner master-detail chart should render').to.exist;
|
|
287
|
+
expect(inner.navigatorControls).to.be.true;
|
|
288
|
+
expect(inner.navigatorHint).to.equal('drag to zoom');
|
|
289
|
+
expect(inner.navigatorDefaultWindow).to.equal('7d');
|
|
290
|
+
});
|
|
291
|
+
});
|
|
292
|
+
// --- navigator controls (spec: nile-master-detail-chart-navigator.md) --------
|
|
293
|
+
//
|
|
294
|
+
// Evenly spaced datetime data: 9 points one day apart, so every window edge the
|
|
295
|
+
// controls produce lands on an exact, predictable timestamp.
|
|
296
|
+
const DAY = 86400000;
|
|
297
|
+
const T0 = Date.UTC(2026, 8, 25, 3, 11, 21); // 2026-09-25 03:11:21 UTC
|
|
298
|
+
const DT_DATA = Array.from({ length: 9 }, (_, i) => ({ x: T0 + i * DAY, y: i }));
|
|
299
|
+
const DT_MIN = T0;
|
|
300
|
+
const DT_MAX = T0 + 8 * DAY; // full span = 8 days = 8 * pointStep
|
|
301
|
+
const DT_SERIES = [
|
|
302
|
+
{ name: 'Clean', data: DT_DATA, color: '#0000ff' },
|
|
303
|
+
{ name: 'Needs attention', data: DT_DATA.map((p) => ({ x: p.x, y: p.y * 2 })), color: '#ff0000' },
|
|
304
|
+
];
|
|
305
|
+
const nav = (el) => el;
|
|
306
|
+
const navigatorPart = (el) => el.shadowRoot.querySelector('[part~="navigator"]');
|
|
307
|
+
const captionPart = (el) => el.shadowRoot.querySelector('[part~="navigator-caption"]');
|
|
308
|
+
const btn = (el, label) => el.shadowRoot.querySelector(`[part~="navigator"] [aria-label="${label}"]`);
|
|
309
|
+
const slider = (el) => el.shadowRoot.querySelector('[part~="navigator"] nile-slider');
|
|
310
|
+
// Every control step goes through applySelection / setExtremes and re-emits
|
|
311
|
+
// `nile-chart-selection { min, max }`. Collect them after mount (the init-time
|
|
312
|
+
// emission has already fired by then).
|
|
313
|
+
function selectionSpy(el) {
|
|
314
|
+
const seen = [];
|
|
315
|
+
el.addEventListener('nile-chart-selection', (e) => seen.push(e.detail));
|
|
316
|
+
return seen;
|
|
317
|
+
}
|
|
318
|
+
const fmt = (ts) => fakeDateFormat('%Y-%m-%d %H:%M:%S', ts);
|
|
319
|
+
const isDisabled = (node) => !!node && (node.hasAttribute('disabled') || node.disabled === true);
|
|
320
|
+
describe('NileMasterDetailChart — navigator controls', () => {
|
|
321
|
+
it('28. renders no control bar without navigator-controls', async () => {
|
|
322
|
+
const el = await mount({ series: DT_SERIES });
|
|
323
|
+
expect(navigatorPart(el)).to.be.null;
|
|
324
|
+
});
|
|
325
|
+
it('29. renders the control bar with navigator-controls (master+detail)', async () => {
|
|
326
|
+
const el = await mount({ series: DT_SERIES, navigatorControls: true });
|
|
327
|
+
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
|
+
expect(btn(el, 'Zoom in')).to.not.be.null;
|
|
331
|
+
expect(btn(el, 'Zoom out')).to.not.be.null;
|
|
332
|
+
expect(slider(el)).to.not.be.null;
|
|
333
|
+
});
|
|
334
|
+
it('30. renders the control bar in master-only mode', async () => {
|
|
335
|
+
const el = await mount({ series: DT_SERIES, navigatorControls: true, masterOnly: true });
|
|
336
|
+
expect(navigatorPart(el)).to.not.be.null;
|
|
337
|
+
});
|
|
338
|
+
it('31. exposes navigator, navigator-caption and navigator-hint parts', async () => {
|
|
339
|
+
const el = await mount({ series: DT_SERIES, navigatorControls: true, navigatorHint: 'blue = clean' });
|
|
340
|
+
expect(navigatorPart(el)).to.not.be.null;
|
|
341
|
+
expect(captionPart(el)).to.not.be.null;
|
|
342
|
+
expect(el.shadowRoot.querySelector('[part~="navigator-hint"]')).to.not.be.null;
|
|
343
|
+
});
|
|
344
|
+
it('32. navigator-controls reflects to the attribute', async () => {
|
|
345
|
+
const el = await mount({ series: DT_SERIES, navigatorControls: true });
|
|
346
|
+
expect(el.hasAttribute('navigator-controls')).to.be.true;
|
|
347
|
+
});
|
|
348
|
+
it('33. at full range pan/zoom-out/slider are disabled, zoom in enabled', async () => {
|
|
349
|
+
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
|
+
expect(isDisabled(btn(el, 'Zoom out')), 'zoom out').to.be.true;
|
|
353
|
+
expect(isDisabled(slider(el)), 'slider').to.be.true;
|
|
354
|
+
expect(isDisabled(btn(el, 'Zoom in')), 'zoom in').to.be.false;
|
|
355
|
+
});
|
|
356
|
+
it('34. zoom in halves the window around its centre and fires nile-chart-selection', async () => {
|
|
357
|
+
const el = await mount({ series: DT_SERIES, navigatorControls: true });
|
|
358
|
+
const seen = selectionSpy(el);
|
|
359
|
+
nav(el).zoomBy(0.5);
|
|
360
|
+
await el.updateComplete;
|
|
361
|
+
// centre = T0 + 4d, new width = 4d → [T0+2d, T0+6d]
|
|
362
|
+
expect(seen[seen.length - 1]).to.deep.equal({ min: T0 + 2 * DAY, max: T0 + 6 * DAY });
|
|
363
|
+
});
|
|
364
|
+
it('35. the zoom-in button halves the window', async () => {
|
|
365
|
+
const el = await mount({ series: DT_SERIES, navigatorControls: true });
|
|
366
|
+
const seen = selectionSpy(el);
|
|
367
|
+
btn(el, 'Zoom in').click();
|
|
368
|
+
await el.updateComplete;
|
|
369
|
+
expect(seen[seen.length - 1]).to.deep.equal({ min: T0 + 2 * DAY, max: T0 + 6 * DAY });
|
|
370
|
+
});
|
|
371
|
+
it('36. zoom out doubles the window toward the data range', async () => {
|
|
372
|
+
const el = await mount({ series: DT_SERIES, navigatorControls: true });
|
|
373
|
+
nav(el).zoomBy(0.5); // → width 4d [T0+2d, T0+6d]
|
|
374
|
+
await el.updateComplete;
|
|
375
|
+
const seen = selectionSpy(el);
|
|
376
|
+
nav(el).zoomBy(2); // double → width 8d, clamped to full range
|
|
377
|
+
await el.updateComplete;
|
|
378
|
+
expect(seen[seen.length - 1]).to.deep.equal({ min: DT_MIN, max: DT_MAX });
|
|
379
|
+
});
|
|
380
|
+
it('37. zoom out is disabled at full range', async () => {
|
|
381
|
+
const el = await mount({ series: DT_SERIES, navigatorControls: true });
|
|
382
|
+
expect(isDisabled(btn(el, 'Zoom out'))).to.be.true;
|
|
383
|
+
});
|
|
384
|
+
it('38. pan forward moves by 25% of the width and preserves the width', async () => {
|
|
385
|
+
const el = await mount({ series: DT_SERIES, navigatorControls: true });
|
|
386
|
+
nav(el).zoomBy(0.5); // width 4d → [T0+2d, T0+6d]
|
|
387
|
+
await el.updateComplete;
|
|
388
|
+
const seen = selectionSpy(el);
|
|
389
|
+
nav(el).panBy(1); // +25% of 4d = +1d → [T0+3d, T0+7d]
|
|
390
|
+
await el.updateComplete;
|
|
391
|
+
const w = seen[seen.length - 1];
|
|
392
|
+
expect(w).to.deep.equal({ min: T0 + 3 * DAY, max: T0 + 7 * DAY });
|
|
393
|
+
expect(w.max - w.min).to.equal(4 * DAY);
|
|
394
|
+
});
|
|
395
|
+
it('39. pan back moves the window toward the start, same width', async () => {
|
|
396
|
+
const el = await mount({ series: DT_SERIES, navigatorControls: true });
|
|
397
|
+
nav(el).zoomBy(0.5); // [T0+2d, T0+6d]
|
|
398
|
+
await el.updateComplete;
|
|
399
|
+
const seen = selectionSpy(el);
|
|
400
|
+
nav(el).panBy(-1); // -1d → [T0+1d, T0+5d]
|
|
401
|
+
await el.updateComplete;
|
|
402
|
+
expect(seen[seen.length - 1]).to.deep.equal({ min: T0 + 1 * DAY, max: T0 + 5 * DAY });
|
|
403
|
+
});
|
|
404
|
+
it('40. pan forward clamps at the data end, preserving the width', async () => {
|
|
405
|
+
const el = await mount({ series: DT_SERIES, navigatorControls: true });
|
|
406
|
+
nav(el).zoomBy(0.5); // width 4d → [T0+2d, T0+6d]
|
|
407
|
+
await el.updateComplete;
|
|
408
|
+
const seen = selectionSpy(el);
|
|
409
|
+
nav(el).panBy(1); // [T0+3d, T0+7d]
|
|
410
|
+
nav(el).panBy(1); // [T0+4d, T0+8d] (hits end)
|
|
411
|
+
nav(el).panBy(1); // clamped, stays [T0+4d, T0+8d]
|
|
412
|
+
await el.updateComplete;
|
|
413
|
+
const w = seen[seen.length - 1];
|
|
414
|
+
expect(w).to.deep.equal({ min: T0 + 4 * DAY, max: DT_MAX });
|
|
415
|
+
expect(w.max - w.min).to.equal(4 * DAY);
|
|
416
|
+
});
|
|
417
|
+
it('41. pan forward is disabled once the window is at the data end', async () => {
|
|
418
|
+
const el = await mount({ series: DT_SERIES, navigatorControls: true });
|
|
419
|
+
nav(el).zoomBy(0.5);
|
|
420
|
+
nav(el).panBy(1);
|
|
421
|
+
nav(el).panBy(1); // [T0+4d, T0+8d] at end
|
|
422
|
+
await el.updateComplete;
|
|
423
|
+
expect(isDisabled(btn(el, 'Pan forward'))).to.be.true;
|
|
424
|
+
expect(isDisabled(btn(el, 'Pan back'))).to.be.false;
|
|
425
|
+
});
|
|
426
|
+
it('42. zoom in stops at one point step and disables the zoom-in button', async () => {
|
|
427
|
+
const el = await mount({ series: DT_SERIES, navigatorControls: true });
|
|
428
|
+
// 8d → 4d → 2d → 1d (= pointStep)
|
|
429
|
+
nav(el).zoomBy(0.5);
|
|
430
|
+
nav(el).zoomBy(0.5);
|
|
431
|
+
nav(el).zoomBy(0.5);
|
|
432
|
+
await el.updateComplete;
|
|
433
|
+
const atStep = nav(el)._window;
|
|
434
|
+
expect(atStep.max - atStep.min).to.equal(DAY);
|
|
435
|
+
expect(isDisabled(btn(el, 'Zoom in'))).to.be.true;
|
|
436
|
+
// A further zoom-in must not shrink below the point step.
|
|
437
|
+
const seen = selectionSpy(el);
|
|
438
|
+
nav(el).zoomBy(0.5);
|
|
439
|
+
await el.updateComplete;
|
|
440
|
+
const after = nav(el)._window;
|
|
441
|
+
expect(after.max - after.min).to.equal(DAY);
|
|
442
|
+
if (seen.length)
|
|
443
|
+
expect(seen[seen.length - 1].max - seen[seen.length - 1].min).to.equal(DAY);
|
|
444
|
+
});
|
|
445
|
+
it('43. slider change moves the window start while keeping its width', async () => {
|
|
446
|
+
const el = await mount({ series: DT_SERIES, navigatorControls: true });
|
|
447
|
+
nav(el).zoomBy(0.5); // width 4d, slider now enabled
|
|
448
|
+
await el.updateComplete;
|
|
449
|
+
const seen = selectionSpy(el);
|
|
450
|
+
const s = slider(el);
|
|
451
|
+
// 0–1000 positions: 500 → start = dataMin + 0.5 * (span − width) = T0 + 2d
|
|
452
|
+
s.value = 500;
|
|
453
|
+
s.dispatchEvent(new CustomEvent('nile-change-end', { detail: { value: 500 }, bubbles: true, composed: true }));
|
|
454
|
+
await el.updateComplete;
|
|
455
|
+
const w = seen[seen.length - 1];
|
|
456
|
+
expect(w.max - w.min).to.equal(4 * DAY);
|
|
457
|
+
expect(w).to.deep.equal({ min: T0 + 2 * DAY, max: T0 + 6 * DAY });
|
|
458
|
+
});
|
|
459
|
+
it('44. resetZoom restores the full window, caption and controls', async () => {
|
|
460
|
+
const el = await mount({ series: DT_SERIES, navigatorControls: true });
|
|
461
|
+
nav(el).zoomBy(0.5);
|
|
462
|
+
await el.updateComplete;
|
|
463
|
+
const seen = selectionSpy(el);
|
|
464
|
+
el.resetZoom();
|
|
465
|
+
await el.updateComplete;
|
|
466
|
+
expect(seen[seen.length - 1]).to.deep.equal({ min: DT_MIN, max: DT_MAX });
|
|
467
|
+
expect(nav(el)._window).to.deep.equal({ min: DT_MIN, max: DT_MAX });
|
|
468
|
+
// back at full range → zoom out / pan disabled again
|
|
469
|
+
expect(isDisabled(btn(el, 'Zoom out'))).to.be.true;
|
|
470
|
+
expect(captionPart(el).textContent).to.contain(`${fmt(DT_MIN)} → ${fmt(DT_MAX)}`);
|
|
471
|
+
});
|
|
472
|
+
it('45. a master drag selection updates the window and caption', async () => {
|
|
473
|
+
const el = await mount({ series: DT_SERIES, navigatorControls: true });
|
|
474
|
+
host(el).applySelection(T0 + 1 * DAY, T0 + 5 * DAY);
|
|
475
|
+
el._window = { min: T0 + 1 * DAY, max: T0 + 5 * DAY };
|
|
476
|
+
await el.updateComplete;
|
|
477
|
+
expect(captionPart(el).textContent).to.contain(`${fmt(T0 + 1 * DAY)} → ${fmt(T0 + 5 * DAY)}`);
|
|
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');
|
|
488
|
+
});
|
|
489
|
+
it('48. a control step refilters every detail series in master+detail mode', async () => {
|
|
490
|
+
const el = await mount({ series: DT_SERIES, navigatorControls: true });
|
|
491
|
+
nav(el).zoomBy(0.5); // [T0+2d, T0+6d] → points at 2,3,4,5,6 days = 5 per series
|
|
492
|
+
await el.updateComplete;
|
|
493
|
+
expect(detailSeries(el).map(pointCount)).to.deep.equal([5, 5]);
|
|
494
|
+
});
|
|
495
|
+
});
|
|
496
|
+
describe('NileMasterDetailChart — navigator icon buttons', () => {
|
|
497
|
+
it('56. each button shows only an icon and is named by title and aria-label', async () => {
|
|
498
|
+
const el = await mount({ series: DT_SERIES, navigatorControls: true });
|
|
499
|
+
for (const label of ['Pan back', 'Pan forward', 'Zoom out', 'Zoom in']) {
|
|
500
|
+
const b = btn(el, label);
|
|
501
|
+
expect(b, label).to.not.be.null;
|
|
502
|
+
expect(b.getAttribute('title'), label).to.equal(label);
|
|
503
|
+
expect(b.textContent.trim(), label).to.equal('');
|
|
504
|
+
expect(b.querySelector('nile-glyph'), label).to.not.be.null;
|
|
505
|
+
}
|
|
506
|
+
});
|
|
507
|
+
});
|
|
508
|
+
describe('NileMasterDetailChart — navigator default window', () => {
|
|
509
|
+
it('49. a fraction opens on that share of the range, ending at the latest data', async () => {
|
|
510
|
+
const el = await mount({ series: DT_SERIES, navigatorControls: true, navigatorDefaultWindow: '0.25' });
|
|
511
|
+
expect(nav(el)._window).to.deep.equal({ min: DT_MAX - 2 * DAY, max: DT_MAX });
|
|
512
|
+
});
|
|
513
|
+
it('50. a duration opens on that span on a datetime axis', async () => {
|
|
514
|
+
const el = await mount({ series: DT_SERIES, navigatorControls: true, navigatorDefaultWindow: '3d' });
|
|
515
|
+
expect(nav(el)._window).to.deep.equal({ min: DT_MAX - 3 * DAY, max: DT_MAX });
|
|
516
|
+
});
|
|
517
|
+
it('51. the slider, pan back and zoom out are enabled on load', async () => {
|
|
518
|
+
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
|
+
expect(isDisabled(btn(el, 'Zoom out')), 'zoom out').to.be.false;
|
|
522
|
+
expect(slider(el).value, 'thumb at the end').to.equal(1000);
|
|
523
|
+
});
|
|
524
|
+
it('52. selection-min / selection-max win over the default window', async () => {
|
|
525
|
+
const el = await mount({
|
|
526
|
+
series: DT_SERIES, navigatorControls: true, navigatorDefaultWindow: '0.25',
|
|
527
|
+
selectionMin: T0 + DAY, selectionMax: T0 + 3 * DAY,
|
|
528
|
+
});
|
|
529
|
+
expect(nav(el)._window).to.deep.equal({ min: T0 + DAY, max: T0 + 3 * DAY });
|
|
530
|
+
});
|
|
531
|
+
it('53. is ignored without navigator-controls, and when empty or invalid', async () => {
|
|
532
|
+
for (const props of [
|
|
533
|
+
{ navigatorDefaultWindow: '0.25' },
|
|
534
|
+
{ navigatorControls: true, navigatorDefaultWindow: '' },
|
|
535
|
+
{ navigatorControls: true, navigatorDefaultWindow: 'soon' },
|
|
536
|
+
{ navigatorControls: true, navigatorDefaultWindow: '2' },
|
|
537
|
+
{ navigatorControls: true, navigatorDefaultWindow: '30d' },
|
|
538
|
+
]) {
|
|
539
|
+
const el = await mount({ series: DT_SERIES, ...props });
|
|
540
|
+
expect(nav(el)._window, JSON.stringify(props)).to.deep.equal({ min: DT_MIN, max: DT_MAX });
|
|
541
|
+
}
|
|
542
|
+
});
|
|
543
|
+
it('54. a duration is ignored on a non-datetime axis', async () => {
|
|
544
|
+
const el = await mount({ series: DT_SERIES, navigatorControls: true, navigatorDefaultWindow: '3d', xAxisType: 'linear' });
|
|
545
|
+
expect(nav(el)._window).to.deep.equal({ min: DT_MIN, max: DT_MAX });
|
|
546
|
+
});
|
|
547
|
+
it('55. resetZoom returns to the full range', async () => {
|
|
548
|
+
const el = await mount({ series: DT_SERIES, navigatorControls: true, navigatorDefaultWindow: '0.25' });
|
|
549
|
+
el.resetZoom();
|
|
550
|
+
await el.updateComplete;
|
|
551
|
+
expect(nav(el)._window).to.deep.equal({ min: DT_MIN, max: DT_MAX });
|
|
552
|
+
});
|
|
553
|
+
});
|
|
554
|
+
describe('NileMasterDetailChart — navigator snapping, log scale, categories, small data', () => {
|
|
555
|
+
const xsOf = (series) => new Set(series.flatMap((s) => s.data.map((p) => p.x)));
|
|
556
|
+
const EIGHT = [{ name: 'A', data: Array.from({ length: 8 }, (_, i) => ({ x: T0 + i * DAY, y: i })) }];
|
|
557
|
+
it('57. a zoom that lands between points snaps both edges to data points', async () => {
|
|
558
|
+
const el = await mount({ series: EIGHT, navigatorControls: true });
|
|
559
|
+
nav(el).zoomBy(0.5); // centre 3.5d, width 3.5d → 1.75d..5.25d → snaps to 2d..5d
|
|
560
|
+
await el.updateComplete;
|
|
561
|
+
const w = nav(el)._window;
|
|
562
|
+
expect(xsOf(EIGHT).has(w.min) && xsOf(EIGHT).has(w.max), JSON.stringify(w)).to.be.true;
|
|
563
|
+
expect(w).to.deep.equal({ min: T0 + 2 * DAY, max: T0 + 5 * DAY });
|
|
564
|
+
});
|
|
565
|
+
it('58. pan always moves at least one data point', async () => {
|
|
566
|
+
const el = await mount({ series: EIGHT, navigatorControls: true, selectionMin: T0, selectionMax: T0 + DAY });
|
|
567
|
+
nav(el).panBy(1); // 25% of one step would snap back; it moves one point instead
|
|
568
|
+
await el.updateComplete;
|
|
569
|
+
expect(nav(el)._window).to.deep.equal({ min: T0 + DAY, max: T0 + 2 * DAY });
|
|
570
|
+
});
|
|
571
|
+
it('59. a slider position between points snaps to data points', async () => {
|
|
572
|
+
const el = await mount({ series: EIGHT, navigatorControls: true, selectionMin: T0, selectionMax: T0 + 2 * DAY });
|
|
573
|
+
const s = slider(el);
|
|
574
|
+
s.dispatchEvent(new CustomEvent('nile-change-end', { detail: { value: 333 } })); // start ≈ 1.67d → 2d
|
|
575
|
+
await el.updateComplete;
|
|
576
|
+
expect(nav(el)._window).to.deep.equal({ min: T0 + 2 * DAY, max: T0 + 4 * DAY });
|
|
577
|
+
});
|
|
578
|
+
it('60. the default window snaps to data points', async () => {
|
|
579
|
+
const el = await mount({ series: DT_SERIES, navigatorControls: true, navigatorDefaultWindow: '0.3' });
|
|
580
|
+
expect(nav(el)._window).to.deep.equal({ min: DT_MAX - 2 * DAY, max: DT_MAX }); // 2.4d → 2d
|
|
581
|
+
});
|
|
582
|
+
it('61. on a logarithmic axis pan and zoom work on the log scale', async () => {
|
|
583
|
+
const LOG = [{ name: 'A', data: Array.from({ length: 9 }, (_, i) => ({ x: 10 ** i, y: i })) }];
|
|
584
|
+
const el = await mount({ series: LOG, navigatorControls: true, xAxisType: 'logarithmic' });
|
|
585
|
+
nav(el).zoomBy(0.5); // decades 0..8 → 2..6
|
|
586
|
+
await el.updateComplete;
|
|
587
|
+
expect(nav(el)._window).to.deep.equal({ min: 1e2, max: 1e6 });
|
|
588
|
+
nav(el).panBy(1); // 25% of 4 decades = 1 decade
|
|
589
|
+
await el.updateComplete;
|
|
590
|
+
expect(nav(el)._window).to.deep.equal({ min: 1e3, max: 1e7 });
|
|
591
|
+
});
|
|
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
|
+
it('63. no control bar with fewer than two distinct x values', async () => {
|
|
601
|
+
for (const data of [[], [{ x: T0, y: 1 }], [{ x: T0, y: 1 }, { x: T0, y: 2 }]]) {
|
|
602
|
+
const el = await mount({ data, navigatorControls: true });
|
|
603
|
+
expect(navigatorPart(el), JSON.stringify(data)).to.be.null;
|
|
604
|
+
}
|
|
605
|
+
const two = await mount({ data: [{ x: T0, y: 1 }, { x: T0 + DAY, y: 2 }], navigatorControls: true });
|
|
606
|
+
expect(navigatorPart(two)).to.not.be.null;
|
|
607
|
+
});
|
|
261
608
|
});
|
|
262
609
|
//# sourceMappingURL=nile-master-detail-chart.test.js.map
|
package/package.json
CHANGED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
/** Default size limits for every nile-lite-tooltip the charts render. */
|
|
2
|
-
export declare const LITE_TOOLTIP_MAX_WIDTH = "var(--ng-width-64)";
|
|
3
|
-
export declare const LITE_TOOLTIP_MAX_HEIGHT = 250;
|
|
4
|
-
/** `nile-show` handler: keeps the whole tooltip box within the limits and scrolls any overflow. */
|
|
5
|
-
export declare function limitLiteTooltipHeight(e: Event): void;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/** Default size limits for every nile-lite-tooltip the charts render. */
|
|
2
|
-
export const LITE_TOOLTIP_MAX_WIDTH = 'var(--ng-width-64)';
|
|
3
|
-
export const LITE_TOOLTIP_MAX_HEIGHT = 250;
|
|
4
|
-
/** `nile-show` handler: keeps the whole tooltip box within the limits and scrolls any overflow. */
|
|
5
|
-
export function limitLiteTooltipHeight(e) {
|
|
6
|
-
const popper = e.detail?.instance?.popper;
|
|
7
|
-
const box = popper?.querySelector('.tippy-box');
|
|
8
|
-
const content = popper?.querySelector('.tippy-content');
|
|
9
|
-
if (!box || !content)
|
|
10
|
-
return;
|
|
11
|
-
box.style.boxSizing = 'border-box';
|
|
12
|
-
box.style.maxHeight = `${LITE_TOOLTIP_MAX_HEIGHT}px`;
|
|
13
|
-
box.style.display = 'flex';
|
|
14
|
-
box.style.flexDirection = 'column';
|
|
15
|
-
content.style.minHeight = '0';
|
|
16
|
-
content.style.overflowY = 'auto';
|
|
17
|
-
}
|
|
18
|
-
//# sourceMappingURL=lite-tooltip.js.map
|