@aquera/nile-visualization 2.9.41 → 2.9.43
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 +7 -0
- package/dist/src/index.d.ts +2 -2
- package/dist/src/internal/echarts/translate-config.js +42 -2
- package/dist/src/internal/types/chart-master-detail-config.type.d.ts +7 -2
- package/dist/src/nile-chart/nile-chart-config.d.ts +7 -2
- package/dist/src/nile-chart/nile-chart-empty.js +10 -0
- package/dist/src/nile-chart/nile-chart.css.js +2 -1
- package/dist/src/nile-chart/nile-chart.js +3 -1
- package/dist/src/nile-kpi-chart/index.d.ts +1 -1
- package/dist/src/nile-kpi-chart/nile-kpi-chart.css.d.ts +1 -1
- package/dist/src/nile-kpi-chart/nile-kpi-chart.css.js +87 -33
- package/dist/src/nile-kpi-chart/nile-kpi-chart.d.ts +10 -5
- package/dist/src/nile-kpi-chart/nile-kpi-chart.js +105 -19
- package/dist/src/nile-kpi-chart/nile-kpi-chart.test.d.ts +1 -0
- package/dist/src/nile-kpi-chart/nile-kpi-chart.test.js +373 -0
- package/dist/src/nile-master-detail-chart/index.d.ts +1 -1
- package/dist/src/nile-master-detail-chart/nile-master-detail-chart.d.ts +24 -1
- package/dist/src/nile-master-detail-chart/nile-master-detail-chart.js +90 -37
- package/dist/src/nile-master-detail-chart/nile-master-detail-chart.test.d.ts +2 -0
- package/dist/src/nile-master-detail-chart/nile-master-detail-chart.test.js +262 -0
- package/package.json +1 -1
|
@@ -7,6 +7,7 @@ import { applySeparatedChartConfig } from '../internal/utils/separated-chart-con
|
|
|
7
7
|
import { deepMerge } from '../internal/utils/deep-merge.js';
|
|
8
8
|
import { withResponsiveDefaults } from '../internal/utils/responsive-defaults.js';
|
|
9
9
|
import { styles } from './nile-master-detail-chart.css.js';
|
|
10
|
+
export const MASTER_DETAIL_STACKING = ['normal', 'percent'];
|
|
10
11
|
export const MASTER_DETAIL_SERIES_TYPES = [
|
|
11
12
|
'area',
|
|
12
13
|
'line',
|
|
@@ -31,6 +32,13 @@ let NileMasterDetailChart = class NileMasterDetailChart extends NileElement {
|
|
|
31
32
|
this.data = [];
|
|
32
33
|
this.seriesName = '';
|
|
33
34
|
this.seriesColor = '';
|
|
35
|
+
/**
|
|
36
|
+
* Several named series. When non-empty it replaces `data` / `seriesName` /
|
|
37
|
+
* `seriesColor`. Series should share x values so stacks line up.
|
|
38
|
+
*/
|
|
39
|
+
this.series = [];
|
|
40
|
+
/** Stack the series on both panes: `normal`, `percent`, or `''` for none. */
|
|
41
|
+
this.stacking = '';
|
|
34
42
|
this.detailType = 'area';
|
|
35
43
|
this.masterType = 'area';
|
|
36
44
|
this.masterOnly = false;
|
|
@@ -143,6 +151,8 @@ let NileMasterDetailChart = class NileMasterDetailChart extends NileElement {
|
|
|
143
151
|
}
|
|
144
152
|
const props = [
|
|
145
153
|
'data',
|
|
154
|
+
'series',
|
|
155
|
+
'stacking',
|
|
146
156
|
'options',
|
|
147
157
|
'masterOptions',
|
|
148
158
|
'height',
|
|
@@ -168,7 +178,7 @@ let NileMasterDetailChart = class NileMasterDetailChart extends NileElement {
|
|
|
168
178
|
'masterHeight', 'loadingText', 'loadingColor', 'loadingFontSize', 'loadingFontFamily', 'loadingBg'];
|
|
169
179
|
if (cssVarProps.some(p => changedProperties.has(p)))
|
|
170
180
|
this._syncCssVars();
|
|
171
|
-
const objectProps = new Set(['data', 'options', 'masterOptions', 'legend']);
|
|
181
|
+
const objectProps = new Set(['data', 'series', 'options', 'masterOptions', 'legend']);
|
|
172
182
|
const reallyChanged = (p) => {
|
|
173
183
|
if (!changedProperties.has(p))
|
|
174
184
|
return false;
|
|
@@ -217,14 +227,44 @@ let NileMasterDetailChart = class NileMasterDetailChart extends NileElement {
|
|
|
217
227
|
});
|
|
218
228
|
this.resizeObserver.observe(target);
|
|
219
229
|
}
|
|
220
|
-
|
|
221
|
-
|
|
230
|
+
/** `series` when given, else one series built from `data` / `seriesName` / `seriesColor`. */
|
|
231
|
+
get _seriesList() {
|
|
232
|
+
if (Array.isArray(this.series) && this.series.length)
|
|
233
|
+
return this.series;
|
|
234
|
+
return [{ name: this.seriesName || 'Series', data: this.data ?? [], color: this.seriesColor || undefined }];
|
|
235
|
+
}
|
|
236
|
+
get _isMultiSeries() {
|
|
237
|
+
return this._seriesList.length > 1;
|
|
238
|
+
}
|
|
239
|
+
get _stackingMode() {
|
|
240
|
+
return MASTER_DETAIL_STACKING.includes(this.stacking)
|
|
241
|
+
? this.stacking
|
|
242
|
+
: undefined;
|
|
243
|
+
}
|
|
244
|
+
/** Sorted, de-duplicated x values across every series. */
|
|
245
|
+
_allXs() {
|
|
246
|
+
const xs = new Set();
|
|
247
|
+
for (const s of this._seriesList)
|
|
248
|
+
for (const p of s.data ?? [])
|
|
249
|
+
xs.add(p.x);
|
|
250
|
+
return [...xs].sort((a, b) => a - b);
|
|
251
|
+
}
|
|
252
|
+
mapPoints(points, min = -Infinity, max = Infinity) {
|
|
253
|
+
return (points ?? []).filter(p => p.x >= min && p.x <= max).map(p => ({ x: p.x, y: p.y }));
|
|
254
|
+
}
|
|
255
|
+
buildSeries(type, min, max) {
|
|
256
|
+
return this._seriesList.map(s => ({
|
|
257
|
+
type,
|
|
258
|
+
name: s.name,
|
|
259
|
+
data: this.mapPoints(s.data, min, max),
|
|
260
|
+
color: s.color || undefined,
|
|
261
|
+
}));
|
|
222
262
|
}
|
|
223
263
|
dataExtremes() {
|
|
224
|
-
const xs = this.
|
|
264
|
+
const xs = this._allXs();
|
|
225
265
|
return {
|
|
226
|
-
dataMin: xs.length ?
|
|
227
|
-
dataMax: xs.length ?
|
|
266
|
+
dataMin: xs.length ? xs[0] : 0,
|
|
267
|
+
dataMax: xs.length ? xs[xs.length - 1] : 0,
|
|
228
268
|
};
|
|
229
269
|
}
|
|
230
270
|
pointStep(xs) {
|
|
@@ -243,17 +283,17 @@ let NileMasterDetailChart = class NileMasterDetailChart extends NileElement {
|
|
|
243
283
|
_zoomWindow(min, max) {
|
|
244
284
|
if (!this._isCategoricalMaster || min !== max)
|
|
245
285
|
return { min, max };
|
|
246
|
-
const eps = this.pointStep(this.
|
|
286
|
+
const eps = this.pointStep(this._allXs()) * 1e-4;
|
|
247
287
|
return { min: min - eps, max: max + eps };
|
|
248
288
|
}
|
|
249
289
|
_masterMinRange() {
|
|
250
|
-
const step = this.pointStep(this.
|
|
290
|
+
const step = this.pointStep(this._allXs());
|
|
251
291
|
if (!step)
|
|
252
292
|
return undefined;
|
|
253
293
|
return this._isCategoricalMaster ? step * 1e-5 : step;
|
|
254
294
|
}
|
|
255
295
|
snapSelection(min, max) {
|
|
256
|
-
const xs = this.
|
|
296
|
+
const xs = this._allXs();
|
|
257
297
|
if (xs.length === 0)
|
|
258
298
|
return { min, max };
|
|
259
299
|
const step = this.pointStep(xs);
|
|
@@ -275,10 +315,22 @@ let NileMasterDetailChart = class NileMasterDetailChart extends NileElement {
|
|
|
275
315
|
}
|
|
276
316
|
buildDetailOptions() {
|
|
277
317
|
const { min, max } = this.defaultSelection();
|
|
278
|
-
const
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
318
|
+
const multi = this._isMultiSeries;
|
|
319
|
+
const stacking = this._stackingMode;
|
|
320
|
+
// Single series keeps its original tooltip. Several series get one shared
|
|
321
|
+
// tooltip headed by the x value, a line per series, and the share in percent mode.
|
|
322
|
+
const tooltip = multi
|
|
323
|
+
? {
|
|
324
|
+
shared: true,
|
|
325
|
+
pointFormat: stacking === 'percent'
|
|
326
|
+
? '<span style="color:{point.color}">●</span> {series.name}: <b>{point.y}</b> ({point.percentage:.0f}%)<br/>'
|
|
327
|
+
: '<span style="color:{point.color}">●</span> {series.name}: <b>{point.y}</b><br/>',
|
|
328
|
+
}
|
|
329
|
+
: {
|
|
330
|
+
headerFormat: '<b>{series.name}</b><br>',
|
|
331
|
+
pointFormat: '{point.x} : {point.y}',
|
|
332
|
+
shared: true,
|
|
333
|
+
};
|
|
282
334
|
const merged = deepMerge({
|
|
283
335
|
chart: { type: this.detailType, reflow: true },
|
|
284
336
|
title: { text: this.detailTitle || undefined },
|
|
@@ -292,25 +344,15 @@ let NileMasterDetailChart = class NileMasterDetailChart extends NileElement {
|
|
|
292
344
|
min: this.yAxisMin ?? undefined,
|
|
293
345
|
max: this.yAxisMax ?? undefined,
|
|
294
346
|
},
|
|
295
|
-
tooltip
|
|
296
|
-
|
|
297
|
-
pointFormat: '{point.x} : {point.y}',
|
|
298
|
-
shared: true,
|
|
299
|
-
},
|
|
300
|
-
legend: { enabled: false },
|
|
347
|
+
tooltip,
|
|
348
|
+
legend: { enabled: multi },
|
|
301
349
|
plotOptions: {
|
|
302
350
|
series: {
|
|
351
|
+
stacking,
|
|
303
352
|
marker: { enabled: false, states: { hover: { enabled: true, radius: 3 } } },
|
|
304
353
|
},
|
|
305
354
|
},
|
|
306
|
-
series:
|
|
307
|
-
{
|
|
308
|
-
type: this.detailType,
|
|
309
|
-
name: this.seriesName || 'Series',
|
|
310
|
-
data: detailData,
|
|
311
|
-
color: this.seriesColor || undefined,
|
|
312
|
-
},
|
|
313
|
-
],
|
|
355
|
+
series: this.buildSeries(this.detailType, min, max),
|
|
314
356
|
credits: { enabled: false },
|
|
315
357
|
}, this.options);
|
|
316
358
|
// Only the detail pane takes the built-in rules. The master is a fixed short
|
|
@@ -363,6 +405,11 @@ let NileMasterDetailChart = class NileMasterDetailChart extends NileElement {
|
|
|
363
405
|
},
|
|
364
406
|
},
|
|
365
407
|
title: { text: this.masterTitle || undefined },
|
|
408
|
+
// With several series the legend lives on the detail pane, so the master
|
|
409
|
+
// must use the same colours or the overview contradicts it. Inherit the
|
|
410
|
+
// detail palette (`options.colors`, which nile-chart fills from its theme)
|
|
411
|
+
// unless `masterOptions.colors` sets one. Single-series output is unchanged.
|
|
412
|
+
...(this._isMultiSeries && Array.isArray(this.options?.colors) ? { colors: this.options.colors } : {}),
|
|
366
413
|
// A capped master (see the `min(…, 40%)` height in the stylesheet) can get
|
|
367
414
|
// short enough that the 30px label band above leaves almost no plot. Below
|
|
368
415
|
// that point drop the date labels and give the space back to the overview
|
|
@@ -399,19 +446,13 @@ let NileMasterDetailChart = class NileMasterDetailChart extends NileElement {
|
|
|
399
446
|
credits: { enabled: false },
|
|
400
447
|
plotOptions: {
|
|
401
448
|
series: {
|
|
449
|
+
stacking: this._stackingMode,
|
|
402
450
|
lineWidth: 1,
|
|
403
451
|
marker: { enabled: false, states: { hover: { enabled: mo, radius: 3 } } },
|
|
404
452
|
enableMouseTracking: mo,
|
|
405
453
|
},
|
|
406
454
|
},
|
|
407
|
-
series:
|
|
408
|
-
{
|
|
409
|
-
type: this.masterType,
|
|
410
|
-
name: this.seriesName || 'Series',
|
|
411
|
-
data: this.mapData(),
|
|
412
|
-
color: this.seriesColor || undefined,
|
|
413
|
-
},
|
|
414
|
-
],
|
|
455
|
+
series: this.buildSeries(this.masterType),
|
|
415
456
|
}, this.masterOptions);
|
|
416
457
|
// The master keeps its own height-aware rule rather than the shared cartesian
|
|
417
458
|
// set, but it honors the same opt-out: `no-responsive` means no built-in
|
|
@@ -446,8 +487,14 @@ let NileMasterDetailChart = class NileMasterDetailChart extends NileElement {
|
|
|
446
487
|
return;
|
|
447
488
|
}
|
|
448
489
|
if (this.detailChart) {
|
|
449
|
-
|
|
450
|
-
|
|
490
|
+
// Refilter every series we own (by index) and redraw once, so a stack
|
|
491
|
+
// stays consistent while zooming. Extra series supplied only through
|
|
492
|
+
// `options.series` are left as they are.
|
|
493
|
+
const chart = this.detailChart;
|
|
494
|
+
this._seriesList.forEach((s, i) => {
|
|
495
|
+
chart.series[i]?.setData(this.mapPoints(s.data, min, max), false);
|
|
496
|
+
});
|
|
497
|
+
chart.redraw();
|
|
451
498
|
}
|
|
452
499
|
const { dataMin, dataMax } = this.dataExtremes();
|
|
453
500
|
const xAxis = this.masterChart.xAxis[0];
|
|
@@ -553,6 +600,12 @@ __decorate([
|
|
|
553
600
|
__decorate([
|
|
554
601
|
property({ type: String, attribute: 'series-color' })
|
|
555
602
|
], NileMasterDetailChart.prototype, "seriesColor", void 0);
|
|
603
|
+
__decorate([
|
|
604
|
+
property({ type: Array })
|
|
605
|
+
], NileMasterDetailChart.prototype, "series", void 0);
|
|
606
|
+
__decorate([
|
|
607
|
+
property({ type: String })
|
|
608
|
+
], NileMasterDetailChart.prototype, "stacking", void 0);
|
|
556
609
|
__decorate([
|
|
557
610
|
property({ type: String, attribute: 'detail-type' })
|
|
558
611
|
], NileMasterDetailChart.prototype, "detailType", void 0);
|
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tests for <nile-master-detail-chart> multi-series + stacking
|
|
3
|
+
* (spec: kb/specs/nile-master-detail-chart-stacking.md — Acceptance criteria).
|
|
4
|
+
*
|
|
5
|
+
* Highcharts itself cannot run in this test browser (the dynamic `import('highcharts')`
|
|
6
|
+
* resolves to a module whose `setOptions` is missing — see the stand-in used by the
|
|
7
|
+
* kpi suite for the same reason). So instead of a live chart we inject a minimal fake
|
|
8
|
+
* Highcharts through the component's private `_hc` field *before* the first render:
|
|
9
|
+
* `initCharts()` then builds its real `buildDetailOptions()` / `buildMasterOptions()`
|
|
10
|
+
* into the fake, and `applySelection` / `resetZoom` run their real code against it.
|
|
11
|
+
* The fake captures each chart's `options`, `series` (with a working `setData`) and a
|
|
12
|
+
* single `xAxis`, which is everything the assertions below read.
|
|
13
|
+
*/
|
|
14
|
+
import { expect, fixture, html } from '@open-wc/testing';
|
|
15
|
+
import './nile-master-detail-chart';
|
|
16
|
+
import '../nile-chart/nile-chart';
|
|
17
|
+
const host = (el) => el;
|
|
18
|
+
const SERIES = [
|
|
19
|
+
{ name: 'Alpha', data: [{ x: 1, y: 10 }, { x: 2, y: 20 }, { x: 3, y: 30 }], color: '#ff0000' },
|
|
20
|
+
{ name: 'Beta', data: [{ x: 1, y: 5 }, { x: 2, y: 15 }, { x: 3, y: 25 }], color: '#00ff00' },
|
|
21
|
+
// Gamma reaches x=4 so the union-of-x assertions have something only it contributes.
|
|
22
|
+
{ name: 'Gamma', data: [{ x: 1, y: 1 }, { x: 2, y: 2 }, { x: 3, y: 3 }, { x: 4, y: 4 }], color: '#0000ff' },
|
|
23
|
+
];
|
|
24
|
+
const SINGLE = [{ x: 1, y: 10 }, { x: 2, y: 20 }, { x: 3, y: 30 }, { x: 4, y: 40 }];
|
|
25
|
+
// --- minimal fake Highcharts -------------------------------------------------
|
|
26
|
+
const toPoints = (data = []) => data.map((d) => ({ x: d.x, y: d.y }));
|
|
27
|
+
function makeSeries(s) {
|
|
28
|
+
const inst = {
|
|
29
|
+
name: s.name,
|
|
30
|
+
options: { ...s },
|
|
31
|
+
points: toPoints(s.data),
|
|
32
|
+
get xData() {
|
|
33
|
+
return inst.points.map((p) => p.x);
|
|
34
|
+
},
|
|
35
|
+
setData(data) {
|
|
36
|
+
inst.points = toPoints(data);
|
|
37
|
+
inst.options = { ...inst.options, data };
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
return inst;
|
|
41
|
+
}
|
|
42
|
+
function makeAxis() {
|
|
43
|
+
const bands = new Map();
|
|
44
|
+
return {
|
|
45
|
+
min: undefined,
|
|
46
|
+
max: undefined,
|
|
47
|
+
setExtremes(min, max) {
|
|
48
|
+
this.min = min;
|
|
49
|
+
this.max = max;
|
|
50
|
+
},
|
|
51
|
+
getExtremes() {
|
|
52
|
+
return { min: this.min, max: this.max, dataMin: this.min, dataMax: this.max };
|
|
53
|
+
},
|
|
54
|
+
addPlotBand(b) {
|
|
55
|
+
bands.set(b.id, b);
|
|
56
|
+
},
|
|
57
|
+
removePlotBand(id) {
|
|
58
|
+
bands.delete(id);
|
|
59
|
+
},
|
|
60
|
+
_bands: bands,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
const mergeSeriesOpts = (a = {}, b = {}) => ({
|
|
64
|
+
...a,
|
|
65
|
+
...b,
|
|
66
|
+
series: { ...(a.series || {}), ...(b.series || {}) },
|
|
67
|
+
});
|
|
68
|
+
function makeChart(options) {
|
|
69
|
+
const chart = {
|
|
70
|
+
options,
|
|
71
|
+
series: (options.series || []).map(makeSeries),
|
|
72
|
+
xAxis: [makeAxis()],
|
|
73
|
+
get legend() {
|
|
74
|
+
return { options: chart.options.legend || {} };
|
|
75
|
+
},
|
|
76
|
+
update(next) {
|
|
77
|
+
chart.options = {
|
|
78
|
+
...chart.options,
|
|
79
|
+
...next,
|
|
80
|
+
plotOptions: mergeSeriesOpts(chart.options.plotOptions, next.plotOptions),
|
|
81
|
+
legend: { ...(chart.options.legend || {}), ...(next.legend || {}) },
|
|
82
|
+
};
|
|
83
|
+
if (next.series)
|
|
84
|
+
chart.series = next.series.map(makeSeries);
|
|
85
|
+
},
|
|
86
|
+
reflow() { },
|
|
87
|
+
redraw() { },
|
|
88
|
+
destroy() { },
|
|
89
|
+
};
|
|
90
|
+
return chart;
|
|
91
|
+
}
|
|
92
|
+
const makeFakeHC = () => ({ chart: (_c, options) => makeChart(options), setOptions() { } });
|
|
93
|
+
// --- mount helper (injects the fake before first render) ---------------------
|
|
94
|
+
const mounted = [];
|
|
95
|
+
async function mount(props) {
|
|
96
|
+
const el = document.createElement('nile-master-detail-chart');
|
|
97
|
+
el.style.cssText = 'display:block;width:600px;height:400px';
|
|
98
|
+
Object.assign(el, props);
|
|
99
|
+
host(el)._hc = makeFakeHC(); // skip the (failing) getHighcharts() import
|
|
100
|
+
document.body.appendChild(el);
|
|
101
|
+
mounted.push(el);
|
|
102
|
+
await el.updateComplete;
|
|
103
|
+
await el.updateComplete; // updated() re-applies built options after firstUpdated()
|
|
104
|
+
return el;
|
|
105
|
+
}
|
|
106
|
+
afterEach(() => {
|
|
107
|
+
while (mounted.length)
|
|
108
|
+
mounted.pop().remove();
|
|
109
|
+
});
|
|
110
|
+
const detailSeries = (el) => host(el).detailChart.series;
|
|
111
|
+
const detailOpts = (el) => host(el).detailChart.options;
|
|
112
|
+
const masterOpts = (el) => host(el).masterChart.options;
|
|
113
|
+
const stackingOf = (opts) => opts?.plotOptions?.series?.stacking ?? null;
|
|
114
|
+
const pointCount = (s) => s.points.length;
|
|
115
|
+
describe('NileMasterDetailChart — property defaults', () => {
|
|
116
|
+
it('1. is defined', () => {
|
|
117
|
+
expect(customElements.get('nile-master-detail-chart')).to.exist;
|
|
118
|
+
});
|
|
119
|
+
it('2. renders', async () => {
|
|
120
|
+
const el = await fixture(html `<nile-master-detail-chart></nile-master-detail-chart>`);
|
|
121
|
+
expect(el).to.exist;
|
|
122
|
+
expect(el.shadowRoot).to.not.be.null;
|
|
123
|
+
});
|
|
124
|
+
it('3. series defaults to an empty array', async () => {
|
|
125
|
+
const el = await fixture(html `<nile-master-detail-chart></nile-master-detail-chart>`);
|
|
126
|
+
expect(el.series).to.deep.equal([]);
|
|
127
|
+
});
|
|
128
|
+
it('4. stacking defaults to empty string', async () => {
|
|
129
|
+
const el = await fixture(html `<nile-master-detail-chart></nile-master-detail-chart>`);
|
|
130
|
+
expect(el.stacking).to.equal('');
|
|
131
|
+
});
|
|
132
|
+
});
|
|
133
|
+
describe('NileMasterDetailChart — multi-series', () => {
|
|
134
|
+
it('5. renders one detail series per entry with the given names and colours', async () => {
|
|
135
|
+
const el = await mount({ series: SERIES });
|
|
136
|
+
const series = detailSeries(el);
|
|
137
|
+
expect(series.length).to.equal(3);
|
|
138
|
+
expect(series.map((s) => s.name)).to.deep.equal(['Alpha', 'Beta', 'Gamma']);
|
|
139
|
+
expect(series.map((s) => s.options.color)).to.deep.equal(['#ff0000', '#00ff00', '#0000ff']);
|
|
140
|
+
});
|
|
141
|
+
it('6. renders one master series per entry', async () => {
|
|
142
|
+
const el = await mount({ series: SERIES });
|
|
143
|
+
expect(host(el).masterChart.series.length).to.equal(3);
|
|
144
|
+
});
|
|
145
|
+
it('7. series (non-empty) wins over data / seriesName / seriesColor', async () => {
|
|
146
|
+
const el = await mount({ series: SERIES, data: SINGLE, seriesName: 'Ignored', seriesColor: '#111111' });
|
|
147
|
+
expect(detailSeries(el).length).to.equal(3);
|
|
148
|
+
expect(detailSeries(el)[0].name).to.equal('Alpha');
|
|
149
|
+
});
|
|
150
|
+
it('24. master inherits the detail palette (options.colors) with 2+ series', async () => {
|
|
151
|
+
const colors = ['#111111', '#222222', '#333333'];
|
|
152
|
+
const el = await mount({ series: SERIES, options: { colors } });
|
|
153
|
+
expect(masterOpts(el).colors).to.deep.equal(colors);
|
|
154
|
+
});
|
|
155
|
+
it('25. masterOptions.colors still wins over the inherited palette', async () => {
|
|
156
|
+
const el = await mount({ series: SERIES, options: { colors: ['#111111'] }, masterOptions: { colors: ['#999999'] } });
|
|
157
|
+
expect(masterOpts(el).colors).to.deep.equal(['#999999']);
|
|
158
|
+
});
|
|
159
|
+
it('26. single-series master does not inherit options.colors (unchanged)', async () => {
|
|
160
|
+
const el = await mount({ data: SINGLE, options: { colors: ['#111111'] } });
|
|
161
|
+
expect(masterOpts(el).colors).to.equal(undefined);
|
|
162
|
+
});
|
|
163
|
+
});
|
|
164
|
+
describe('NileMasterDetailChart — stacking', () => {
|
|
165
|
+
it("8. stacking 'normal' sets stacking on both panes", async () => {
|
|
166
|
+
const el = await mount({ series: SERIES, stacking: 'normal' });
|
|
167
|
+
expect(stackingOf(detailOpts(el))).to.equal('normal');
|
|
168
|
+
expect(stackingOf(masterOpts(el))).to.equal('normal');
|
|
169
|
+
});
|
|
170
|
+
it("9. stacking 'percent' sets percent stacking on both panes", async () => {
|
|
171
|
+
const el = await mount({ series: SERIES, stacking: 'percent' });
|
|
172
|
+
expect(stackingOf(detailOpts(el))).to.equal('percent');
|
|
173
|
+
expect(stackingOf(masterOpts(el))).to.equal('percent');
|
|
174
|
+
});
|
|
175
|
+
it('10. no stacking when stacking is unset', async () => {
|
|
176
|
+
const el = await mount({ series: SERIES });
|
|
177
|
+
expect(stackingOf(detailOpts(el))).to.be.null;
|
|
178
|
+
expect(stackingOf(masterOpts(el))).to.be.null;
|
|
179
|
+
});
|
|
180
|
+
it('11. an unknown stacking value means no stacking', async () => {
|
|
181
|
+
const el = await mount({ series: SERIES, stacking: 'bogus' });
|
|
182
|
+
expect(stackingOf(detailOpts(el))).to.be.null;
|
|
183
|
+
});
|
|
184
|
+
it('17. options can override the detail stacking', async () => {
|
|
185
|
+
const el = await mount({
|
|
186
|
+
series: SERIES,
|
|
187
|
+
stacking: 'normal',
|
|
188
|
+
options: { plotOptions: { series: { stacking: undefined } } },
|
|
189
|
+
});
|
|
190
|
+
expect(stackingOf(detailOpts(el))).to.be.null;
|
|
191
|
+
});
|
|
192
|
+
});
|
|
193
|
+
describe('NileMasterDetailChart — legend', () => {
|
|
194
|
+
it('12. legend is enabled on the detail pane with 2+ series', async () => {
|
|
195
|
+
const el = await mount({ series: SERIES });
|
|
196
|
+
expect(detailOpts(el).legend.enabled).to.be.true;
|
|
197
|
+
});
|
|
198
|
+
it('13. legend is disabled on the detail pane with a single series', async () => {
|
|
199
|
+
const el = await mount({ series: [SERIES[0]] });
|
|
200
|
+
expect(detailOpts(el).legend.enabled).to.not.be.true;
|
|
201
|
+
});
|
|
202
|
+
it('18. options can override the detail legend', async () => {
|
|
203
|
+
const el = await mount({ series: SERIES, options: { legend: { enabled: false } } });
|
|
204
|
+
expect(detailOpts(el).legend.enabled).to.not.be.true;
|
|
205
|
+
});
|
|
206
|
+
});
|
|
207
|
+
describe('NileMasterDetailChart — extremes, selection, reset', () => {
|
|
208
|
+
it('14. data extremes span the union of all series x values', async () => {
|
|
209
|
+
const el = await mount({ series: SERIES });
|
|
210
|
+
const { dataMin, dataMax } = host(el).dataExtremes();
|
|
211
|
+
expect(dataMin).to.equal(1);
|
|
212
|
+
expect(dataMax).to.equal(4); // only Gamma reaches x=4
|
|
213
|
+
});
|
|
214
|
+
it('15. applySelection refilters every detail series to the range', async () => {
|
|
215
|
+
const el = await mount({ series: SERIES });
|
|
216
|
+
host(el).applySelection(2, 3);
|
|
217
|
+
// Alpha/Beta have x in {1,2,3} → 2 points in [2,3]; Gamma {1,2,3,4} → also 2.
|
|
218
|
+
expect(detailSeries(el).map(pointCount)).to.deep.equal([2, 2, 2]);
|
|
219
|
+
});
|
|
220
|
+
it('16. resetZoom restores every detail series to its full data', async () => {
|
|
221
|
+
const el = await mount({ series: SERIES });
|
|
222
|
+
host(el).applySelection(2, 2);
|
|
223
|
+
el.resetZoom();
|
|
224
|
+
await el.updateComplete;
|
|
225
|
+
expect(detailSeries(el).map(pointCount)).to.deep.equal([3, 3, 4]);
|
|
226
|
+
});
|
|
227
|
+
});
|
|
228
|
+
describe('NileMasterDetailChart — single-series regression (data, unchanged)', () => {
|
|
229
|
+
it('19. renders exactly one detail series from data', async () => {
|
|
230
|
+
const el = await mount({ data: SINGLE, seriesName: 'Solo' });
|
|
231
|
+
expect(detailSeries(el).length).to.equal(1);
|
|
232
|
+
expect(detailSeries(el)[0].name).to.equal('Solo');
|
|
233
|
+
});
|
|
234
|
+
it('20. keeps the legend disabled for a single data series', async () => {
|
|
235
|
+
const el = await mount({ data: SINGLE });
|
|
236
|
+
expect(detailOpts(el).legend.enabled).to.not.be.true;
|
|
237
|
+
});
|
|
238
|
+
it('21. applySelection filters the single series', async () => {
|
|
239
|
+
const el = await mount({ data: SINGLE });
|
|
240
|
+
host(el).applySelection(2, 3);
|
|
241
|
+
expect(pointCount(detailSeries(el)[0])).to.equal(2);
|
|
242
|
+
});
|
|
243
|
+
it('22. data extremes come from the single series x values', async () => {
|
|
244
|
+
const el = await mount({ data: SINGLE });
|
|
245
|
+
const { dataMin, dataMax } = host(el).dataExtremes();
|
|
246
|
+
expect(dataMin).to.equal(1);
|
|
247
|
+
expect(dataMax).to.equal(4);
|
|
248
|
+
});
|
|
249
|
+
});
|
|
250
|
+
describe('NileChart → master-detail passthrough', () => {
|
|
251
|
+
it('23. passes series and stacking down to the inner nile-master-detail-chart', async () => {
|
|
252
|
+
const el = await fixture(html `<nile-chart style="display:block;width:600px;height:400px"></nile-chart>`);
|
|
253
|
+
el.config = { chart: { type: 'master-detail', series: SERIES, stacking: 'normal' } };
|
|
254
|
+
await el.updateComplete;
|
|
255
|
+
await el.updateComplete;
|
|
256
|
+
const inner = el.shadowRoot.querySelector('nile-master-detail-chart');
|
|
257
|
+
expect(inner, 'inner master-detail chart should render').to.exist;
|
|
258
|
+
expect(inner.series).to.deep.equal(SERIES);
|
|
259
|
+
expect(inner.stacking).to.equal('normal');
|
|
260
|
+
});
|
|
261
|
+
});
|
|
262
|
+
//# sourceMappingURL=nile-master-detail-chart.test.js.map
|