@ember-joinery/chart 0.0.0-stage → 1.0.1

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.
Files changed (121) hide show
  1. package/CHANGELOG.md +167 -0
  2. package/LICENSE.md +9 -0
  3. package/NOTICE +532 -0
  4. package/README.md +69 -2
  5. package/addon-main.cjs +4 -0
  6. package/declarations/-private/cartesian-chart.d.ts +413 -0
  7. package/declarations/-private/cartesian-chart.d.ts.map +1 -0
  8. package/declarations/-private/cartesian.d.ts +236 -0
  9. package/declarations/-private/cartesian.d.ts.map +1 -0
  10. package/declarations/-private/config.d.ts +13 -0
  11. package/declarations/-private/config.d.ts.map +1 -0
  12. package/declarations/-private/dots.d.ts +27 -0
  13. package/declarations/-private/dots.d.ts.map +1 -0
  14. package/declarations/-private/nice-ticks.d.ts +17 -0
  15. package/declarations/-private/nice-ticks.d.ts.map +1 -0
  16. package/declarations/-private/parts.d.ts +596 -0
  17. package/declarations/-private/parts.d.ts.map +1 -0
  18. package/declarations/-private/paths.d.ts +26 -0
  19. package/declarations/-private/paths.d.ts.map +1 -0
  20. package/declarations/-private/pie-chart.d.ts +244 -0
  21. package/declarations/-private/pie-chart.d.ts.map +1 -0
  22. package/declarations/-private/polar-chart.d.ts +423 -0
  23. package/declarations/-private/polar-chart.d.ts.map +1 -0
  24. package/declarations/-private/polar-geometry.d.ts +230 -0
  25. package/declarations/-private/polar-geometry.d.ts.map +1 -0
  26. package/declarations/-private/polar-parts.d.ts +315 -0
  27. package/declarations/-private/polar-parts.d.ts.map +1 -0
  28. package/declarations/-private/polar.d.ts +156 -0
  29. package/declarations/-private/polar.d.ts.map +1 -0
  30. package/declarations/-private/registry.d.ts +9 -0
  31. package/declarations/-private/registry.d.ts.map +1 -0
  32. package/declarations/-private/text-size.d.ts +13 -0
  33. package/declarations/-private/text-size.d.ts.map +1 -0
  34. package/declarations/-private/tick-interval.d.ts +35 -0
  35. package/declarations/-private/tick-interval.d.ts.map +1 -0
  36. package/declarations/components/area-chart.d.ts +16 -0
  37. package/declarations/components/area-chart.d.ts.map +1 -0
  38. package/declarations/components/bar-chart.d.ts +16 -0
  39. package/declarations/components/bar-chart.d.ts.map +1 -0
  40. package/declarations/components/chart-container.d.ts +66 -0
  41. package/declarations/components/chart-container.d.ts.map +1 -0
  42. package/declarations/components/chart-legend-content.d.ts +42 -0
  43. package/declarations/components/chart-legend-content.d.ts.map +1 -0
  44. package/declarations/components/chart-style.d.ts +19 -0
  45. package/declarations/components/chart-style.d.ts.map +1 -0
  46. package/declarations/components/chart-tooltip-content.d.ts +94 -0
  47. package/declarations/components/chart-tooltip-content.d.ts.map +1 -0
  48. package/declarations/components/dot.d.ts +22 -0
  49. package/declarations/components/dot.d.ts.map +1 -0
  50. package/declarations/components/line-chart.d.ts +16 -0
  51. package/declarations/components/line-chart.d.ts.map +1 -0
  52. package/declarations/components/pie-chart.d.ts +13 -0
  53. package/declarations/components/pie-chart.d.ts.map +1 -0
  54. package/declarations/components/radar-chart.d.ts +21 -0
  55. package/declarations/components/radar-chart.d.ts.map +1 -0
  56. package/declarations/components/radial-bar-chart.d.ts +17 -0
  57. package/declarations/components/radial-bar-chart.d.ts.map +1 -0
  58. package/declarations/components/rectangle.d.ts +32 -0
  59. package/declarations/components/rectangle.d.ts.map +1 -0
  60. package/declarations/components/sector.d.ts +47 -0
  61. package/declarations/components/sector.d.ts.map +1 -0
  62. package/declarations/index.d.ts +24 -0
  63. package/declarations/index.d.ts.map +1 -0
  64. package/declarations/test-support/chart.d.ts +162 -0
  65. package/declarations/test-support/chart.d.ts.map +1 -0
  66. package/declarations/test-support/index.d.ts +3 -0
  67. package/declarations/test-support/index.d.ts.map +1 -0
  68. package/declarations/test-support/polar-chart.d.ts +62 -0
  69. package/declarations/test-support/polar-chart.d.ts.map +1 -0
  70. package/declarations/test-support.d.ts +2 -0
  71. package/declarations/types.d.ts +138 -0
  72. package/declarations/types.d.ts.map +1 -0
  73. package/dist/cartesian-D9hWDamz.js +1217 -0
  74. package/dist/cartesian-D9hWDamz.js.map +1 -0
  75. package/dist/cartesian-chart-BLj6Q_OB.js +1123 -0
  76. package/dist/cartesian-chart-BLj6Q_OB.js.map +1 -0
  77. package/dist/components/area-chart.js +20 -0
  78. package/dist/components/area-chart.js.map +1 -0
  79. package/dist/components/bar-chart.js +20 -0
  80. package/dist/components/bar-chart.js.map +1 -0
  81. package/dist/components/chart-container.js +54 -0
  82. package/dist/components/chart-container.js.map +1 -0
  83. package/dist/components/chart-legend-content.js +48 -0
  84. package/dist/components/chart-legend-content.js.map +1 -0
  85. package/dist/components/chart-style.js +35 -0
  86. package/dist/components/chart-style.js.map +1 -0
  87. package/dist/components/chart-tooltip-content.js +131 -0
  88. package/dist/components/chart-tooltip-content.js.map +1 -0
  89. package/dist/components/dot.js +18 -0
  90. package/dist/components/dot.js.map +1 -0
  91. package/dist/components/line-chart.js +20 -0
  92. package/dist/components/line-chart.js.map +1 -0
  93. package/dist/components/pie-chart.js +6 -0
  94. package/dist/components/pie-chart.js.map +1 -0
  95. package/dist/components/radar-chart.js +22 -0
  96. package/dist/components/radar-chart.js.map +1 -0
  97. package/dist/components/radial-bar-chart.js +20 -0
  98. package/dist/components/radial-bar-chart.js.map +1 -0
  99. package/dist/components/rectangle.js +5 -0
  100. package/dist/components/rectangle.js.map +1 -0
  101. package/dist/components/sector.js +5 -0
  102. package/dist/components/sector.js.map +1 -0
  103. package/dist/config-DnsUmxOT.js +35 -0
  104. package/dist/config-DnsUmxOT.js.map +1 -0
  105. package/dist/index.js +15 -0
  106. package/dist/index.js.map +1 -0
  107. package/dist/parts-BWLhFFjB.js +355 -0
  108. package/dist/parts-BWLhFFjB.js.map +1 -0
  109. package/dist/pie-chart-CmDtW_Ge.js +646 -0
  110. package/dist/pie-chart-CmDtW_Ge.js.map +1 -0
  111. package/dist/polar-chart-GhgOSsH9.js +2242 -0
  112. package/dist/polar-chart-GhgOSsH9.js.map +1 -0
  113. package/dist/rectangle-Cl7tbXuZ.js +166 -0
  114. package/dist/rectangle-Cl7tbXuZ.js.map +1 -0
  115. package/dist/sector-7shQPJuQ.js +565 -0
  116. package/dist/sector-7shQPJuQ.js.map +1 -0
  117. package/dist/test-support.js +470 -0
  118. package/dist/test-support.js.map +1 -0
  119. package/dist/types.js +56 -0
  120. package/dist/types.js.map +1 -0
  121. package/package.json +117 -3
@@ -0,0 +1,470 @@
1
+ import { triggerEvent, focus, blur } from '@ember/test-helpers';
2
+ import { Harness, pressKey } from '@ember-joinery/test-support';
3
+
4
+ const collapse$1 = value => (value ?? '').replace(/\s+/g, ' ').trim();
5
+
6
+ /** A point, in the chart's pixels (its `<svg>`'s coordinates). */
7
+
8
+ /** A series as its harness reads it. */
9
+
10
+ function parsePoints(value) {
11
+ if (!value) return [];
12
+ return value.trim().split(/\s+/).map(pair => {
13
+ const [x, y] = pair.split(',').map(Number);
14
+ return {
15
+ x: x,
16
+ y: y
17
+ };
18
+ });
19
+ }
20
+
21
+ /**
22
+ * Reads a chart tooltip's box (`ChartTooltipContent`): its label and each entry's name and
23
+ * value. A chart's harness gives you the one it shows (`chart.tooltip`); this one also finds a
24
+ * tooltip rendered on its own.
25
+ */
26
+ class ChartTooltipHarness extends Harness {
27
+ static component = 'chart-tooltip';
28
+
29
+ /** `dot`, `line` or `dashed`. */
30
+ get indicator() {
31
+ return this.element.getAttribute('data-indicator');
32
+ }
33
+
34
+ /** The label's text, or `null` without one. */
35
+ get label() {
36
+ const label = this.queryPart('label');
37
+ return label ? collapse$1(label.textContent) : null;
38
+ }
39
+
40
+ /** Each entry: its key, the name it shows, its value's text, and its indicator. */
41
+ get items() {
42
+ return this.parts('item').map(item => ({
43
+ key: item.getAttribute('data-test-jn-value') ?? '',
44
+ name: collapse$1(item.querySelector('[data-test-jn-part="name"]')?.textContent),
45
+ value: item.querySelector('[data-test-jn-part="value"]') ? collapse$1(item.querySelector('[data-test-jn-part="value"]').textContent) : null,
46
+ indicator: item.querySelector('[data-test-jn-part="indicator"]')
47
+ }));
48
+ }
49
+
50
+ /** The entries' names, in order. */
51
+ get names() {
52
+ return this.items.map(item => item.name);
53
+ }
54
+
55
+ /** The entries' values' text, in order. */
56
+ get entryValues() {
57
+ return this.items.map(item => item.value);
58
+ }
59
+
60
+ /** All the text it shows, whitespace collapsed. */
61
+ get text() {
62
+ return collapse$1(this.element.textContent);
63
+ }
64
+ }
65
+
66
+ /** Reads a chart legend (`ChartLegendContent`): each entry's key and label. */
67
+ class ChartLegendHarness extends Harness {
68
+ static component = 'chart-legend';
69
+
70
+ /** Each entry: its key, its label, and its swatch (or `null` where it shows an icon). */
71
+ get items() {
72
+ return this.parts('item').map(item => ({
73
+ key: item.getAttribute('data-test-jn-value') ?? '',
74
+ label: collapse$1(item.textContent),
75
+ swatch: item.querySelector('[data-test-jn-part="swatch"]')
76
+ }));
77
+ }
78
+
79
+ /** The entries' labels, in order. */
80
+ get labels() {
81
+ return this.items.map(item => item.label);
82
+ }
83
+ }
84
+
85
+ /**
86
+ * Drives a chart from `@ember-joinery/chart` (`<ChartContainer>`, or a chart outside one): reads
87
+ * its series, axes, grid, labels and legend, and moves the tooltip with the pointer or the
88
+ * keyboard, as a user does.
89
+ *
90
+ * const chart = new ChartHarness('visitors') // <ChartContainer @name="visitors">
91
+ * assert.deepEqual(chart.xTicks, ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun'])
92
+ * await chart.hover(1)
93
+ * assert.strictEqual(chart.tooltip?.label, 'February')
94
+ * assert.deepEqual(chart.legend?.labels, ['Desktop', 'Mobile'])
95
+ */
96
+ class ChartHarness extends Harness {
97
+ static component = 'chart';
98
+
99
+ /** recharts' wrapper: the chart at its size, holding the `<svg>`, legend and tooltip. */
100
+ get wrapper() {
101
+ return this.part('wrapper');
102
+ }
103
+
104
+ /** The chart's `<svg>`. */
105
+ get surface() {
106
+ return this.part('surface');
107
+ }
108
+
109
+ /** The size the chart drew at. */
110
+ get width() {
111
+ return Number(this.surface.getAttribute('width'));
112
+ }
113
+ get height() {
114
+ return Number(this.surface.getAttribute('height'));
115
+ }
116
+
117
+ /** The plot area: the chart less its margins, axes and legend. */
118
+ get plot() {
119
+ const rect = this.part('plot');
120
+ const read = name => Number(rect.getAttribute(name));
121
+ return {
122
+ x: read('x'),
123
+ y: read('y'),
124
+ width: read('width'),
125
+ height: read('height')
126
+ };
127
+ }
128
+
129
+ /** The value of the chart's `--color-<key>` variable (from its config). */
130
+ color(key) {
131
+ return getComputedStyle(this.element).getPropertyValue(`--color-${key}`).trim();
132
+ }
133
+
134
+ /** Every series, in the order the chart draws them (areas, then bars, then lines). */
135
+ get series() {
136
+ return this.parts('series').map(element => {
137
+ const type = element.getAttribute('data-series-type');
138
+ const curve = element.querySelector('.recharts-area-curve, .recharts-line-curve');
139
+ const area = element.querySelector('.recharts-area-area');
140
+ const painted = area ?? curve ?? element.querySelector('.recharts-rectangle, .recharts-sector');
141
+ return {
142
+ key: element.getAttribute('data-test-jn-value') ?? '',
143
+ type,
144
+ points: parsePoints(element.getAttribute('data-test-jn-points')),
145
+ path: curve?.getAttribute('d') ?? null,
146
+ areaPath: area?.getAttribute('d') ?? null,
147
+ fill: painted?.getAttribute('fill') ?? null,
148
+ stroke: (curve ?? painted)?.getAttribute('stroke') ?? null,
149
+ element
150
+ };
151
+ });
152
+ }
153
+
154
+ /** The series drawn for `key`. Throws when there is none. */
155
+ seriesFor(key) {
156
+ const series = this.series.find(entry => entry.key === key);
157
+ if (!series) throw new Error(`no series "${key}" in ${this}`);
158
+ return series;
159
+ }
160
+
161
+ /** A bar series' bars, as `<path>` elements. */
162
+ bars(key) {
163
+ return Array.from(this.seriesFor(key).element.querySelectorAll('[data-test-jn-part="bar"]'));
164
+ }
165
+
166
+ /** A pie's sectors, as `<path>` elements, in its rows' order. */
167
+ sectors(key) {
168
+ return Array.from(this.seriesFor(key).element.querySelectorAll('[data-test-jn-part="sector"]'));
169
+ }
170
+
171
+ /** A pie's sectors' names (each row's `@nameKey`, or its index). */
172
+ sectorNames(key) {
173
+ return this.sectors(key).map(sector => sector.getAttribute('data-test-jn-value') ?? '');
174
+ }
175
+
176
+ /** A series' dots (circles, or the custom dots it draws). */
177
+ dots(key) {
178
+ const group = this.surface.querySelector(`[data-test-jn-part="dots"][data-test-jn-value="${key}"]`);
179
+ return group ? Array.from(group.children) : [];
180
+ }
181
+
182
+ /**
183
+ * A series' labels' text: its first `LabelList`, or a pie's `@label`s. `labelLists(key)` has
184
+ * every list.
185
+ */
186
+ labels(key) {
187
+ return this.labelLists(key)[0] ?? [];
188
+ }
189
+
190
+ /** The text of each of a series' label lists (a pie's `@label`s count as one), in order. */
191
+ labelLists(key) {
192
+ return Array.from(this.surface.querySelectorAll(`[data-test-jn-part="labels"][data-test-jn-value="${key}"]`)).map(group => Array.from(group.querySelectorAll('text')).map(text => collapse$1(text.textContent)));
193
+ }
194
+
195
+ /** The lines from a pie's sectors to their `@label`s. */
196
+ labelLines(key) {
197
+ const group = this.surface.querySelector(`[data-test-jn-part="labels"][data-test-jn-value="${key}"]`);
198
+ return group ? Array.from(group.querySelectorAll('[data-test-jn-part="label-line"]')) : [];
199
+ }
200
+ #tickTexts(axis) {
201
+ const group = this.queryPart(`${axis}-labels`);
202
+ return group ? Array.from(group.querySelectorAll('text')).map(text => collapse$1(text.textContent)) : [];
203
+ }
204
+
205
+ /** The x-axis's tick labels, as drawn. Empty without a drawn x-axis. */
206
+ get xTicks() {
207
+ return this.#tickTexts('xAxis');
208
+ }
209
+
210
+ /** The y-axis's tick labels, as drawn. Empty without a drawn y-axis. */
211
+ get yTicks() {
212
+ return this.#tickTexts('yAxis');
213
+ }
214
+
215
+ /** The grid's lines: the y of each horizontal one and the x of each vertical one. */
216
+ get gridLines() {
217
+ const lines = this.parts('grid-line');
218
+ const of = (kind, attribute) => lines.filter(line => line.getAttribute('data-test-jn-value') === kind).map(line => Number(line.getAttribute(attribute)));
219
+ return {
220
+ horizontal: of('horizontal', 'y1'),
221
+ vertical: of('vertical', 'x1')
222
+ };
223
+ }
224
+
225
+ /** Where each row sits along the category axis, in the chart's pixels. */
226
+ get categories() {
227
+ const value = this.queryPart('plot')?.getAttribute('data-test-jn-categories');
228
+ return value ? value.split(' ').map(Number) : [];
229
+ }
230
+
231
+ /**
232
+ * Whether it is a pie chart, whose tooltip points at sectors rather than rows. A radar chart's
233
+ * layout is `centric` too, but it marks itself a polar chart (`data-polar-chart`).
234
+ */
235
+ get isPie() {
236
+ const wrapper = this.wrapper;
237
+ return wrapper.getAttribute('data-layout') === 'centric' && !wrapper.hasAttribute('data-polar-chart');
238
+ }
239
+
240
+ /**
241
+ * Moves the pointer over row `index` (its category), which shows the tooltip there. In a pie
242
+ * chart, over the middle of sector `index` of the pie for `key` (the first pie by default).
243
+ */
244
+ async hover(index, key) {
245
+ const wrapper = this.wrapper;
246
+ const rect = wrapper.getBoundingClientRect();
247
+ const scale = wrapper.offsetWidth ? rect.width / wrapper.offsetWidth : 1;
248
+ if (this.isPie) {
249
+ const pie = key ? this.seriesFor(key) : this.series[0];
250
+ const point = pie?.points[index];
251
+ if (!point) throw new Error(`${this} has no sector ${index}`);
252
+ await triggerEvent(wrapper, 'mousemove', {
253
+ clientX: Math.round(rect.left + point.x * scale),
254
+ clientY: Math.round(rect.top + point.y * scale)
255
+ });
256
+ return;
257
+ }
258
+ const coordinate = this.categories[index];
259
+ if (coordinate === undefined) throw new Error(`${this} has no row ${index}`);
260
+ const plot = this.plot;
261
+ const vertical = wrapper.getAttribute('data-layout') === 'vertical';
262
+ // Mouse events carry whole pixels: round to one, kept inside the plot area so a row on its
263
+ // edge is still under the pointer.
264
+ const client = (value, start, size, origin) => {
265
+ const low = Math.ceil(origin + start * scale);
266
+ const high = Math.floor(origin + (start + size) * scale);
267
+ return Math.min(Math.max(Math.round(origin + value * scale), low), high);
268
+ };
269
+ const clientX = vertical ? client(plot.x + plot.width / 2, plot.x, plot.width, rect.left) : client(coordinate, plot.x, plot.width, rect.left);
270
+ const clientY = vertical ? client(coordinate, plot.y, plot.height, rect.top) : client(plot.y + plot.height / 2, plot.y, plot.height, rect.top);
271
+ await triggerEvent(wrapper, 'mousemove', {
272
+ clientX,
273
+ clientY
274
+ });
275
+ }
276
+
277
+ /** Moves the pointer off the chart, which hides the tooltip. */
278
+ async unhover() {
279
+ await triggerEvent(this.wrapper, 'mouseleave');
280
+ }
281
+
282
+ /** Focuses the chart, as Tab does: the tooltip shows the first row (or a pie's first sector). */
283
+ async focus() {
284
+ await focus(this.surface);
285
+ }
286
+
287
+ /** Takes focus away from the chart, which hides a keyboard tooltip. */
288
+ async blur() {
289
+ await blur(this.surface);
290
+ }
291
+
292
+ /**
293
+ * Presses a key on the focused chart: `ArrowRight`/`ArrowLeft` move the tooltip a row (or a
294
+ * sector), `Enter` toggles it.
295
+ */
296
+ async press(key) {
297
+ await pressKey(key);
298
+ }
299
+
300
+ /** Whether the tooltip is showing. */
301
+ get isTooltipVisible() {
302
+ const wrapper = this.wrapper.querySelector('.recharts-tooltip-wrapper');
303
+ return !!wrapper && wrapper.style.visibility === 'visible';
304
+ }
305
+
306
+ /** The tooltip box, while it shows; otherwise `null`. */
307
+ get tooltip() {
308
+ if (!this.isTooltipVisible) return null;
309
+ const tooltip = this.find(ChartTooltipHarness);
310
+ return tooltip.exists ? tooltip : null;
311
+ }
312
+
313
+ /** The tooltip's position against the chart: the translate recharts gives it. */
314
+ get tooltipPosition() {
315
+ const wrapper = this.wrapper.querySelector('.recharts-tooltip-wrapper');
316
+ const match = /translate\(([-\d.]+)px, ([-\d.]+)px\)/.exec(wrapper?.style.transform ?? '');
317
+ return match ? {
318
+ x: Number(match[1]),
319
+ y: Number(match[2])
320
+ } : null;
321
+ }
322
+
323
+ /** The tooltip's cursor: the line (or band) under the active row, or `null`. */
324
+ get cursor() {
325
+ return this.queryPart('cursor');
326
+ }
327
+
328
+ /** The dots drawn at the active row while the tooltip shows. */
329
+ get activeDots() {
330
+ return this.parts('active-dot').flatMap(group => Array.from(group.querySelectorAll('circle')));
331
+ }
332
+
333
+ /** The legend, or `null` without one. */
334
+ get legend() {
335
+ const legend = this.find(ChartLegendHarness);
336
+ return legend.exists ? legend : null;
337
+ }
338
+ }
339
+
340
+ const collapse = value => (value ?? '').replace(/\s+/g, ' ').trim();
341
+
342
+ /** A polar chart's ring: its centre, its radii, and the angles its angle axis runs between. */
343
+
344
+ /** A polar chart's grid, as its harness reads it. */
345
+
346
+ const RADIAN = Math.PI / 180;
347
+ function point(cx, cy, radius, angle) {
348
+ return {
349
+ x: cx + Math.cos(-RADIAN * angle) * radius,
350
+ y: cy + Math.sin(-RADIAN * angle) * radius
351
+ };
352
+ }
353
+
354
+ /**
355
+ * Drives a radar or radial bar chart from `@ember-joinery/chart` (`RadarChart`,
356
+ * `RadialBarChart`): everything `ChartHarness` reads, plus the ring, the polar grid and axes,
357
+ * each radar's polygon and each radial bar's sectors. `hover(index)` points at a row as recharts
358
+ * finds it: on its spoke in a radar chart, on its ring in a radial bar chart.
359
+ *
360
+ * const chart = new PolarChartHarness('visitors') // <ChartContainer @name="visitors">
361
+ * assert.deepEqual(chart.angleTicks, ['January', 'February', 'March', 'April', 'May', 'June'])
362
+ * await chart.hover(1)
363
+ * assert.strictEqual(chart.tooltip?.label, 'February')
364
+ */
365
+ class PolarChartHarness extends ChartHarness {
366
+ /** `centric` (a radar chart, its rows round the ring) or `radial` (rows out from the centre). */
367
+ get layout() {
368
+ return this.wrapper.getAttribute('data-layout') ?? '';
369
+ }
370
+
371
+ /** The chart's ring. */
372
+ get ring() {
373
+ const value = this.queryPart('plot')?.getAttribute('data-test-jn-ring') ?? '';
374
+ const [cx, cy, innerRadius, outerRadius, startAngle, endAngle] = value.split(' ').map(Number);
375
+ return {
376
+ cx: cx ?? 0,
377
+ cy: cy ?? 0,
378
+ innerRadius: innerRadius ?? 0,
379
+ outerRadius: outerRadius ?? 0,
380
+ startAngle: startAngle ?? 0,
381
+ endAngle: endAngle ?? 0
382
+ };
383
+ }
384
+
385
+ /** The polar grid, or `null` without one. */
386
+ get polarGrid() {
387
+ const grid = this.queryPart('polar-grid');
388
+ if (!grid) return null;
389
+ const rings = Array.from(grid.querySelectorAll('[data-test-jn-part="grid-ring"]'));
390
+ const spokes = Array.from(grid.querySelectorAll('[data-test-jn-part="grid-spoke"]'));
391
+ return {
392
+ type: grid.getAttribute('data-grid-type') ?? '',
393
+ radii: rings.map(ring => Number(ring.getAttribute('data-test-jn-value'))),
394
+ angles: spokes.map(spoke => Number(spoke.getAttribute('data-test-jn-value'))),
395
+ rings,
396
+ spokes
397
+ };
398
+ }
399
+ #axisTexts(part) {
400
+ const tick = part === 'angle-axis' ? 'polar-angle-axis-tick' : 'polar-radius-axis-tick';
401
+ const axis = this.queryPart(part);
402
+ return axis ? Array.from(axis.querySelectorAll(`.recharts-${tick}`)).map(entry => collapse(entry.querySelector('text')?.textContent)) : [];
403
+ }
404
+
405
+ /** The angle axis's labels, as drawn (a custom `@tick`'s text included). */
406
+ get angleTicks() {
407
+ return this.#axisTexts('angle-axis');
408
+ }
409
+
410
+ /** The radius axis's labels, as drawn. */
411
+ get radiusTicks() {
412
+ return this.#axisTexts('radius-axis');
413
+ }
414
+
415
+ /** The angle axis's group, or `null` without one. */
416
+ get angleAxis() {
417
+ return this.queryPart('angle-axis');
418
+ }
419
+
420
+ /** The radius axis's group, or `null` without one: its `Label`s draw inside it. */
421
+ get radiusAxis() {
422
+ return this.queryPart('radius-axis');
423
+ }
424
+
425
+ /** A radar's polygon (the `<path>` it fills). Throws when there is no radar for `key`. */
426
+ polygon(key) {
427
+ const series = this.seriesFor(key);
428
+ const path = series.element.querySelector('.recharts-radar-polygon path');
429
+ if (!path) throw new Error(`the radar "${key}" in ${this} draws no polygon`);
430
+ return path;
431
+ }
432
+
433
+ /** A radial bar series' bars (sectors), in its rows' order. */
434
+ radialBars(key) {
435
+ return Array.from(this.seriesFor(key).element.querySelectorAll('[data-test-jn-part="sector"]'));
436
+ }
437
+
438
+ /** The tracks behind the radial bars (`@background`), in their rows' order. */
439
+ get backgroundSectors() {
440
+ return this.parts('background-sector');
441
+ }
442
+
443
+ /**
444
+ * Moves the pointer over row `index`, which shows the tooltip there: halfway along the row's
445
+ * spoke in a radar chart, halfway round its ring in a radial bar chart.
446
+ */
447
+ async hover(index) {
448
+ const coordinate = this.categories[index];
449
+ if (coordinate === undefined) throw new Error(`${this} has no row ${index}`);
450
+ const {
451
+ cx,
452
+ cy,
453
+ innerRadius,
454
+ outerRadius,
455
+ startAngle,
456
+ endAngle
457
+ } = this.ring;
458
+ const target = this.layout === 'centric' ? point(cx, cy, (innerRadius + outerRadius) / 2, coordinate) : point(cx, cy, coordinate, (startAngle + endAngle) / 2);
459
+ const wrapper = this.wrapper;
460
+ const rect = wrapper.getBoundingClientRect();
461
+ const scale = wrapper.offsetWidth ? rect.width / wrapper.offsetWidth : 1;
462
+ await triggerEvent(wrapper, 'mousemove', {
463
+ clientX: Math.round(rect.left + target.x * scale),
464
+ clientY: Math.round(rect.top + target.y * scale)
465
+ });
466
+ }
467
+ }
468
+
469
+ export { ChartHarness, ChartLegendHarness, ChartTooltipHarness, PolarChartHarness };
470
+ //# sourceMappingURL=test-support.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test-support.js","sources":["../src/test-support/chart.ts","../src/test-support/polar-chart.ts"],"sourcesContent":["import { blur, focus, triggerEvent } from '@ember/test-helpers'\nimport { Harness, pressKey } from '@ember-joinery/test-support'\n\nconst collapse = (value: string | null | undefined): string =>\n (value ?? '').replace(/\\s+/g, ' ').trim()\n\n/** A point, in the chart's pixels (its `<svg>`'s coordinates). */\nexport interface ChartPoint {\n x: number\n y: number\n}\n\n/** A series as its harness reads it. */\nexport interface ChartSeriesInfo {\n /** Its data key. */\n key: string\n type: 'area' | 'bar' | 'line' | 'pie'\n /**\n * Each drawn point, in the chart's pixels: a bar's top-left corner, a sector's middle (where\n * its tooltip points).\n */\n points: ChartPoint[]\n /** A line's or area's curve, as the path's `d`. */\n path: string | null\n /** An area's filled path. */\n areaPath: string | null\n fill: string | null\n stroke: string | null\n /** The series' group, to look inside. */\n element: SVGGElement\n}\n\nfunction parsePoints(value: string | null): ChartPoint[] {\n if (!value) return []\n return value\n .trim()\n .split(/\\s+/)\n .map(pair => {\n const [x, y] = pair.split(',').map(Number)\n return { x: x!, y: y! }\n })\n}\n\n/**\n * Reads a chart tooltip's box (`ChartTooltipContent`): its label and each entry's name and\n * value. A chart's harness gives you the one it shows (`chart.tooltip`); this one also finds a\n * tooltip rendered on its own.\n */\nexport class ChartTooltipHarness extends Harness {\n static override component = 'chart-tooltip'\n\n /** `dot`, `line` or `dashed`. */\n get indicator(): string | null {\n return this.element.getAttribute('data-indicator')\n }\n\n /** The label's text, or `null` without one. */\n get label(): string | null {\n const label = this.queryPart('label')\n return label ? collapse(label.textContent) : null\n }\n\n /** Each entry: its key, the name it shows, its value's text, and its indicator. */\n get items(): {\n key: string\n name: string\n value: string | null\n indicator: HTMLElement | null\n }[] {\n return this.parts('item').map(item => ({\n key: item.getAttribute('data-test-jn-value') ?? '',\n name: collapse(item.querySelector('[data-test-jn-part=\"name\"]')?.textContent),\n value: item.querySelector('[data-test-jn-part=\"value\"]')\n ? collapse(item.querySelector('[data-test-jn-part=\"value\"]')!.textContent)\n : null,\n indicator: item.querySelector<HTMLElement>('[data-test-jn-part=\"indicator\"]'),\n }))\n }\n\n /** The entries' names, in order. */\n get names(): string[] {\n return this.items.map(item => item.name)\n }\n\n /** The entries' values' text, in order. */\n get entryValues(): (string | null)[] {\n return this.items.map(item => item.value)\n }\n\n /** All the text it shows, whitespace collapsed. */\n get text(): string {\n return collapse(this.element.textContent)\n }\n}\n\n/** Reads a chart legend (`ChartLegendContent`): each entry's key and label. */\nexport class ChartLegendHarness extends Harness {\n static override component = 'chart-legend'\n\n /** Each entry: its key, its label, and its swatch (or `null` where it shows an icon). */\n get items(): { key: string; label: string; swatch: HTMLElement | null }[] {\n return this.parts('item').map(item => ({\n key: item.getAttribute('data-test-jn-value') ?? '',\n label: collapse(item.textContent),\n swatch: item.querySelector<HTMLElement>('[data-test-jn-part=\"swatch\"]'),\n }))\n }\n\n /** The entries' labels, in order. */\n get labels(): string[] {\n return this.items.map(item => item.label)\n }\n}\n\n/**\n * Drives a chart from `@ember-joinery/chart` (`<ChartContainer>`, or a chart outside one): reads\n * its series, axes, grid, labels and legend, and moves the tooltip with the pointer or the\n * keyboard, as a user does.\n *\n * const chart = new ChartHarness('visitors') // <ChartContainer @name=\"visitors\">\n * assert.deepEqual(chart.xTicks, ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun'])\n * await chart.hover(1)\n * assert.strictEqual(chart.tooltip?.label, 'February')\n * assert.deepEqual(chart.legend?.labels, ['Desktop', 'Mobile'])\n */\nexport class ChartHarness extends Harness {\n static override component = 'chart'\n\n /** recharts' wrapper: the chart at its size, holding the `<svg>`, legend and tooltip. */\n get wrapper(): HTMLElement {\n return this.part('wrapper')\n }\n\n /** The chart's `<svg>`. */\n get surface(): SVGSVGElement {\n return this.part<SVGSVGElement>('surface')\n }\n\n /** The size the chart drew at. */\n get width(): number {\n return Number(this.surface.getAttribute('width'))\n }\n\n get height(): number {\n return Number(this.surface.getAttribute('height'))\n }\n\n /** The plot area: the chart less its margins, axes and legend. */\n get plot(): { x: number; y: number; width: number; height: number } {\n const rect = this.part('plot')\n const read = (name: string) => Number(rect.getAttribute(name))\n return { x: read('x'), y: read('y'), width: read('width'), height: read('height') }\n }\n\n /** The value of the chart's `--color-<key>` variable (from its config). */\n color(key: string): string {\n return getComputedStyle(this.element).getPropertyValue(`--color-${key}`).trim()\n }\n\n /** Every series, in the order the chart draws them (areas, then bars, then lines). */\n get series(): ChartSeriesInfo[] {\n return this.parts<SVGGElement>('series').map(element => {\n const type = element.getAttribute('data-series-type') as ChartSeriesInfo['type']\n const curve = element.querySelector('.recharts-area-curve, .recharts-line-curve')\n const area = element.querySelector('.recharts-area-area')\n const painted =\n area ?? curve ?? element.querySelector('.recharts-rectangle, .recharts-sector')\n return {\n key: element.getAttribute('data-test-jn-value') ?? '',\n type,\n points: parsePoints(element.getAttribute('data-test-jn-points')),\n path: curve?.getAttribute('d') ?? null,\n areaPath: area?.getAttribute('d') ?? null,\n fill: painted?.getAttribute('fill') ?? null,\n stroke: (curve ?? painted)?.getAttribute('stroke') ?? null,\n element,\n }\n })\n }\n\n /** The series drawn for `key`. Throws when there is none. */\n seriesFor(key: string): ChartSeriesInfo {\n const series = this.series.find(entry => entry.key === key)\n if (!series) throw new Error(`no series \"${key}\" in ${this}`)\n return series\n }\n\n /** A bar series' bars, as `<path>` elements. */\n bars(key: string): SVGPathElement[] {\n return Array.from(\n this.seriesFor(key).element.querySelectorAll<SVGPathElement>('[data-test-jn-part=\"bar\"]'),\n )\n }\n\n /** A pie's sectors, as `<path>` elements, in its rows' order. */\n sectors(key: string): SVGPathElement[] {\n return Array.from(\n this.seriesFor(key).element.querySelectorAll<SVGPathElement>('[data-test-jn-part=\"sector\"]'),\n )\n }\n\n /** A pie's sectors' names (each row's `@nameKey`, or its index). */\n sectorNames(key: string): string[] {\n return this.sectors(key).map(sector => sector.getAttribute('data-test-jn-value') ?? '')\n }\n\n /** A series' dots (circles, or the custom dots it draws). */\n dots(key: string): Element[] {\n const group = this.surface.querySelector(\n `[data-test-jn-part=\"dots\"][data-test-jn-value=\"${key}\"]`,\n )\n return group ? Array.from(group.children) : []\n }\n\n /**\n * A series' labels' text: its first `LabelList`, or a pie's `@label`s. `labelLists(key)` has\n * every list.\n */\n labels(key: string): string[] {\n return this.labelLists(key)[0] ?? []\n }\n\n /** The text of each of a series' label lists (a pie's `@label`s count as one), in order. */\n labelLists(key: string): string[][] {\n return Array.from(\n this.surface.querySelectorAll(`[data-test-jn-part=\"labels\"][data-test-jn-value=\"${key}\"]`),\n ).map(group =>\n Array.from(group.querySelectorAll('text')).map(text => collapse(text.textContent)),\n )\n }\n\n /** The lines from a pie's sectors to their `@label`s. */\n labelLines(key: string): SVGPathElement[] {\n const group = this.surface.querySelector(\n `[data-test-jn-part=\"labels\"][data-test-jn-value=\"${key}\"]`,\n )\n return group\n ? Array.from(group.querySelectorAll<SVGPathElement>('[data-test-jn-part=\"label-line\"]'))\n : []\n }\n\n #tickTexts(axis: 'xAxis' | 'yAxis'): string[] {\n const group = this.queryPart(`${axis}-labels`)\n return group\n ? Array.from(group.querySelectorAll('text')).map(text => collapse(text.textContent))\n : []\n }\n\n /** The x-axis's tick labels, as drawn. Empty without a drawn x-axis. */\n get xTicks(): string[] {\n return this.#tickTexts('xAxis')\n }\n\n /** The y-axis's tick labels, as drawn. Empty without a drawn y-axis. */\n get yTicks(): string[] {\n return this.#tickTexts('yAxis')\n }\n\n /** The grid's lines: the y of each horizontal one and the x of each vertical one. */\n get gridLines(): { horizontal: number[]; vertical: number[] } {\n const lines = this.parts('grid-line')\n const of = (kind: string, attribute: string) =>\n lines\n .filter(line => line.getAttribute('data-test-jn-value') === kind)\n .map(line => Number(line.getAttribute(attribute)))\n return { horizontal: of('horizontal', 'y1'), vertical: of('vertical', 'x1') }\n }\n\n /** Where each row sits along the category axis, in the chart's pixels. */\n get categories(): number[] {\n const value = this.queryPart('plot')?.getAttribute('data-test-jn-categories')\n return value ? value.split(' ').map(Number) : []\n }\n\n /**\n * Whether it is a pie chart, whose tooltip points at sectors rather than rows. A radar chart's\n * layout is `centric` too, but it marks itself a polar chart (`data-polar-chart`).\n */\n get isPie(): boolean {\n const wrapper = this.wrapper\n return (\n wrapper.getAttribute('data-layout') === 'centric' && !wrapper.hasAttribute('data-polar-chart')\n )\n }\n\n /**\n * Moves the pointer over row `index` (its category), which shows the tooltip there. In a pie\n * chart, over the middle of sector `index` of the pie for `key` (the first pie by default).\n */\n async hover(index: number, key?: string): Promise<void> {\n const wrapper = this.wrapper\n const rect = wrapper.getBoundingClientRect()\n const scale = wrapper.offsetWidth ? rect.width / wrapper.offsetWidth : 1\n if (this.isPie) {\n const pie = key ? this.seriesFor(key) : this.series[0]\n const point = pie?.points[index]\n if (!point) throw new Error(`${this} has no sector ${index}`)\n await triggerEvent(wrapper, 'mousemove', {\n clientX: Math.round(rect.left + point.x * scale),\n clientY: Math.round(rect.top + point.y * scale),\n })\n return\n }\n const coordinate = this.categories[index]\n if (coordinate === undefined) throw new Error(`${this} has no row ${index}`)\n const plot = this.plot\n const vertical = wrapper.getAttribute('data-layout') === 'vertical'\n // Mouse events carry whole pixels: round to one, kept inside the plot area so a row on its\n // edge is still under the pointer.\n const client = (value: number, start: number, size: number, origin: number) => {\n const low = Math.ceil(origin + start * scale)\n const high = Math.floor(origin + (start + size) * scale)\n return Math.min(Math.max(Math.round(origin + value * scale), low), high)\n }\n const clientX = vertical\n ? client(plot.x + plot.width / 2, plot.x, plot.width, rect.left)\n : client(coordinate, plot.x, plot.width, rect.left)\n const clientY = vertical\n ? client(coordinate, plot.y, plot.height, rect.top)\n : client(plot.y + plot.height / 2, plot.y, plot.height, rect.top)\n await triggerEvent(wrapper, 'mousemove', { clientX, clientY })\n }\n\n /** Moves the pointer off the chart, which hides the tooltip. */\n async unhover(): Promise<void> {\n await triggerEvent(this.wrapper, 'mouseleave')\n }\n\n /** Focuses the chart, as Tab does: the tooltip shows the first row (or a pie's first sector). */\n async focus(): Promise<void> {\n await focus(this.surface)\n }\n\n /** Takes focus away from the chart, which hides a keyboard tooltip. */\n async blur(): Promise<void> {\n await blur(this.surface)\n }\n\n /**\n * Presses a key on the focused chart: `ArrowRight`/`ArrowLeft` move the tooltip a row (or a\n * sector), `Enter` toggles it.\n */\n async press(key: 'ArrowRight' | 'ArrowLeft' | 'Enter'): Promise<void> {\n await pressKey(key)\n }\n\n /** Whether the tooltip is showing. */\n get isTooltipVisible(): boolean {\n const wrapper = this.wrapper.querySelector<HTMLElement>('.recharts-tooltip-wrapper')\n return !!wrapper && wrapper.style.visibility === 'visible'\n }\n\n /** The tooltip box, while it shows; otherwise `null`. */\n get tooltip(): ChartTooltipHarness | null {\n if (!this.isTooltipVisible) return null\n const tooltip = this.find(ChartTooltipHarness)\n return tooltip.exists ? tooltip : null\n }\n\n /** The tooltip's position against the chart: the translate recharts gives it. */\n get tooltipPosition(): { x: number; y: number } | null {\n const wrapper = this.wrapper.querySelector<HTMLElement>('.recharts-tooltip-wrapper')\n const match = /translate\\(([-\\d.]+)px, ([-\\d.]+)px\\)/.exec(wrapper?.style.transform ?? '')\n return match ? { x: Number(match[1]), y: Number(match[2]) } : null\n }\n\n /** The tooltip's cursor: the line (or band) under the active row, or `null`. */\n get cursor(): SVGPathElement | null {\n return this.queryPart<SVGPathElement>('cursor')\n }\n\n /** The dots drawn at the active row while the tooltip shows. */\n get activeDots(): SVGCircleElement[] {\n return this.parts('active-dot').flatMap(group => Array.from(group.querySelectorAll('circle')))\n }\n\n /** The legend, or `null` without one. */\n get legend(): ChartLegendHarness | null {\n const legend = this.find(ChartLegendHarness)\n return legend.exists ? legend : null\n }\n}\n","import { triggerEvent } from '@ember/test-helpers'\nimport { ChartHarness, type ChartPoint } from './chart.ts'\n\nconst collapse = (value: string | null | undefined): string =>\n (value ?? '').replace(/\\s+/g, ' ').trim()\n\n/** A polar chart's ring: its centre, its radii, and the angles its angle axis runs between. */\nexport interface PolarRing {\n cx: number\n cy: number\n innerRadius: number\n outerRadius: number\n startAngle: number\n endAngle: number\n}\n\n/** A polar chart's grid, as its harness reads it. */\nexport interface PolarGridInfo {\n /** `polygon` or `circle`. */\n type: string\n /** Each ring's radius, innermost first as drawn. */\n radii: number[]\n /** Each spoke's angle, in degrees. Empty without spokes (`@radialLines={{false}}`). */\n angles: number[]\n /** The rings (`<path>`s or `<circle>`s) and the spokes (`<line>`s). */\n rings: SVGElement[]\n spokes: SVGLineElement[]\n}\n\nconst RADIAN = Math.PI / 180\n\nfunction point(cx: number, cy: number, radius: number, angle: number): ChartPoint {\n return { x: cx + Math.cos(-RADIAN * angle) * radius, y: cy + Math.sin(-RADIAN * angle) * radius }\n}\n\n/**\n * Drives a radar or radial bar chart from `@ember-joinery/chart` (`RadarChart`,\n * `RadialBarChart`): everything `ChartHarness` reads, plus the ring, the polar grid and axes,\n * each radar's polygon and each radial bar's sectors. `hover(index)` points at a row as recharts\n * finds it: on its spoke in a radar chart, on its ring in a radial bar chart.\n *\n * const chart = new PolarChartHarness('visitors') // <ChartContainer @name=\"visitors\">\n * assert.deepEqual(chart.angleTicks, ['January', 'February', 'March', 'April', 'May', 'June'])\n * await chart.hover(1)\n * assert.strictEqual(chart.tooltip?.label, 'February')\n */\nexport class PolarChartHarness extends ChartHarness {\n /** `centric` (a radar chart, its rows round the ring) or `radial` (rows out from the centre). */\n get layout(): string {\n return this.wrapper.getAttribute('data-layout') ?? ''\n }\n\n /** The chart's ring. */\n get ring(): PolarRing {\n const value = this.queryPart('plot')?.getAttribute('data-test-jn-ring') ?? ''\n const [cx, cy, innerRadius, outerRadius, startAngle, endAngle] = value.split(' ').map(Number)\n return {\n cx: cx ?? 0,\n cy: cy ?? 0,\n innerRadius: innerRadius ?? 0,\n outerRadius: outerRadius ?? 0,\n startAngle: startAngle ?? 0,\n endAngle: endAngle ?? 0,\n }\n }\n\n /** The polar grid, or `null` without one. */\n get polarGrid(): PolarGridInfo | null {\n const grid = this.queryPart('polar-grid')\n if (!grid) return null\n const rings = Array.from(grid.querySelectorAll<SVGElement>('[data-test-jn-part=\"grid-ring\"]'))\n const spokes = Array.from(\n grid.querySelectorAll<SVGLineElement>('[data-test-jn-part=\"grid-spoke\"]'),\n )\n return {\n type: grid.getAttribute('data-grid-type') ?? '',\n radii: rings.map(ring => Number(ring.getAttribute('data-test-jn-value'))),\n angles: spokes.map(spoke => Number(spoke.getAttribute('data-test-jn-value'))),\n rings,\n spokes,\n }\n }\n\n #axisTexts(part: 'angle-axis' | 'radius-axis'): string[] {\n const tick = part === 'angle-axis' ? 'polar-angle-axis-tick' : 'polar-radius-axis-tick'\n const axis = this.queryPart(part)\n return axis\n ? Array.from(axis.querySelectorAll(`.recharts-${tick}`)).map(entry =>\n collapse(entry.querySelector('text')?.textContent),\n )\n : []\n }\n\n /** The angle axis's labels, as drawn (a custom `@tick`'s text included). */\n get angleTicks(): string[] {\n return this.#axisTexts('angle-axis')\n }\n\n /** The radius axis's labels, as drawn. */\n get radiusTicks(): string[] {\n return this.#axisTexts('radius-axis')\n }\n\n /** The angle axis's group, or `null` without one. */\n get angleAxis(): SVGGElement | null {\n return this.queryPart<SVGGElement>('angle-axis')\n }\n\n /** The radius axis's group, or `null` without one: its `Label`s draw inside it. */\n get radiusAxis(): SVGGElement | null {\n return this.queryPart<SVGGElement>('radius-axis')\n }\n\n /** A radar's polygon (the `<path>` it fills). Throws when there is no radar for `key`. */\n polygon(key: string): SVGPathElement {\n const series = this.seriesFor(key)\n const path = series.element.querySelector<SVGPathElement>('.recharts-radar-polygon path')\n if (!path) throw new Error(`the radar \"${key}\" in ${this} draws no polygon`)\n return path\n }\n\n /** A radial bar series' bars (sectors), in its rows' order. */\n radialBars(key: string): SVGPathElement[] {\n return Array.from(\n this.seriesFor(key).element.querySelectorAll<SVGPathElement>('[data-test-jn-part=\"sector\"]'),\n )\n }\n\n /** The tracks behind the radial bars (`@background`), in their rows' order. */\n get backgroundSectors(): SVGPathElement[] {\n return this.parts<SVGPathElement>('background-sector')\n }\n\n /**\n * Moves the pointer over row `index`, which shows the tooltip there: halfway along the row's\n * spoke in a radar chart, halfway round its ring in a radial bar chart.\n */\n override async hover(index: number): Promise<void> {\n const coordinate = this.categories[index]\n if (coordinate === undefined) throw new Error(`${this} has no row ${index}`)\n const { cx, cy, innerRadius, outerRadius, startAngle, endAngle } = this.ring\n const target =\n this.layout === 'centric'\n ? point(cx, cy, (innerRadius + outerRadius) / 2, coordinate)\n : point(cx, cy, coordinate, (startAngle + endAngle) / 2)\n const wrapper = this.wrapper\n const rect = wrapper.getBoundingClientRect()\n const scale = wrapper.offsetWidth ? rect.width / wrapper.offsetWidth : 1\n await triggerEvent(wrapper, 'mousemove', {\n clientX: Math.round(rect.left + target.x * scale),\n clientY: Math.round(rect.top + target.y * scale),\n })\n }\n}\n"],"names":["collapse","value","replace","trim","parsePoints","split","map","pair","x","y","Number","ChartTooltipHarness","Harness","component","indicator","element","getAttribute","label","queryPart","textContent","items","parts","item","key","name","querySelector","names","entryValues","text","ChartLegendHarness","swatch","labels","ChartHarness","wrapper","part","surface","width","height","plot","rect","read","color","getComputedStyle","getPropertyValue","series","type","curve","area","painted","points","path","areaPath","fill","stroke","seriesFor","find","entry","Error","bars","Array","from","querySelectorAll","sectors","sectorNames","sector","dots","group","children","labelLists","labelLines","#tickTexts","axis","xTicks","yTicks","gridLines","lines","of","kind","attribute","filter","line","horizontal","vertical","categories","isPie","hasAttribute","hover","index","getBoundingClientRect","scale","offsetWidth","pie","point","triggerEvent","clientX","Math","round","left","clientY","top","coordinate","undefined","client","start","size","origin","low","ceil","high","floor","min","max","unhover","focus","blur","press","pressKey","isTooltipVisible","style","visibility","tooltip","exists","tooltipPosition","match","exec","transform","cursor","activeDots","flatMap","legend","RADIAN","PI","cx","cy","radius","angle","cos","sin","PolarChartHarness","layout","ring","innerRadius","outerRadius","startAngle","endAngle","polarGrid","grid","rings","spokes","radii","angles","spoke","#axisTexts","tick","angleTicks","radiusTicks","angleAxis","radiusAxis","polygon","radialBars","backgroundSectors","target"],"mappings":";;;AAGA,MAAMA,UAAQ,GAAIC,KAAgC,IAChD,CAACA,KAAK,IAAI,EAAE,EAAEC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAACC,IAAI,EAAE;;AAE3C;;AAMA;;AAoBA,SAASC,WAAWA,CAACH,KAAoB,EAAgB;AACvD,EAAA,IAAI,CAACA,KAAK,EAAE,OAAO,EAAE;AACrB,EAAA,OAAOA,KAAK,CACTE,IAAI,EAAE,CACNE,KAAK,CAAC,KAAK,CAAC,CACZC,GAAG,CAACC,IAAI,IAAI;AACX,IAAA,MAAM,CAACC,CAAC,EAAEC,CAAC,CAAC,GAAGF,IAAI,CAACF,KAAK,CAAC,GAAG,CAAC,CAACC,GAAG,CAACI,MAAM,CAAC;IAC1C,OAAO;AAAEF,MAAAA,CAAC,EAAEA,CAAE;AAAEC,MAAAA,CAAC,EAA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MAAEC,WAAW;MAAEC,UAAU;AAAEC,MAAAA;KAAU,GAAG,IAAI,CAACJ,IAAI;AAC5E,IAAA,MAAMqB,MAAM,GACV,IAAI,CAACtB,MAAM,KAAK,SAAS,GACrB/C,KAAK,CAACwC,EAAE,EAAEC,EAAE,EAAE,CAACQ,WAAW,GAAGC,WAAW,IAAI,CAAC,EAAE1C,UAAU,CAAC,GAC1DR,KAAK,CAACwC,EAAE,EAAEC,EAAE,EAAEjC,UAAU,EAAE,CAAC2C,UAAU,GAAGC,QAAQ,IAAI,CAAC,CAAC;AAC5D,IAAA,MAAM/G,OAAO,GAAG,IAAI,CAACA,OAAO;AAC5B,IAAA,MAAMM,IAAI,GAAGN,OAAO,CAACuD,qBAAqB,EAAE;AAC5C,IAAA,MAAMC,KAAK,GAAGxD,OAAO,CAACyD,WAAW,GAAGnD,IAAI,CAACH,KAAK,GAAGH,OAAO,CAACyD,WAAW,GAAG,CAAC;AACxE,IAAA,MAAMG,YAAY,CAAC5D,OAAO,EAAE,WAAW,EAAE;AACvC6D,MAAAA,OAAO,EAAEC,IAAI,CAACC,KAAK,CAACzD,IAAI,CAAC0D,IAAI,GAAGgE,MAAM,CAACzJ,CAAC,GAAGiF,KAAK,CAAC;AACjDS,MAAAA,OAAO,EAAEH,IAAI,CAACC,KAAK,CAACzD,IAAI,CAAC4D,GAAG,GAAG8D,MAAM,CAACxJ,CAAC,GAAGgF,KAAK;AACjD,KAAC,CAAC;AACJ,EAAA;AACF;;"}
package/dist/types.js ADDED
@@ -0,0 +1,56 @@
1
+ /*
2
+ * The types a chart's config, tooltip and legend use, shaped as shadcn's and recharts' are.
3
+ */
4
+
5
+ /** The colour themes a config's `theme` sets, and the selector each applies under. */
6
+ const THEMES = {
7
+ light: '',
8
+ dark: '.dark'
9
+ };
10
+
11
+ /** A config entry's icon: a `lucide` icon, or a component of your own. */
12
+
13
+ /**
14
+ * One series (or category) in a chart's config: its human-readable label, an icon, and its
15
+ * colour, either one `color` or a `theme` with a colour for light and one for dark.
16
+ */
17
+
18
+ /**
19
+ * The labels, icons and colours of a chart's series, by key. Each colour becomes a CSS
20
+ * variable on the chart, `--color-<key>`, so a series can use `var(--color-desktop)`.
21
+ *
22
+ * const chartConfig = {
23
+ * desktop: { label: 'Desktop', color: 'var(--chart-1)' },
24
+ * mobile: { label: 'Mobile', color: 'var(--chart-2)' },
25
+ * } satisfies ChartConfig
26
+ */
27
+
28
+ /** One row of a chart's data. */
29
+
30
+ /** Where a series or axis finds its value in a row: a key, or a function of the row. */
31
+
32
+ /** One entry of a tooltip, as recharts hands it to the tooltip's content. */
33
+
34
+ /** One entry of a legend, as recharts hands it to the legend's content. */
35
+
36
+ /** Formats a tooltip's label: the active row's category (or its config label). */
37
+
38
+ /** Formats a tooltip entry as text, in place of its indicator, name and value. */
39
+
40
+ /**
41
+ * A component that draws a tooltip entry, in place of its indicator, name and value: what
42
+ * recharts' `formatter` does when it returns markup. It is handed recharts' formatter
43
+ * arguments by name, and the chart's config.
44
+ */
45
+
46
+ /**
47
+ * A tooltip's `@formatter`: a function that returns an entry's text (`ValueFormatter`), or a
48
+ * component that draws the entry (`TooltipFormatterSignature`), for markup.
49
+ */
50
+
51
+ /** What a chart hands its tooltip's `@content`, besides that component's own arguments. */
52
+
53
+ /** What a chart hands its legend's `@content`, besides that component's own arguments. */
54
+
55
+ export { THEMES };
56
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sources":["../src/types.ts"],"sourcesContent":["/*\n * The types a chart's config, tooltip and legend use, shaped as shadcn's and recharts' are.\n */\nimport type { ComponentLike } from '@glint/template'\nimport type { IconNode } from '@ember-joinery/ember/components/icon'\n\n/** The colour themes a config's `theme` sets, and the selector each applies under. */\nexport const THEMES = { light: '', dark: '.dark' } as const\n\n/** A config entry's icon: a `lucide` icon, or a component of your own. */\nexport type ChartIcon = IconNode | ComponentLike<{ Element: Element }>\n\n/**\n * One series (or category) in a chart's config: its human-readable label, an icon, and its\n * colour, either one `color` or a `theme` with a colour for light and one for dark.\n */\nexport type ChartConfigItem = {\n label?: string\n icon?: ChartIcon\n} & (\n { color?: string; theme?: never } | { color?: never; theme: Record<keyof typeof THEMES, string> }\n)\n\n/**\n * The labels, icons and colours of a chart's series, by key. Each colour becomes a CSS\n * variable on the chart, `--color-<key>`, so a series can use `var(--color-desktop)`.\n *\n * const chartConfig = {\n * desktop: { label: 'Desktop', color: 'var(--chart-1)' },\n * mobile: { label: 'Mobile', color: 'var(--chart-2)' },\n * } satisfies ChartConfig\n */\nexport type ChartConfig = Record<string, ChartConfigItem>\n\n/** One row of a chart's data. */\nexport type ChartDatum = Record<string, unknown>\n\n/** Where a series or axis finds its value in a row: a key, or a function of the row. */\nexport type DataKey = string | number | ((datum: ChartDatum) => unknown)\n\n/** One entry of a tooltip, as recharts hands it to the tooltip's content. */\nexport interface TooltipPayloadItem {\n /** The series' `@name`, or its data key. */\n name?: string | number\n /** The value at the active row. */\n value?: unknown\n dataKey?: DataKey\n /** The series' colour: its stroke, or its fill where it has no stroke. */\n color?: string\n fill?: string\n stroke?: string\n /** The row it came from. */\n payload?: Record<string, unknown>\n /** `none` hides the entry. */\n type?: string\n unit?: string\n}\n\n/** One entry of a legend, as recharts hands it to the legend's content. */\nexport interface LegendPayloadItem {\n /** The series' `@name`, or its data key; a pie's sector's name. */\n value: string\n dataKey?: DataKey\n /** A pie's sector's row, which `nameKey` reads. */\n payload?: Record<string, unknown>\n color?: string\n /** `none` hides the entry. */\n type?: string\n /** Whether the series is hidden (`@hide`). */\n inactive?: boolean\n}\n\n/** Formats a tooltip's label: the active row's category (or its config label). */\nexport type LabelFormatter = (label: unknown, payload: readonly TooltipPayloadItem[]) => unknown\n\n/** Formats a tooltip entry as text, in place of its indicator, name and value. */\nexport type ValueFormatter = (\n value: unknown,\n name: string | number,\n item: TooltipPayloadItem,\n index: number,\n payload: unknown,\n) => unknown\n\n/**\n * A component that draws a tooltip entry, in place of its indicator, name and value: what\n * recharts' `formatter` does when it returns markup. It is handed recharts' formatter\n * arguments by name, and the chart's config.\n */\nexport interface TooltipFormatterSignature {\n Args: {\n /** The entry's value at the active row: a number, or a string. */\n value: number | string\n /** The series' name (its `@name`, or its data key). */\n name: string | number\n /** The whole entry. */\n item: TooltipPayloadItem\n /** The entry's index among the tooltip's entries. */\n index: number\n /** The row the entry came from. */\n payload: Record<string, unknown> | undefined\n /** The chart's config. */\n config: ChartConfig\n }\n}\n\n/**\n * A tooltip's `@formatter`: a function that returns an entry's text (`ValueFormatter`), or a\n * component that draws the entry (`TooltipFormatterSignature`), for markup.\n */\nexport type TooltipFormatter = ValueFormatter | ComponentLike<TooltipFormatterSignature>\n\n/** What a chart hands its tooltip's `@content`, besides that component's own arguments. */\nexport interface ChartTooltipContentArgs {\n /** Whether the tooltip is showing. */\n active?: boolean\n /** The entries at the active row, one per series. */\n payload?: readonly TooltipPayloadItem[]\n /** The active row's category. */\n label?: unknown\n /** The chart's config, from `ChartContainer`. */\n config?: ChartConfig\n /** Where the tooltip points, in the chart's pixels. */\n coordinate?: { x: number; y: number }\n /**\n * The chart tooltip's own `@labelClassName`, `@labelFormatter` and `@formatter`, for its\n * content (each one the tooltip was given wins over the content's own, as in recharts).\n */\n tooltip?: {\n labelClassName?: string\n labelFormatter?: LabelFormatter\n formatter?: TooltipFormatter\n }\n}\n\n/** What a chart hands its legend's `@content`, besides that component's own arguments. */\nexport interface ChartLegendContentArgs {\n payload?: readonly LegendPayloadItem[]\n verticalAlign?: 'top' | 'middle' | 'bottom'\n config?: ChartConfig\n /** The legend's own `@class`, as recharts hands its content the legend's `className`. */\n class?: string\n}\n\nexport type {\n AreaSignature,\n AxisArgs,\n BarShapeSignature,\n BarSignature,\n CartesianGridSignature,\n CellSignature,\n ChartLegendSignature,\n ChartTooltipSignature,\n DotArgs,\n DotOption,\n LabelContentSignature,\n LabelListSignature,\n LabelPosition,\n LabelSignature,\n LineSignature,\n PieLabelProps,\n PieLabelSignature,\n PieShapeSignature,\n PieSignature,\n RectangleProps,\n SectorProps,\n SeriesArgs,\n XAxisSignature,\n YAxisSignature,\n} from './-private/parts.gts'\nexport type { PieChartParts, PieChartSignature } from './-private/pie-chart.gts'\nexport type { PolarLabelPosition, PolarViewBox } from './-private/polar.ts'\nexport type { CurveType } from './-private/paths.ts'\nexport type { CartesianChartSignature, CartesianChartParts } from './-private/cartesian-chart.gts'\n"],"names":["THEMES","light","dark"],"mappings":"AAAA;AACA;AACA;;AAIA;AACO,MAAMA,MAAM,GAAG;AAAEC,EAAAA,KAAK,EAAE,EAAE;AAAEC,EAAAA,IAAI,EAAE;AAAQ;;AAEjD;;AAGA;AACA;AACA;AACA;;AAQA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA;;AAGA;;AAGA;;AAkBA;;AAcA;;AAGA;;AASA;AACA;AACA;AACA;AACA;;AAkBA;AACA;AACA;AACA;;AAGA;;AAuBA;;"}