@aquera/nile-visualization 2.9.40 → 2.9.42
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 +9 -0
- package/dist/src/index.d.ts +3 -1
- package/dist/src/index.js +2 -0
- package/dist/src/internal/types/chart-pagination-config.type.d.ts +32 -0
- package/dist/src/internal/types/chart-pagination-config.type.js +2 -0
- package/dist/src/internal/types/nile-chart-config-input.type.d.ts +2 -1
- package/dist/src/internal/types/separated-chart-config-input.type.d.ts +2 -1
- package/dist/src/internal/utils/chart-events.d.ts +3 -0
- package/dist/src/internal/utils/chart-events.js +4 -0
- package/dist/src/internal/utils/chart-pagination.d.ts +145 -0
- package/dist/src/internal/utils/chart-pagination.js +1502 -0
- package/dist/src/internal/utils/highcharts-provider.js +2 -0
- package/dist/src/nile-chart/nile-chart-config.d.ts +2 -1
- package/dist/src/nile-chart/nile-chart.css.js +2 -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/package.json +1 -1
|
@@ -0,0 +1,373 @@
|
|
|
1
|
+
/** Tests for <nile-kpi-chart>: sparkline tooltip placement, compact title overflow, sparkline sizing. */
|
|
2
|
+
import { expect, fixture, html } from '@open-wc/testing';
|
|
3
|
+
import './nile-kpi-chart';
|
|
4
|
+
const LONG = '8 accounts waiting for review across all regions';
|
|
5
|
+
describe('NileKpiChart sparkline tooltip placement', () => {
|
|
6
|
+
let el;
|
|
7
|
+
let host;
|
|
8
|
+
const vw = () => document.documentElement.clientWidth;
|
|
9
|
+
beforeEach(async () => {
|
|
10
|
+
el = await fixture(html `<nile-kpi-chart></nile-kpi-chart>`);
|
|
11
|
+
host = el;
|
|
12
|
+
host._createTipEl();
|
|
13
|
+
});
|
|
14
|
+
afterEach(() => {
|
|
15
|
+
host._hideTip();
|
|
16
|
+
document.querySelectorAll('.nile-kpi-tooltip, .nile-kpi-marker').forEach((n) => n.remove());
|
|
17
|
+
});
|
|
18
|
+
it('sizes to its text at the window edge instead of one character per line', () => {
|
|
19
|
+
host._showTip(LONG, vw(), 300);
|
|
20
|
+
const r = host._tipEl.getBoundingClientRect();
|
|
21
|
+
expect(r.width).to.be.greaterThan(100);
|
|
22
|
+
expect(r.height).to.be.lessThan(120); // two or three lines, not a tall column
|
|
23
|
+
});
|
|
24
|
+
it('stays inside the window at the right edge and keeps the arrow on the point', () => {
|
|
25
|
+
host._showTip(LONG, vw(), 300);
|
|
26
|
+
const r = host._tipEl.getBoundingClientRect();
|
|
27
|
+
expect(r.right).to.be.at.most(vw());
|
|
28
|
+
expect(r.left).to.be.at.least(0);
|
|
29
|
+
const arrowX = parseFloat(host._tipEl.style.getPropertyValue('--nile-kpi-tip-arrow-x'));
|
|
30
|
+
expect(arrowX).to.be.greaterThan(r.width / 2); // arrow moved right of centre, toward the point
|
|
31
|
+
expect(arrowX).to.be.at.most(r.width - 12);
|
|
32
|
+
});
|
|
33
|
+
it('stays inside the window at the left edge', () => {
|
|
34
|
+
host._showTip(LONG, 0, 300);
|
|
35
|
+
const r = host._tipEl.getBoundingClientRect();
|
|
36
|
+
expect(r.left).to.be.at.least(0);
|
|
37
|
+
expect(parseFloat(host._tipEl.style.getPropertyValue('--nile-kpi-tip-arrow-x'))).to.be.lessThan(r.width / 2);
|
|
38
|
+
});
|
|
39
|
+
it('is centred on the point, with a centred arrow, when there is room', () => {
|
|
40
|
+
const x = Math.round(vw() / 2);
|
|
41
|
+
host._showTip('42', x, 300);
|
|
42
|
+
expect(host._tipEl.style.left).to.equal(`${x}px`);
|
|
43
|
+
expect(host._tipEl.style.getPropertyValue('--nile-kpi-tip-arrow-x')).to.equal('');
|
|
44
|
+
expect(host._tipEl.hasAttribute('data-placement')).to.be.false;
|
|
45
|
+
});
|
|
46
|
+
it('flips below the point when there is no room above', () => {
|
|
47
|
+
host._showTip(LONG, Math.round(vw() / 2), 10);
|
|
48
|
+
expect(host._tipEl.getAttribute('data-placement')).to.equal('bottom');
|
|
49
|
+
expect(host._tipEl.getBoundingClientRect().top).to.be.at.least(10);
|
|
50
|
+
});
|
|
51
|
+
it('clears the previous shift and flip on the next call', () => {
|
|
52
|
+
host._showTip(LONG, vw(), 10);
|
|
53
|
+
host._showTip('42', Math.round(vw() / 2), 300);
|
|
54
|
+
expect(host._tipEl.hasAttribute('data-placement')).to.be.false;
|
|
55
|
+
expect(host._tipEl.style.getPropertyValue('--nile-kpi-tip-arrow-x')).to.equal('');
|
|
56
|
+
});
|
|
57
|
+
it('is never wider than the window minus its margins (padding and border count toward the cap)', () => {
|
|
58
|
+
host._showTip(LONG.repeat(4), Math.round(vw() / 2), 300);
|
|
59
|
+
const r = host._tipEl.getBoundingClientRect();
|
|
60
|
+
expect(r.width).to.be.at.most(Math.min(260, vw() - 16) + 0.5);
|
|
61
|
+
expect(r.left).to.be.at.least(0);
|
|
62
|
+
expect(r.right).to.be.at.most(vw());
|
|
63
|
+
});
|
|
64
|
+
it('keeps a z-index of 2', () => {
|
|
65
|
+
host._showTip('42', 100, 300);
|
|
66
|
+
expect(getComputedStyle(host._tipEl).zIndex).to.equal('2');
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
describe('NileKpiChart title overflow', () => {
|
|
70
|
+
// the wrapping matrix covers compact; the other variants are asserted separately below
|
|
71
|
+
const VARIANTS = ['compact'];
|
|
72
|
+
const OTHER_VARIANTS = ['default', 'card'];
|
|
73
|
+
const CONTROLS = {
|
|
74
|
+
none: [],
|
|
75
|
+
lead: ['header-lead'],
|
|
76
|
+
actions: ['header-actions'],
|
|
77
|
+
both: ['header-lead', 'header-actions'],
|
|
78
|
+
};
|
|
79
|
+
const SHORT = 'Revenue';
|
|
80
|
+
const WORD = 'Supercalifragilisticexpialidocious'; // one word far wider than a 170px card
|
|
81
|
+
const WORD_PLUS = 'Supercalifragilisticexpialidocious Overview';
|
|
82
|
+
const LONG = 'one two three four five six seven eight nine ten eleven twelve thirteen fourteen fifteen sixteen'; // > 3 lines everywhere
|
|
83
|
+
const mount = async (label, o = {}) => {
|
|
84
|
+
const wrap = await fixture(html `<div
|
|
85
|
+
style="width:${o.width ?? 170}px;height:${o.height ?? 212}px"
|
|
86
|
+
>
|
|
87
|
+
<nile-kpi-chart fit style="width:100%;height:100%"></nile-kpi-chart>
|
|
88
|
+
</div>`);
|
|
89
|
+
const el = wrap.querySelector('nile-kpi-chart');
|
|
90
|
+
if (o.overflow)
|
|
91
|
+
el.setAttribute('title-overflow', o.overflow);
|
|
92
|
+
for (const slot of o.slots ?? []) {
|
|
93
|
+
const b = document.createElement('button');
|
|
94
|
+
b.slot = slot;
|
|
95
|
+
b.textContent = 'x';
|
|
96
|
+
b.style.cssText = 'width:24px;height:24px;padding:0;border:0';
|
|
97
|
+
el.appendChild(b);
|
|
98
|
+
}
|
|
99
|
+
el.config = {
|
|
100
|
+
chart: {
|
|
101
|
+
type: 'kpi',
|
|
102
|
+
variant: (o.variant ?? 'compact'),
|
|
103
|
+
label,
|
|
104
|
+
value: '285K',
|
|
105
|
+
trendValue: 12.5,
|
|
106
|
+
trendDirection: 'up',
|
|
107
|
+
},
|
|
108
|
+
aq: {},
|
|
109
|
+
};
|
|
110
|
+
await el.updateComplete;
|
|
111
|
+
await el.updateComplete; // config is applied in updated(), which schedules a second update
|
|
112
|
+
await new Promise((r) => requestAnimationFrame(() => requestAnimationFrame(r)));
|
|
113
|
+
return el;
|
|
114
|
+
};
|
|
115
|
+
const parts = (el) => {
|
|
116
|
+
const root = el.shadowRoot;
|
|
117
|
+
const label = root.querySelector('.kpi-label');
|
|
118
|
+
const text = root.querySelector('.kpi-label-text');
|
|
119
|
+
const tip = root.querySelector('nile-lite-tooltip[data-kpi-tip="label"]');
|
|
120
|
+
return { label, text, tip, header: root.querySelector('.kpi-header') };
|
|
121
|
+
};
|
|
122
|
+
const lineCount = (el) => {
|
|
123
|
+
const { label, text } = parts(el);
|
|
124
|
+
return Math.round(text.getBoundingClientRect().height / parseFloat(getComputedStyle(label).lineHeight));
|
|
125
|
+
};
|
|
126
|
+
const cutSideways = (el) => {
|
|
127
|
+
const { text } = parts(el);
|
|
128
|
+
return text.scrollWidth > text.clientWidth + 1;
|
|
129
|
+
};
|
|
130
|
+
const tooltipOn = (el) => parts(el).tip.disabled === false;
|
|
131
|
+
for (const variant of VARIANTS) {
|
|
132
|
+
for (const [controls, slots] of Object.entries(CONTROLS)) {
|
|
133
|
+
describe(`${variant} + ${controls}`, () => {
|
|
134
|
+
it('ellipsis: normal words wrap, capped at 3 lines, the rest ends in … with the full title in the tooltip', async () => {
|
|
135
|
+
const el = await mount(LONG, { variant, slots, overflow: 'ellipsis' });
|
|
136
|
+
const { label, text, tip } = parts(el);
|
|
137
|
+
expect(getComputedStyle(label).whiteSpace).to.not.equal('nowrap');
|
|
138
|
+
expect(getComputedStyle(text).webkitLineClamp).to.equal('3');
|
|
139
|
+
expect(getComputedStyle(text).textOverflow).to.equal('ellipsis');
|
|
140
|
+
expect(lineCount(el)).to.equal(3);
|
|
141
|
+
expect(tooltipOn(el)).to.be.true;
|
|
142
|
+
expect(tip.getAttribute('content')).to.equal(LONG);
|
|
143
|
+
});
|
|
144
|
+
it('ellipsis: a word wider than the line is cut with …, not split', async () => {
|
|
145
|
+
const el = await mount(WORD_PLUS, { variant, slots, overflow: 'ellipsis' });
|
|
146
|
+
expect(getComputedStyle(parts(el).text).overflowWrap).to.equal('normal');
|
|
147
|
+
expect(cutSideways(el)).to.be.true;
|
|
148
|
+
expect(tooltipOn(el)).to.be.true;
|
|
149
|
+
expect(parts(el).tip.getAttribute('content')).to.equal(WORD_PLUS);
|
|
150
|
+
});
|
|
151
|
+
it('break: a word wider than the line is split across lines, not cut sideways', async () => {
|
|
152
|
+
const el = await mount(WORD, { variant, slots, overflow: 'break' });
|
|
153
|
+
expect(getComputedStyle(parts(el).text).overflowWrap).to.equal('anywhere');
|
|
154
|
+
expect(cutSideways(el)).to.be.false;
|
|
155
|
+
expect(lineCount(el)).to.be.within(2, 3);
|
|
156
|
+
});
|
|
157
|
+
it('break: text past line 3 is truncated with the full title in the tooltip', async () => {
|
|
158
|
+
const el = await mount(LONG, { variant, slots, overflow: 'break' });
|
|
159
|
+
expect(getComputedStyle(parts(el).text).webkitLineClamp).to.equal('3');
|
|
160
|
+
expect(lineCount(el)).to.equal(3);
|
|
161
|
+
expect(tooltipOn(el)).to.be.true;
|
|
162
|
+
expect(parts(el).tip.getAttribute('content')).to.equal(LONG);
|
|
163
|
+
});
|
|
164
|
+
for (const overflow of ['ellipsis', 'break', null]) {
|
|
165
|
+
it(`no tooltip when the whole title is visible (title-overflow ${overflow ?? 'default'})`, async () => {
|
|
166
|
+
const el = await mount(SHORT, { variant, slots, overflow });
|
|
167
|
+
expect(lineCount(el)).to.equal(1);
|
|
168
|
+
expect(cutSideways(el)).to.be.false;
|
|
169
|
+
expect(tooltipOn(el)).to.be.false;
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
it('the first title line starts level with the top of the header', async () => {
|
|
173
|
+
for (const overflow of ['ellipsis', 'break']) {
|
|
174
|
+
const el = await mount('Transaction Failure Rate Overview', {
|
|
175
|
+
variant,
|
|
176
|
+
slots,
|
|
177
|
+
overflow,
|
|
178
|
+
});
|
|
179
|
+
const { text, header } = parts(el);
|
|
180
|
+
const range = document.createRange();
|
|
181
|
+
range.selectNodeContents(text);
|
|
182
|
+
expect(range.getClientRects()[0].top - header.getBoundingClientRect().top, overflow).to.be.lessThan(4);
|
|
183
|
+
}
|
|
184
|
+
});
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
describe('header controls only change the width, not whether the title wraps', () => {
|
|
189
|
+
for (const variant of VARIANTS) {
|
|
190
|
+
it(`${variant}: wrapping, clamp and overflow-wrap are identical with and without controls`, async () => {
|
|
191
|
+
const snapshot = async (slots, overflow) => {
|
|
192
|
+
const { label, text } = parts(await mount(LONG, { variant, slots, overflow }));
|
|
193
|
+
return [
|
|
194
|
+
getComputedStyle(label).whiteSpace,
|
|
195
|
+
getComputedStyle(text).display,
|
|
196
|
+
getComputedStyle(text).webkitLineClamp,
|
|
197
|
+
getComputedStyle(text).overflowWrap,
|
|
198
|
+
].join('|');
|
|
199
|
+
};
|
|
200
|
+
for (const overflow of ['ellipsis', 'break', null]) {
|
|
201
|
+
const none = await snapshot([], overflow);
|
|
202
|
+
for (const slots of [
|
|
203
|
+
['header-lead'],
|
|
204
|
+
['header-actions'],
|
|
205
|
+
['header-lead', 'header-actions'],
|
|
206
|
+
]) {
|
|
207
|
+
expect(await snapshot(slots, overflow), `${slots.join('+')} / ${overflow ?? 'default'}`).to.equal(none);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
it('a compact card without controls wraps', async () => {
|
|
213
|
+
const el = await mount('Monthly recurring revenue by region and product line');
|
|
214
|
+
expect(parts(el).label.hasAttribute('has-header-actions')).to.be.false;
|
|
215
|
+
expect(el.hasAttribute('has-header-lead')).to.be.false;
|
|
216
|
+
expect(el.hasAttribute('has-header-actions')).to.be.false;
|
|
217
|
+
expect(lineCount(el)).to.be.greaterThan(1);
|
|
218
|
+
});
|
|
219
|
+
});
|
|
220
|
+
describe('non-compact variants keep a single-line title and floating header controls', () => {
|
|
221
|
+
for (const variant of OTHER_VARIANTS) {
|
|
222
|
+
it(`${variant} without controls: one line cut with …, no 3-line clamp, title-overflow has no effect`, async () => {
|
|
223
|
+
for (const overflow of ['ellipsis', 'break', null]) {
|
|
224
|
+
const el = await mount(LONG, { variant, overflow });
|
|
225
|
+
const { label, text } = parts(el);
|
|
226
|
+
expect(getComputedStyle(label).whiteSpace, String(overflow)).to.equal('nowrap');
|
|
227
|
+
expect(getComputedStyle(label).textOverflow).to.equal('ellipsis');
|
|
228
|
+
expect(getComputedStyle(text).display).to.not.equal('-webkit-box');
|
|
229
|
+
expect(getComputedStyle(text).overflowWrap).to.not.equal('anywhere');
|
|
230
|
+
expect(lineCount(el)).to.equal(1);
|
|
231
|
+
expect(tooltipOn(el)).to.be.true;
|
|
232
|
+
expect(parts(el).tip.getAttribute('content')).to.equal(LONG);
|
|
233
|
+
}
|
|
234
|
+
});
|
|
235
|
+
for (const [controls, slots] of Object.entries(CONTROLS)) {
|
|
236
|
+
if (!slots.length)
|
|
237
|
+
continue;
|
|
238
|
+
it(`${variant} + ${controls}: keeps the title wrapping around floating controls with the 4-line cap`, async () => {
|
|
239
|
+
const el = await mount(LONG, { variant, slots, overflow: 'break' });
|
|
240
|
+
const { label, header } = parts(el);
|
|
241
|
+
expect(getComputedStyle(header).display).to.equal('block');
|
|
242
|
+
expect(getComputedStyle(header).position).to.equal('relative');
|
|
243
|
+
expect(getComputedStyle(label).display).to.equal('-webkit-box');
|
|
244
|
+
expect(getComputedStyle(label).webkitLineClamp).to.be.oneOf(['4', '3', '2']);
|
|
245
|
+
expect(getComputedStyle(parts(el).text).overflowWrap).to.not.equal('anywhere');
|
|
246
|
+
expect(header.style.getPropertyValue('--kpi-controls-w')).to.not.equal('');
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
});
|
|
251
|
+
describe('property and config', () => {
|
|
252
|
+
it("defaults to 'ellipsis' (reflected), which is what a card with no attribute behaves like", async () => {
|
|
253
|
+
const el = await mount(WORD_PLUS);
|
|
254
|
+
expect(el.titleOverflow).to.equal('ellipsis');
|
|
255
|
+
expect(el.getAttribute('title-overflow')).to.equal('ellipsis');
|
|
256
|
+
expect(getComputedStyle(parts(el).text).overflowWrap).to.equal('normal');
|
|
257
|
+
expect(cutSideways(el)).to.be.true;
|
|
258
|
+
});
|
|
259
|
+
it('can be set from config.chart.titleOverflow', async () => {
|
|
260
|
+
const el = await mount(WORD);
|
|
261
|
+
el.config = {
|
|
262
|
+
chart: {
|
|
263
|
+
type: 'kpi',
|
|
264
|
+
variant: 'compact',
|
|
265
|
+
label: WORD,
|
|
266
|
+
value: '285K',
|
|
267
|
+
titleOverflow: 'break',
|
|
268
|
+
},
|
|
269
|
+
aq: {},
|
|
270
|
+
};
|
|
271
|
+
await el.updateComplete;
|
|
272
|
+
await el.updateComplete;
|
|
273
|
+
expect(el.titleOverflow).to.equal('break');
|
|
274
|
+
expect(el.getAttribute('title-overflow')).to.equal('break');
|
|
275
|
+
expect(getComputedStyle(parts(el).text).overflowWrap).to.equal('anywhere');
|
|
276
|
+
});
|
|
277
|
+
it('an unknown value behaves like ellipsis', async () => {
|
|
278
|
+
const el = await mount(WORD_PLUS);
|
|
279
|
+
el.titleOverflow = 'nonsense';
|
|
280
|
+
await el.updateComplete;
|
|
281
|
+
expect(getComputedStyle(parts(el).text).overflowWrap).to.equal('normal');
|
|
282
|
+
});
|
|
283
|
+
});
|
|
284
|
+
describe('the title does not push the rest of the card out', () => {
|
|
285
|
+
it('keeps the value inside the card at every height while the title has 3 lines', async () => {
|
|
286
|
+
for (const height of [100, 126, 160, 212, 320]) {
|
|
287
|
+
const el = await mount(LONG, { height, slots: ['header-actions'] });
|
|
288
|
+
const value = el.shadowRoot.querySelector('.kpi-value');
|
|
289
|
+
expect(value.getBoundingClientRect().bottom, `height ${height}`).to.be.at.most(el.getBoundingClientRect().bottom + 1);
|
|
290
|
+
}
|
|
291
|
+
});
|
|
292
|
+
// a stand-in box with the real compact sparkline styles replaces Highcharts, which the test browser can't load
|
|
293
|
+
const withSparkline = async (label, height) => {
|
|
294
|
+
const el = await mount(label, { height });
|
|
295
|
+
const box = document.createElement('div');
|
|
296
|
+
box.className = 'kpi-sparkline';
|
|
297
|
+
el.shadowRoot.querySelector('.kpi--compact').appendChild(box);
|
|
298
|
+
el._fitDescription(true);
|
|
299
|
+
return { el, box };
|
|
300
|
+
};
|
|
301
|
+
it('hides the compact sparkline whole when a 3-line title leaves it less than its minimum height', async () => {
|
|
302
|
+
const { el, box } = await withSparkline(LONG, 100);
|
|
303
|
+
expect(el.hasAttribute('data-hide-spark')).to.be.true;
|
|
304
|
+
expect(getComputedStyle(box).display).to.equal('none');
|
|
305
|
+
});
|
|
306
|
+
it('keeps the sparkline when it fits (short title, or a tall card)', async () => {
|
|
307
|
+
for (const [label, height] of [
|
|
308
|
+
[SHORT, 100],
|
|
309
|
+
[LONG, 260],
|
|
310
|
+
]) {
|
|
311
|
+
const { el, box } = await withSparkline(label, height);
|
|
312
|
+
expect(el.hasAttribute('data-hide-spark'), `${label.slice(0, 7)} @ ${height}`).to.be.false;
|
|
313
|
+
expect(getComputedStyle(box).display).to.not.equal('none');
|
|
314
|
+
}
|
|
315
|
+
});
|
|
316
|
+
});
|
|
317
|
+
});
|
|
318
|
+
describe('NileKpiChart sparkline size under a transform', () => {
|
|
319
|
+
const setup = async (scale) => {
|
|
320
|
+
const wrap = await fixture(html ` <div
|
|
321
|
+
style="width:148px;transform:scale(${scale});transform-origin:left top"
|
|
322
|
+
>
|
|
323
|
+
<nile-kpi-chart variant="compact" style="display:block;width:100%"></nile-kpi-chart>
|
|
324
|
+
</div>`);
|
|
325
|
+
const el = wrap.querySelector('nile-kpi-chart');
|
|
326
|
+
await el.updateComplete;
|
|
327
|
+
const box = document.createElement('div');
|
|
328
|
+
box.className = 'kpi-sparkline';
|
|
329
|
+
box.style.cssText = 'display:block;width:100%;height:50px';
|
|
330
|
+
el.shadowRoot.appendChild(box);
|
|
331
|
+
const drawn = document.createElement('div');
|
|
332
|
+
box.appendChild(drawn);
|
|
333
|
+
const stub = {
|
|
334
|
+
container: drawn,
|
|
335
|
+
chartWidth: 0,
|
|
336
|
+
chartHeight: 0,
|
|
337
|
+
renderTo: box,
|
|
338
|
+
update(o) {
|
|
339
|
+
this.chartWidth = o.chart.width;
|
|
340
|
+
this.chartHeight = o.chart.height;
|
|
341
|
+
},
|
|
342
|
+
destroy() {
|
|
343
|
+
// stand-in chart: nothing to release
|
|
344
|
+
},
|
|
345
|
+
};
|
|
346
|
+
const host = el;
|
|
347
|
+
host.sparklineChart = stub;
|
|
348
|
+
return { wrap, el, box, host, stub };
|
|
349
|
+
};
|
|
350
|
+
it('uses the layout size while the card is scaled down, not the on-screen size', async () => {
|
|
351
|
+
const { box, host, stub } = await setup(0.973);
|
|
352
|
+
expect(box.offsetWidth).to.equal(148);
|
|
353
|
+
expect(Math.round(box.getBoundingClientRect().width)).to.equal(144); // what getBoundingClientRect() would have given
|
|
354
|
+
host.syncSparklineChartSize();
|
|
355
|
+
expect(stub.chartWidth).to.equal(148); // the layout width, not the scaled on-screen width
|
|
356
|
+
expect(stub.chartHeight).to.equal(50);
|
|
357
|
+
});
|
|
358
|
+
it('matches the box exactly after the scale animation finishes', async () => {
|
|
359
|
+
const { wrap, box, host, stub } = await setup(0.973);
|
|
360
|
+
host.syncSparklineChartSize();
|
|
361
|
+
wrap.style.transform = 'scale(1)'; // layout size does not change, so a ResizeObserver would stay silent
|
|
362
|
+
host.syncSparklineChartSize();
|
|
363
|
+
expect(Math.round(box.getBoundingClientRect().width)).to.equal(148);
|
|
364
|
+
expect(stub.chartWidth).to.equal(box.offsetWidth);
|
|
365
|
+
});
|
|
366
|
+
it('matches the box when there is no transform', async () => {
|
|
367
|
+
const { box, host, stub } = await setup(1);
|
|
368
|
+
host.syncSparklineChartSize();
|
|
369
|
+
expect(stub.chartWidth).to.equal(box.offsetWidth);
|
|
370
|
+
expect(stub.chartWidth).to.equal(148);
|
|
371
|
+
});
|
|
372
|
+
});
|
|
373
|
+
//# sourceMappingURL=nile-kpi-chart.test.js.map
|