@fusion.dev/helix-headless 0.245.0 → 0.246.0
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/api.json +1 -1
- package/custom-elements.json +1 -1
- package/dist/heatmap/root/buckets.d.ts +27 -0
- package/dist/heatmap/root/buckets.js +24 -1
- package/dist/heatmap/root/heatmap-root.d.ts +53 -2
- package/dist/heatmap/root/heatmap-root.js +59 -3
- package/dist/spatial-bar-chart/bars.d.ts +35 -9
- package/dist/spatial-bar-chart/bars.js +74 -17
- package/dist/spatial-bar-chart/root/spatial-bar-chart-root.d.ts +22 -34
- package/dist/spatial-bar-chart/root/spatial-bar-chart-root.js +46 -111
- package/dist/spatial-heatmap/root/spatial-heatmap-root.d.ts +27 -4
- package/dist/spatial-heatmap/root/spatial-heatmap-root.js +52 -13
- package/dist/spatial-ribbon-chart/ribbons.d.ts +10 -1
- package/dist/spatial-ribbon-chart/ribbons.js +25 -9
- package/dist/spatial-ribbon-chart/root/spatial-ribbon-chart-root.d.ts +43 -3
- package/dist/spatial-ribbon-chart/root/spatial-ribbon-chart-root.js +46 -8
- package/dist/spatial-scatter-chart/field.d.ts +23 -0
- package/dist/spatial-scatter-chart/field.js +47 -1
- package/dist/spatial-scatter-chart/root/spatial-scatter-chart-root.d.ts +46 -3
- package/dist/spatial-scatter-chart/root/spatial-scatter-chart-root.js +56 -13
- package/dist/spatial-surface-chart/grid.d.ts +16 -0
- package/dist/spatial-surface-chart/grid.js +36 -1
- package/dist/spatial-surface-chart/root/spatial-surface-chart-root.d.ts +46 -2
- package/dist/spatial-surface-chart/root/spatial-surface-chart-root.js +53 -7
- package/dist/spatial-treemap/blocks.d.ts +32 -1
- package/dist/spatial-treemap/blocks.js +72 -2
- package/dist/spatial-treemap/root/spatial-treemap-root.d.ts +45 -3
- package/dist/spatial-treemap/root/spatial-treemap-root.js +46 -6
- package/lint.json +1 -1
- package/package.json +5 -5
- package/types/jsx.d.ts +246 -25
- package/types/vue.d.ts +167 -9
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
|
-
import { AriaForwardController, CHART_PLOT, customElement, drawTooltip, formatWords, HelixElement, HelixPlotChangeEvent, HelixPlotTurnEvent, HelixReadingChangeEvent, HelixReadingPressEvent, isRtl, MixinChartSource, MixinChartStatus,
|
|
2
|
+
import { AriaForwardController, CHART_PLOT, customElement, drawTooltip, formatWords, HelixElement, HelixPlotChangeEvent, HelixPlotTurnEvent, HelixReadingChangeEvent, HelixReadingPressEvent, isRtl, MixinChartSource, MixinChartStatus, ReadingsMotionController, shortNumber, spokenReading, words, wordsLocale, } from '@fusion.dev/helix-core';
|
|
3
3
|
import { html, nothing, svg, } from 'lit';
|
|
4
4
|
import { property, state } from 'lit/decorators.js';
|
|
5
5
|
import '../../tooltip/index.js';
|
|
6
6
|
import { boundsOf, boxView, DragTurn, drawBox, SPATIAL_VIEW, TICK_SIZE, turned, wordsFitted, } from '../../spatial-scatter-chart/view.js';
|
|
7
|
-
import { barsDrawn, barsOf, climbing, floorOf,
|
|
7
|
+
import { barItems, barsBetween, barsDrawn, barsOf, climbing, floorOf, heightened, namesOf, paintOrder, rowFits, tallestTimes, widthOf, } from '../bars.js';
|
|
8
8
|
const barSizeOf = (style) => {
|
|
9
9
|
const size = Number.parseFloat(style.columnGap);
|
|
10
10
|
return Number.isFinite(size) && size > 0 ? size : undefined;
|
|
@@ -19,6 +19,12 @@ const TURNS = {
|
|
|
19
19
|
};
|
|
20
20
|
const SERIES = 24;
|
|
21
21
|
const toned = (tone) => tone && /^[a-z][a-z0-9-]*$/.test(tone) ? tone : undefined;
|
|
22
|
+
const scaledAs = (shown, read, sized) => sized === read
|
|
23
|
+
? shown
|
|
24
|
+
: {
|
|
25
|
+
...heightened(shown, sized.axes.extent[1] / read.axes.extent[1]),
|
|
26
|
+
...(sized.climb === undefined ? {} : { climb: sized.climb }),
|
|
27
|
+
};
|
|
22
28
|
const around = (frame, points) => {
|
|
23
29
|
const xs = [frame.x, frame.x + frame.width, ...points.map((point) => point.x)];
|
|
24
30
|
const ys = [frame.y, frame.y + frame.height, ...points.map((point) => point.y)];
|
|
@@ -41,8 +47,19 @@ let HelixHeadlessSpatialBarChart = class HelixHeadlessSpatialBarChart extends Mi
|
|
|
41
47
|
this.camera = next(this.camera);
|
|
42
48
|
}, () => this.requestUpdate());
|
|
43
49
|
this.told = -1;
|
|
44
|
-
this.
|
|
45
|
-
|
|
50
|
+
this.motion = new ReadingsMotionController(this, {
|
|
51
|
+
between: barsBetween,
|
|
52
|
+
grow: () => this.grow,
|
|
53
|
+
growAgain: () => this.growAgain,
|
|
54
|
+
items: barItems,
|
|
55
|
+
timing: () => {
|
|
56
|
+
const style = getComputedStyle(this);
|
|
57
|
+
return {
|
|
58
|
+
duration: style.getPropertyValue('--spatial-bar-chart-move-duration'),
|
|
59
|
+
easing: style.getPropertyValue('--spatial-bar-chart-move-easing'),
|
|
60
|
+
};
|
|
61
|
+
},
|
|
62
|
+
});
|
|
46
63
|
this.aria = new AriaForwardController(this, {
|
|
47
64
|
target: () => this.partNamed('plot'),
|
|
48
65
|
});
|
|
@@ -100,6 +117,9 @@ let HelixHeadlessSpatialBarChart = class HelixHeadlessSpatialBarChart extends Mi
|
|
|
100
117
|
}
|
|
101
118
|
return this.memo.field;
|
|
102
119
|
}
|
|
120
|
+
get shown() {
|
|
121
|
+
return this.motion.drawn ?? this.field;
|
|
122
|
+
}
|
|
103
123
|
get active() {
|
|
104
124
|
return this.pointer.at;
|
|
105
125
|
}
|
|
@@ -110,7 +130,8 @@ let HelixHeadlessSpatialBarChart = class HelixHeadlessSpatialBarChart extends Mi
|
|
|
110
130
|
this.rendered = on;
|
|
111
131
|
this.toggleState('drawn', on);
|
|
112
132
|
}
|
|
113
|
-
requestActive(
|
|
133
|
+
requestActive(at, kind = 'mouse') {
|
|
134
|
+
const index = at < this.field.cells.length ? at : -1;
|
|
114
135
|
if (kind === 'touch') {
|
|
115
136
|
this.pointer.tapTo(index);
|
|
116
137
|
}
|
|
@@ -125,53 +146,13 @@ let HelixHeadlessSpatialBarChart = class HelixHeadlessSpatialBarChart extends Mi
|
|
|
125
146
|
super.willUpdate(changed);
|
|
126
147
|
const field = this.field;
|
|
127
148
|
this.pointer.grid = Math.max(1, field.series.length);
|
|
128
|
-
|
|
129
|
-
const moves = typeof IntersectionObserver === 'function' &&
|
|
130
|
-
typeof requestAnimationFrame === 'function' &&
|
|
131
|
-
!reducedMotion() &&
|
|
132
|
-
!motionPaused();
|
|
133
|
-
if (this.grow && !this.grew && field.readings > 0) {
|
|
134
|
-
this.grew = true;
|
|
135
|
-
this.growth = moves ? {} : undefined;
|
|
136
|
-
}
|
|
137
|
-
else if (this.grow && this.grew && field.readings > 0 && this.drawnLabels && moves) {
|
|
138
|
-
const added = [...labels].filter((label) => !this.drawnLabels?.has(label));
|
|
139
|
-
if (added.length > 0 && !this.growth) {
|
|
140
|
-
const since = performance.now();
|
|
141
|
-
added.forEach((label, index) => {
|
|
142
|
-
this.fresh.set(label, { count: added.length, index, since });
|
|
143
|
-
});
|
|
144
|
-
this.followFresh();
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
if (field.readings > 0) {
|
|
148
|
-
this.drawnLabels = labels;
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
followFresh() {
|
|
152
|
-
const frame = () => {
|
|
153
|
-
const now = performance.now();
|
|
154
|
-
for (const [label, one] of this.fresh) {
|
|
155
|
-
if (now - one.since >= growTime(one.count)) {
|
|
156
|
-
this.fresh.delete(label);
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
this.requestUpdate();
|
|
160
|
-
if (this.fresh.size > 0) {
|
|
161
|
-
requestAnimationFrame(frame);
|
|
162
|
-
}
|
|
163
|
-
};
|
|
164
|
-
requestAnimationFrame(frame);
|
|
149
|
+
this.motion.follow(field, field.readings > 0);
|
|
165
150
|
}
|
|
166
151
|
disconnectedCallback() {
|
|
167
152
|
super.disconnectedCallback();
|
|
168
153
|
this.sizes?.disconnect();
|
|
169
154
|
this.sizes = undefined;
|
|
170
155
|
this.measured = undefined;
|
|
171
|
-
this.seen?.disconnect();
|
|
172
|
-
this.seen = undefined;
|
|
173
|
-
this.gone?.disconnect();
|
|
174
|
-
this.gone = undefined;
|
|
175
156
|
}
|
|
176
157
|
measure() {
|
|
177
158
|
const box = this.partNamed('fallback');
|
|
@@ -225,55 +206,10 @@ let HelixHeadlessSpatialBarChart = class HelixHeadlessSpatialBarChart extends Mi
|
|
|
225
206
|
const times = Math.min(fills, tallestTimes(field, projection, barsDrawn(field, projection, layout)));
|
|
226
207
|
return { field: heightened(field, times), unit };
|
|
227
208
|
}
|
|
228
|
-
watchGrowth() {
|
|
229
|
-
if (!this.growth || this.growth.since !== undefined || this.seen) {
|
|
230
|
-
return;
|
|
231
|
-
}
|
|
232
|
-
this.seen = new IntersectionObserver(([entry]) => {
|
|
233
|
-
if (!entry?.isIntersecting || !this.growth) {
|
|
234
|
-
return;
|
|
235
|
-
}
|
|
236
|
-
this.seen?.disconnect();
|
|
237
|
-
this.seen = undefined;
|
|
238
|
-
const since = performance.now();
|
|
239
|
-
this.growth = { since };
|
|
240
|
-
const length = growTime(this.field.categories.length);
|
|
241
|
-
const frame = () => {
|
|
242
|
-
if (this.growth?.since !== since) {
|
|
243
|
-
return;
|
|
244
|
-
}
|
|
245
|
-
if (performance.now() - since >= length) {
|
|
246
|
-
this.growth = undefined;
|
|
247
|
-
this.watchExit();
|
|
248
|
-
return;
|
|
249
|
-
}
|
|
250
|
-
this.requestUpdate();
|
|
251
|
-
requestAnimationFrame(frame);
|
|
252
|
-
};
|
|
253
|
-
requestAnimationFrame(frame);
|
|
254
|
-
}, { threshold: 0.4 });
|
|
255
|
-
this.seen.observe(this);
|
|
256
|
-
}
|
|
257
|
-
watchExit() {
|
|
258
|
-
if (!this.growAgain || this.gone) {
|
|
259
|
-
return;
|
|
260
|
-
}
|
|
261
|
-
this.gone = new IntersectionObserver(([entry]) => {
|
|
262
|
-
if (!entry || entry.isIntersecting) {
|
|
263
|
-
return;
|
|
264
|
-
}
|
|
265
|
-
this.gone?.disconnect();
|
|
266
|
-
this.gone = undefined;
|
|
267
|
-
this.fresh.clear();
|
|
268
|
-
this.growth = {};
|
|
269
|
-
});
|
|
270
|
-
this.gone.observe(this);
|
|
271
|
-
}
|
|
272
209
|
connectedCallback() {
|
|
273
210
|
super.connectedCallback();
|
|
274
211
|
if (this.hasUpdated) {
|
|
275
212
|
this.measure();
|
|
276
|
-
this.watchGrowth();
|
|
277
213
|
}
|
|
278
214
|
this.pointer.axis = 'none';
|
|
279
215
|
this.pointer.onReading = (heard, detail) => {
|
|
@@ -289,12 +225,17 @@ let HelixHeadlessSpatialBarChart = class HelixHeadlessSpatialBarChart extends Mi
|
|
|
289
225
|
updated(changed) {
|
|
290
226
|
super.updated(changed);
|
|
291
227
|
this.measure();
|
|
292
|
-
this.watchGrowth();
|
|
293
228
|
const field = this.field;
|
|
229
|
+
const shown = this.shown;
|
|
294
230
|
if (field !== this.last) {
|
|
295
231
|
this.last = field;
|
|
232
|
+
this.lastShown = shown;
|
|
296
233
|
this.dispatchEvent(new HelixPlotChangeEvent({ kind: 'data' }));
|
|
297
234
|
}
|
|
235
|
+
else if (shown !== this.lastShown) {
|
|
236
|
+
this.lastShown = shown;
|
|
237
|
+
this.dispatchEvent(new HelixPlotChangeEvent({ kind: 'move' }));
|
|
238
|
+
}
|
|
298
239
|
if (this.pointer.at !== this.told) {
|
|
299
240
|
this.told = this.pointer.at;
|
|
300
241
|
this.dispatchEvent(new HelixPlotChangeEvent({ kind: 'focus' }));
|
|
@@ -339,19 +280,11 @@ let HelixHeadlessSpatialBarChart = class HelixHeadlessSpatialBarChart extends Mi
|
|
|
339
280
|
const sized = lined && room?.bar ? this.sized(read, view.projection, lined, room) : undefined;
|
|
340
281
|
const field = sized?.field ?? read;
|
|
341
282
|
const full = barsDrawn(field, view.projection, layout);
|
|
342
|
-
const
|
|
343
|
-
const
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
const
|
|
347
|
-
const bars = growth
|
|
348
|
-
? barsDrawn(field, view.projection, layout, (one) => grownAt(one.across, categories, elapsed))
|
|
349
|
-
: this.fresh.size > 0
|
|
350
|
-
? barsDrawn(field, view.projection, layout, (one) => {
|
|
351
|
-
const added = this.fresh.get(one.label);
|
|
352
|
-
return added ? grownAt(added.index, added.count, now - added.since) : 1;
|
|
353
|
-
})
|
|
354
|
-
: full;
|
|
283
|
+
const drawn = this.motion.moving ? scaledAs(this.shown, read, field) : field;
|
|
284
|
+
const moving = drawn === field
|
|
285
|
+
? view
|
|
286
|
+
: boxView(drawn.axes, this.camera, [], bare, view.words, wordsLocale(this));
|
|
287
|
+
const bars = drawn === field ? full : barsDrawn(drawn, view.projection, layout);
|
|
355
288
|
const floor = lined && !this.noBox ? floorOf(field, view.projection, lined) : [];
|
|
356
289
|
const active = bars.find((bar) => bar.index === at);
|
|
357
290
|
const cell = field.cells[at];
|
|
@@ -406,6 +339,10 @@ let HelixHeadlessSpatialBarChart = class HelixHeadlessSpatialBarChart extends Mi
|
|
|
406
339
|
y: fits.y + (fits.height - high) / 2,
|
|
407
340
|
}
|
|
408
341
|
: fits;
|
|
342
|
+
const plates = drawn === field || floor.length === 0 || !lined
|
|
343
|
+
? floor
|
|
344
|
+
: floorOf(drawn, view.projection, lined);
|
|
345
|
+
const written = plates === floor ? names : namesOf(drawn, plates, size);
|
|
409
346
|
const bounds = this.drag.frame(placed, view.on([0, 0, 0]));
|
|
410
347
|
const pixel = pixelOf(bounds);
|
|
411
348
|
const font = Math.round(size * 10_000) / 10_000;
|
|
@@ -421,9 +358,9 @@ let HelixHeadlessSpatialBarChart = class HelixHeadlessSpatialBarChart extends Mi
|
|
|
421
358
|
@pointerleave=${this.onDrawingLeave}
|
|
422
359
|
@pointermove=${this.onDrawingMove}
|
|
423
360
|
@pointerup=${this.onDrawingTap}
|
|
424
|
-
>${bars.some((bar) =>
|
|
361
|
+
>${bars.some((bar) => drawn.cells[bar.index]?.tone)
|
|
425
362
|
? svg `<defs><filter height="160%" id="helix-spatial-bar-chart-glow" width="500%" x="-200%" y="-30%"><feGaussianBlur stdDeviation=${(pixel ?? 0.006) * 8}></feGaussianBlur></filter></defs>`
|
|
426
|
-
: nothing}${bare ? nothing : drawBox(
|
|
363
|
+
: nothing}${bare ? nothing : drawBox(moving)}${plates.map((plate) => svg `<path d=${plate.d} part="floor"></path>`)}${written.map((name) => svg `<text data-tone=${name.tone ?? nothing} dominant-baseline="central" font-size=${font} part="tick" style="${name.tone ? `--chart-series: var(--spatial-bar-chart-tone-${name.tone})` : ''}" text-anchor="middle" x=${shortNumber(name.x)} y=${shortNumber(name.y)}>${name.text}</text>`)}${paintOrder(view.projection, bars).map((bar) => svg `${drawn.cells[bar.index]?.tone ? svg `<path d=${bar.drawn.outline} fill="none" filter="url(#helix-spatial-bar-chart-glow)" part="glow" style="--chart-series: var(--spatial-bar-chart-tone-${drawn.cells[bar.index]?.tone})"></path>` : nothing}${this.renderBar(drawn, bar, at)}${bar === active ? svg `<path d=${active.drawn.outline} part="ring"></path>` : nothing}`)}${values.map((value) => {
|
|
427
364
|
const crown = bars.find((bar) => bar.index === value.index)?.drawn.crown ?? value.y + size;
|
|
428
365
|
return svg `<text data-tone=${value.tone ?? nothing} dominant-baseline="central" font-size=${font} part="value" text-anchor="middle" x=${shortNumber(value.x)} y=${shortNumber(crown - size)}>${value.text}</text>`;
|
|
429
366
|
})}${active
|
|
@@ -433,7 +370,8 @@ let HelixHeadlessSpatialBarChart = class HelixHeadlessSpatialBarChart extends Mi
|
|
|
433
370
|
}
|
|
434
371
|
renderBar(field, bar, at) {
|
|
435
372
|
const one = field.cells[bar.index];
|
|
436
|
-
const
|
|
373
|
+
const wore = one?.wore && one.wore.share < 0.5 ? one.wore.depth : one?.depth;
|
|
374
|
+
const series = ((wore ?? 0) % SERIES) + 1;
|
|
437
375
|
const short = (value) => Math.round(value * 1000) / 1000;
|
|
438
376
|
return svg `<g data-index=${bar.index} data-tone=${one?.tone ?? nothing} part="bar${bar.index === at ? ' bar-active' : ''}" style="--chart-series: ${one?.tone ? `var(--spatial-bar-chart-tone-${one.tone}, var(--chart-series-${series}))` : `var(--chart-series-${series})`}">${bar.drawn.faces.map((face) => svg `<path d=${face.d} part="face" style="--spatial-bar-chart-shade: ${short(face.darken)}"></path>`)}</g>`;
|
|
439
377
|
}
|
|
@@ -522,9 +460,6 @@ __decorate([
|
|
|
522
460
|
__decorate([
|
|
523
461
|
state()
|
|
524
462
|
], HelixHeadlessSpatialBarChart.prototype, "room", void 0);
|
|
525
|
-
__decorate([
|
|
526
|
-
state()
|
|
527
|
-
], HelixHeadlessSpatialBarChart.prototype, "growth", void 0);
|
|
528
463
|
HelixHeadlessSpatialBarChart = __decorate([
|
|
529
464
|
customElement('helix-headless-spatial-bar-chart')
|
|
530
465
|
], HelixHeadlessSpatialBarChart);
|
|
@@ -95,7 +95,7 @@ type DrawnCorners = {
|
|
|
95
95
|
*
|
|
96
96
|
* @slot renderer - The renderer's box, which a 3D drawing is made in, over the chart's own.
|
|
97
97
|
*
|
|
98
|
-
* @event {HelixPlotChangeEvent} helix-plot-change - The readings drawn or the reading the keys rest on changed, which a renderer is told. It stays on the chart.
|
|
98
|
+
* @event {HelixPlotChangeEvent} helix-plot-change - The readings drawn or the reading the keys rest on changed, or a frame of a move drew the readings on their way, which a renderer is told. It stays on the chart.
|
|
99
99
|
* @event {HelixPlotTurnEvent} helix-plot-turn - Shift with an arrow asked a renderer's view to turn, by a step across or up.
|
|
100
100
|
*
|
|
101
101
|
* @csspart base - The slab the prisms stand on: a group holding its top and its two sides. Hidden from screen readers.
|
|
@@ -113,6 +113,8 @@ type DrawnCorners = {
|
|
|
113
113
|
*
|
|
114
114
|
* @cssproperty --spatial-heatmap-label-x - Where the `start` or the `end` label stands clear of the drawing, from the footer's inline start, in pixels. The component measures it and writes it on the label, with `data-placed`, as the view turns.
|
|
115
115
|
* @cssproperty --spatial-heatmap-label-y - Where the `start` or the `end` label stands clear of the drawing, from the footer's top, in pixels. The component measures it and writes it on the label, with `data-placed`, as the view turns.
|
|
116
|
+
* @cssproperty --spatial-heatmap-move-duration - How long the prisms take to move to a new table's readings: a cell the table keeps rises or falls to its new height, its tone following it through the tones between, and the heights of all of them follow the table's new highest reading. Unset, a new table is drawn at once. The growth under `grow` keeps its own timing.
|
|
117
|
+
* @cssproperty --spatial-heatmap-move-easing - The curve the prisms move to new readings along.
|
|
116
118
|
* @cssproperty --spatial-heatmap-span - How many cells the drawing spans across: its columns and its rows together. The component writes it on the strip, and a stylesheet that caps the cell size reads it.
|
|
117
119
|
*
|
|
118
120
|
* @cssstate drawn - While a renderer has drawn the relief, and the chart's own drawing stays unseen under it.
|
|
@@ -134,7 +136,7 @@ export declare class HelixHeadlessSpatialHeatmap extends HelixHeadlessHeatmap {
|
|
|
134
136
|
*/
|
|
135
137
|
relief: number;
|
|
136
138
|
/** The prisms drawn on the last render, which the tooltip is placed against. */
|
|
137
|
-
private
|
|
139
|
+
private drawnPrisms;
|
|
138
140
|
/** Where the chart's own drawing is seen from, which a drag or Shift with an arrow turns. */
|
|
139
141
|
private camera;
|
|
140
142
|
/** What places the first and last labels again when one of them, or the footer, changes size. */
|
|
@@ -163,8 +165,10 @@ export declare class HelixHeadlessSpatialHeatmap extends HelixHeadlessHeatmap {
|
|
|
163
165
|
private place;
|
|
164
166
|
/** Where the renderer draws the two ends of the front edge, which the first and last labels stand at. */
|
|
165
167
|
private corners;
|
|
166
|
-
/** The field last told, and the reading, so a renderer is told of a change only. */
|
|
168
|
+
/** The field last told, the frame of a move, and the reading, so a renderer is told of a change only. */
|
|
167
169
|
private told;
|
|
170
|
+
/** `field`, built again only when the readings or what draws them change, so a change is told by identity. */
|
|
171
|
+
private plotted;
|
|
168
172
|
/**
|
|
169
173
|
* What a renderer draws: every reading drawn, down each column and then
|
|
170
174
|
* across, with its place on the grid, its height in cells, and its tone.
|
|
@@ -180,6 +184,14 @@ export declare class HelixHeadlessSpatialHeatmap extends HelixHeadlessHeatmap {
|
|
|
180
184
|
columns: number;
|
|
181
185
|
rows: number;
|
|
182
186
|
};
|
|
187
|
+
/**
|
|
188
|
+
* The relief as drawn this frame, which a renderer draws: `field` at rest,
|
|
189
|
+
* and while the readings grow or move, each prism at its height on the way,
|
|
190
|
+
* in the tone of its reading on the way.
|
|
191
|
+
*/
|
|
192
|
+
get shown(): HelixHeadlessSpatialHeatmap['field'];
|
|
193
|
+
/** The readings as a renderer draws them: each with its place on the grid, its height in cells, and its tone. */
|
|
194
|
+
private plotOf;
|
|
183
195
|
/** The reading the pointer or the keys rest on, as its place in `field.cells`, or `-1`. */
|
|
184
196
|
get active(): number;
|
|
185
197
|
/**
|
|
@@ -226,7 +238,18 @@ export declare class HelixHeadlessSpatialHeatmap extends HelixHeadlessHeatmap {
|
|
|
226
238
|
* left of its first column.
|
|
227
239
|
*/
|
|
228
240
|
protected get room(): number;
|
|
229
|
-
/**
|
|
241
|
+
/**
|
|
242
|
+
* How long a prism takes to rise or fall to a new reading, and its curve:
|
|
243
|
+
* `--spatial-heatmap-move-duration` and `--spatial-heatmap-move-easing`.
|
|
244
|
+
*/
|
|
245
|
+
protected moveTiming(): {
|
|
246
|
+
duration: string;
|
|
247
|
+
easing: string;
|
|
248
|
+
};
|
|
249
|
+
/**
|
|
250
|
+
* The drawn readings as prisms, standing against the highest reading in the
|
|
251
|
+
* table, each at its height on the way while the readings grow or move.
|
|
252
|
+
*/
|
|
230
253
|
private drawnRelief;
|
|
231
254
|
protected render(): TemplateResult;
|
|
232
255
|
/**
|
|
@@ -6,7 +6,7 @@ import '../../tooltip/index.js';
|
|
|
6
6
|
import { fits, toneOf } from '../../heatmap/root/buckets.js';
|
|
7
7
|
import { HelixHeadlessHeatmap } from '../../heatmap/root/heatmap-root.js';
|
|
8
8
|
import { DragTurn, turned } from '../../spatial-scatter-chart/view.js';
|
|
9
|
-
import { ACROSS, heightsOf,
|
|
9
|
+
import { ACROSS, heightsOf, labelPlaces, reliefOf, } from '../projection.js';
|
|
10
10
|
const LABEL_GAP = 4;
|
|
11
11
|
const TURNS = {
|
|
12
12
|
ArrowDown: { across: 0, up: -1 },
|
|
@@ -19,7 +19,7 @@ let HelixHeadlessSpatialHeatmap = class HelixHeadlessSpatialHeatmap extends Heli
|
|
|
19
19
|
super(...arguments);
|
|
20
20
|
this.flat = false;
|
|
21
21
|
this.relief = 2;
|
|
22
|
-
this.
|
|
22
|
+
this.drawnPrisms = undefined;
|
|
23
23
|
this.camera = ISOMETRIC;
|
|
24
24
|
this.labelSizes = undefined;
|
|
25
25
|
this.drag = new DragTurn((next) => {
|
|
@@ -45,7 +45,11 @@ let HelixHeadlessSpatialHeatmap = class HelixHeadlessSpatialHeatmap extends Heli
|
|
|
45
45
|
}
|
|
46
46
|
};
|
|
47
47
|
this.rendered = false;
|
|
48
|
-
this.told = {
|
|
48
|
+
this.told = {
|
|
49
|
+
at: -1,
|
|
50
|
+
field: undefined,
|
|
51
|
+
frame: undefined,
|
|
52
|
+
};
|
|
49
53
|
this.onTurnKeydown = (event) => {
|
|
50
54
|
const turn = TURNS[event.key];
|
|
51
55
|
if (!event.shiftKey ||
|
|
@@ -89,12 +93,33 @@ let HelixHeadlessSpatialHeatmap = class HelixHeadlessSpatialHeatmap extends Heli
|
|
|
89
93
|
}
|
|
90
94
|
}
|
|
91
95
|
get field() {
|
|
92
|
-
const
|
|
96
|
+
const [heat, flat, relief, thresholds, tones] = [
|
|
97
|
+
this.heatField,
|
|
98
|
+
this.flat,
|
|
99
|
+
this.relief,
|
|
100
|
+
this.thresholds,
|
|
101
|
+
this.tones,
|
|
102
|
+
];
|
|
103
|
+
const memo = this.plotted;
|
|
104
|
+
if (memo?.heat !== heat ||
|
|
105
|
+
memo.flat !== flat ||
|
|
106
|
+
memo.relief !== relief ||
|
|
107
|
+
memo.thresholds !== thresholds ||
|
|
108
|
+
memo.tones !== tones) {
|
|
109
|
+
this.plotted = { field: this.plotOf(heat), flat, heat, relief, thresholds, tones };
|
|
110
|
+
}
|
|
111
|
+
return this.plotted.field;
|
|
112
|
+
}
|
|
113
|
+
get shown() {
|
|
114
|
+
return this.motion.moving ? this.plotOf(this.movingField) : this.field;
|
|
115
|
+
}
|
|
116
|
+
plotOf(heat) {
|
|
117
|
+
const cells = heat.cells;
|
|
93
118
|
const rows = this.rowCount;
|
|
94
119
|
const bounds = writtenNumbers(this.thresholds);
|
|
95
120
|
const palette = writtenList(this.tones);
|
|
96
121
|
const tallest = this.flat ? 0 : Math.max(0, this.relief || 0);
|
|
97
|
-
const heights = heightsOf(cells.map((point) => point.value),
|
|
122
|
+
const heights = heightsOf(cells.map((point) => point.value), heat.highest, tallest);
|
|
98
123
|
const first = this.points.length - cells.length;
|
|
99
124
|
return {
|
|
100
125
|
cells: cells.map((cell, index) => ({
|
|
@@ -134,11 +159,17 @@ let HelixHeadlessSpatialHeatmap = class HelixHeadlessSpatialHeatmap extends Heli
|
|
|
134
159
|
updated(changed) {
|
|
135
160
|
super.updated(changed);
|
|
136
161
|
this.placeLabels();
|
|
137
|
-
const field =
|
|
162
|
+
const field = this.field;
|
|
163
|
+
const frame = this.motion.drawn;
|
|
138
164
|
if (field !== this.told.field) {
|
|
139
165
|
this.told.field = field;
|
|
166
|
+
this.told.frame = frame;
|
|
140
167
|
this.dispatchEvent(new HelixPlotChangeEvent({ kind: 'data' }));
|
|
141
168
|
}
|
|
169
|
+
else if (frame !== this.told.frame) {
|
|
170
|
+
this.told.frame = frame;
|
|
171
|
+
this.dispatchEvent(new HelixPlotChangeEvent({ kind: 'move' }));
|
|
172
|
+
}
|
|
142
173
|
if (this.pointer.at !== this.told.at) {
|
|
143
174
|
this.told.at = this.pointer.at;
|
|
144
175
|
this.dispatchEvent(new HelixPlotChangeEvent({ kind: 'focus' }));
|
|
@@ -157,10 +188,17 @@ let HelixHeadlessSpatialHeatmap = class HelixHeadlessSpatialHeatmap extends Heli
|
|
|
157
188
|
const across = width / ACROSS - this.rowCount * pitch - this.gapPx;
|
|
158
189
|
return fits(this.points.length, Math.max(across, Number.MIN_VALUE), this.cellPx, this.gapPx, this.rowCount);
|
|
159
190
|
}
|
|
191
|
+
moveTiming() {
|
|
192
|
+
const style = getComputedStyle(this);
|
|
193
|
+
return {
|
|
194
|
+
duration: style.getPropertyValue('--spatial-heatmap-move-duration'),
|
|
195
|
+
easing: style.getPropertyValue('--spatial-heatmap-move-easing'),
|
|
196
|
+
};
|
|
197
|
+
}
|
|
160
198
|
drawnRelief() {
|
|
161
199
|
const tallest = this.flat ? 0 : Math.max(0, this.relief || 0);
|
|
162
|
-
const
|
|
163
|
-
const heights = heightsOf(
|
|
200
|
+
const moving = this.movingField;
|
|
201
|
+
const heights = heightsOf(moving.cells.map((point) => point.value), moving.highest, tallest);
|
|
164
202
|
return reliefOf(heights, this.rowCount, this.cellPx / (this.cellPx + this.gapPx), this.camera);
|
|
165
203
|
}
|
|
166
204
|
render() {
|
|
@@ -173,9 +211,10 @@ let HelixHeadlessSpatialHeatmap = class HelixHeadlessSpatialHeatmap extends Heli
|
|
|
173
211
|
const chosen = new Set(this.selectionMode ? commaList(this.value) : []);
|
|
174
212
|
const fits = this.drawnRelief();
|
|
175
213
|
const relief = { ...fits, box: this.drag.frame(fits.box, fits.middle) };
|
|
176
|
-
this.
|
|
214
|
+
this.drawnPrisms = relief;
|
|
177
215
|
const at = this.pointer.at;
|
|
178
|
-
const
|
|
216
|
+
const moving = this.movingField.cells;
|
|
217
|
+
const prisms = relief.order.map((index) => this.renderPrism(relief.prisms[index], at === index, chosen.has(keys[index] ?? ''), grid, toneOf(moving[index] ?? cells[index] ?? { value: undefined }, bounds, palette)));
|
|
179
218
|
const { box } = relief;
|
|
180
219
|
const drawing = readable
|
|
181
220
|
? html `<svg
|
|
@@ -233,7 +272,7 @@ let HelixHeadlessSpatialHeatmap = class HelixHeadlessSpatialHeatmap extends Heli
|
|
|
233
272
|
placeLabels() {
|
|
234
273
|
const footer = this.partNamed('footer');
|
|
235
274
|
const [end, start] = [this.partNamed('end'), this.partNamed('start')];
|
|
236
|
-
const relief = this.
|
|
275
|
+
const relief = this.drawnPrisms;
|
|
237
276
|
if (!footer || !end || !start || !relief?.corners) {
|
|
238
277
|
return;
|
|
239
278
|
}
|
|
@@ -299,8 +338,8 @@ let HelixHeadlessSpatialHeatmap = class HelixHeadlessSpatialHeatmap extends Heli
|
|
|
299
338
|
}
|
|
300
339
|
renderTooltip(grid = false) {
|
|
301
340
|
const at = this.pointer.at;
|
|
302
|
-
const prism = this.
|
|
303
|
-
const box = this.
|
|
341
|
+
const prism = this.drawnPrisms?.prisms[at];
|
|
342
|
+
const box = this.drawnPrisms?.box;
|
|
304
343
|
const reading = grid ? undefined : this.pointer;
|
|
305
344
|
if (this.rendered) {
|
|
306
345
|
const place = this.place;
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* front, and a value read under the wrong column bends a ribbon where the
|
|
8
8
|
* data never did.
|
|
9
9
|
*/
|
|
10
|
-
import { type PagePoint, type Projection } from '@fusion.dev/helix-core';
|
|
10
|
+
import { type MotionShares, type PagePoint, type Projection } from '@fusion.dev/helix-core';
|
|
11
11
|
import { type BarCell, type BarField } from '../spatial-bar-chart/bars.js';
|
|
12
12
|
import type { FieldRow } from '../spatial-scatter-chart/field.js';
|
|
13
13
|
/**
|
|
@@ -25,6 +25,15 @@ export type RibbonCell = BarCell;
|
|
|
25
25
|
* a wall.
|
|
26
26
|
*/
|
|
27
27
|
export declare const ribbonsOf: (rows: readonly FieldRow[], columns: readonly number[]) => RibbonField;
|
|
28
|
+
/**
|
|
29
|
+
* The ribbons `at` the shares between `from` and `to`, which the chart draws
|
|
30
|
+
* while its readings move, as a bar chart's bars move: **a reading both
|
|
31
|
+
* tables hold rises or falls** to its new value and slides to its new place,
|
|
32
|
+
* **a reading only `to` holds grows** from zero, and **a reading only `from`
|
|
33
|
+
* held sinks** to zero, then goes. A series the new table drops goes at once,
|
|
34
|
+
* since its ribbon would stand in another's depth.
|
|
35
|
+
*/
|
|
36
|
+
export declare const ribbonsBetween: (from: RibbonField | undefined, to: RibbonField, at: MotionShares) => RibbonField;
|
|
28
37
|
/** One face of a ribbon, as path data, and how far it turns from the light. */
|
|
29
38
|
export interface RibbonFace {
|
|
30
39
|
d: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { pathData } from '@fusion.dev/helix-core';
|
|
2
|
-
import { barsOf } from '../spatial-bar-chart/bars.js';
|
|
1
|
+
import { keysOf, pathData, } from '@fusion.dev/helix-core';
|
|
2
|
+
import { barKeys, barsBetween, barsOf, } from '../spatial-bar-chart/bars.js';
|
|
3
3
|
import { inBox } from '../spatial-scatter-chart/view.js';
|
|
4
4
|
const HEIGHT = 0.6;
|
|
5
5
|
const THICKNESS = 0.45;
|
|
@@ -24,10 +24,23 @@ export const ribbonsOf = (rows, columns) => {
|
|
|
24
24
|
},
|
|
25
25
|
};
|
|
26
26
|
};
|
|
27
|
+
export const ribbonsBetween = (from, to, at) => {
|
|
28
|
+
const field = barsBetween(from, to, at);
|
|
29
|
+
const own = to.cells.length;
|
|
30
|
+
const series = keysOf(to.series);
|
|
31
|
+
const keys = barKeys(field);
|
|
32
|
+
const cells = field.cells.flatMap((cell, index) => {
|
|
33
|
+
if (index < own) {
|
|
34
|
+
return [cell];
|
|
35
|
+
}
|
|
36
|
+
const depth = series.indexOf(keys[index]?.split('\u0001')[1] ?? '');
|
|
37
|
+
return depth < 0 ? [] : [{ ...cell, depth, lane: depth }];
|
|
38
|
+
});
|
|
39
|
+
return { ...field, cells };
|
|
40
|
+
};
|
|
27
41
|
export const ribbonsDrawn = (field, projection) => {
|
|
28
42
|
const [ex, ey, ez] = field.axes.extent;
|
|
29
43
|
const on = (x, y, z) => projection.at(x * ex, -z * ez, y * ey);
|
|
30
|
-
const across = field.categories.length;
|
|
31
44
|
const count = Math.max(field.series.length, 1);
|
|
32
45
|
const half = (THICKNESS * 2) / count / 2;
|
|
33
46
|
const zero = inBox(field.axes.y, Math.max(field.axes.y.range[0], 0));
|
|
@@ -37,13 +50,16 @@ export const ribbonsDrawn = (field, projection) => {
|
|
|
37
50
|
const z = inBox(field.axes.z, series);
|
|
38
51
|
const [near, far] = [z + half, z - half];
|
|
39
52
|
const points = [];
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
53
|
+
field.cells.forEach((cell, index) => {
|
|
54
|
+
if (cell.depth === series && cell.value !== undefined) {
|
|
55
|
+
points.push({
|
|
56
|
+
index,
|
|
57
|
+
value: inBox(field.axes.y, cell.value),
|
|
58
|
+
x: inBox(field.axes.x, cell.across),
|
|
59
|
+
});
|
|
45
60
|
}
|
|
46
|
-
}
|
|
61
|
+
});
|
|
62
|
+
points.sort((one, other) => one.x - other.x);
|
|
47
63
|
const faces = [];
|
|
48
64
|
const front = toward.z >= 0 ? near : far;
|
|
49
65
|
const curtain = (depth) => pathData([
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AriaForwardController, HelixElement } from '@fusion.dev/helix-core';
|
|
1
|
+
import { AriaForwardController, HelixElement, ReadingsMotionController } from '@fusion.dev/helix-core';
|
|
2
2
|
import { type PropertyValues, type TemplateResult } from 'lit';
|
|
3
3
|
import '../../tooltip/index.js';
|
|
4
4
|
import { type RibbonField } from '../ribbons.js';
|
|
@@ -67,7 +67,7 @@ declare const HelixHeadlessSpatialRibbonChart_base: typeof HelixElement & (new (
|
|
|
67
67
|
* @slot error - Content shown after `error-text` while it is set and there are no readings, such as a button that tries again.
|
|
68
68
|
* @slot loading - Content shown while `loading` is set and there are no readings yet. Falls back to `loading-text`.
|
|
69
69
|
*
|
|
70
|
-
* @event {HelixPlotChangeEvent} helix-plot-change - The readings or the reading the keys rest on changed, which the renderer is told. It stays on the chart.
|
|
70
|
+
* @event {HelixPlotChangeEvent} helix-plot-change - The readings or the reading the keys rest on changed, or a frame of a move drew the readings on their way, which the renderer is told. It stays on the chart.
|
|
71
71
|
* @event {HelixPlotTurnEvent} helix-plot-turn - Shift with an arrow asked the view to turn, by a step across or up.
|
|
72
72
|
* @event {HelixReadingChangeEvent} helix-reading-change - The reading moved, or was put away: `index` is the row, or `-1` for none, with its `label` and the `pointerType` that moved it.
|
|
73
73
|
* @event {HelixReadingPressEvent} helix-reading-press - A reading was clicked or pressed with Enter or Space, with the same detail as `helix-reading-change`.
|
|
@@ -107,6 +107,8 @@ declare const HelixHeadlessSpatialRibbonChart_base: typeof HelixElement & (new (
|
|
|
107
107
|
* @csspart tooltip-surface-top - The bubble while it is above the reading. Set alongside `tooltip-surface`.
|
|
108
108
|
* @csspart tooltip-value - A column's value inside the tooltip.
|
|
109
109
|
*
|
|
110
|
+
* @cssproperty --spatial-ribbon-chart-move-duration - How long the ribbons take to move to a new table's readings: a reading the table keeps rises or falls to its new value, a reading it adds grows from zero, and a reading it drops sinks to zero. Unset, a new table is drawn at once. The growth under `grow` keeps its own timing.
|
|
111
|
+
* @cssproperty --spatial-ribbon-chart-move-easing - The curve the ribbons move to new readings along.
|
|
110
112
|
* @cssproperty --spatial-ribbon-chart-shade - How far a ribbon's face turns from the light, from 0 for a level top. The component writes it on each face, and the stylesheet that shades the face reads it.
|
|
111
113
|
*
|
|
112
114
|
* @cssstate active - While a reading is shown, under the pointer or the keys.
|
|
@@ -121,6 +123,29 @@ export declare class HelixHeadlessSpatialRibbonChart extends HelixHeadlessSpatia
|
|
|
121
123
|
* `registerWords('de', { 'helix-spatial-ribbon-chart': { emptyText: 'Keine Werte' } })`.
|
|
122
124
|
*/
|
|
123
125
|
static words: string;
|
|
126
|
+
/**
|
|
127
|
+
* Grows the ribbons in from the floor the first time the chart comes
|
|
128
|
+
* into view with readings, each place across a little after the one before it, so the drawing arrives the way a
|
|
129
|
+
* page's own picture does. The growth is fast at first, slows to rest,
|
|
130
|
+
* and never passes a reading.
|
|
131
|
+
*
|
|
132
|
+
* Under `prefers-reduced-motion`, or where the page has paused its motion
|
|
133
|
+
* through `pauseMotion` or `Motion Toggle`, the ribbons stand at their
|
|
134
|
+
* readings from the start. A later table grows the ribbons it adds, each
|
|
135
|
+
* from the floor, so a reading that arrives while the chart is in view
|
|
136
|
+
* arrives the same way. The readings it keeps move to their new values on `--spatial-ribbon-chart-move-duration`, and stand there at once where it is unset.
|
|
137
|
+
*/
|
|
138
|
+
grow: boolean;
|
|
139
|
+
/**
|
|
140
|
+
* Grows the ribbons in again each time the chart comes back into view
|
|
141
|
+
* after it left it, as a pane does when it is opened again, where `grow`
|
|
142
|
+
* alone grows them the first time only. Only a chart that grows takes it.
|
|
143
|
+
*
|
|
144
|
+
* While it is out of view the ribbons stand at the floor, so the first
|
|
145
|
+
* frame after it returns is the start of the growth and never a flash of
|
|
146
|
+
* the whole drawing.
|
|
147
|
+
*/
|
|
148
|
+
growAgain: boolean;
|
|
124
149
|
/**
|
|
125
150
|
* Draws no box: no edges, grid, numbers, or names, so the readings stand
|
|
126
151
|
* alone and fill the plot, as a picture on a product's own page does. The
|
|
@@ -154,6 +179,14 @@ export declare class HelixHeadlessSpatialRibbonChart extends HelixHeadlessSpatia
|
|
|
154
179
|
private last;
|
|
155
180
|
/** The reading the keys rested on last, so a change of it can be told. */
|
|
156
181
|
private told;
|
|
182
|
+
/**
|
|
183
|
+
* Moves the ribbons from one table to the next, and grows them in under
|
|
184
|
+
* `grow`, timed by `--spatial-ribbon-chart-move-duration` and
|
|
185
|
+
* `--spatial-ribbon-chart-move-easing`.
|
|
186
|
+
*/
|
|
187
|
+
protected readonly motion: ReadingsMotionController<import("../../index.js").BarField>;
|
|
188
|
+
/** The ribbons drawn last, kept so a frame of their move can be told. */
|
|
189
|
+
private lastShown;
|
|
157
190
|
/** Carries a host `aria-labelledby` and `aria-describedby` to the plot. */
|
|
158
191
|
protected readonly aria: AriaForwardController;
|
|
159
192
|
/**
|
|
@@ -163,6 +196,13 @@ export declare class HelixHeadlessSpatialRibbonChart extends HelixHeadlessSpatia
|
|
|
163
196
|
get field(): RibbonField;
|
|
164
197
|
/** The field last read, and the rows and columns it was read from. */
|
|
165
198
|
private memo;
|
|
199
|
+
/**
|
|
200
|
+
* The ribbons as drawn this frame, which a renderer draws: `field` at
|
|
201
|
+
* rest, and while the readings move, every reading between its last value
|
|
202
|
+
* and its new one, in `field`'s order, then each reading the last table
|
|
203
|
+
* had and the new one does not, sinking to zero.
|
|
204
|
+
*/
|
|
205
|
+
get shown(): RibbonField;
|
|
166
206
|
/** The reading the keys or the pointer rest on, as its place in `field.cells`, or `-1`. */
|
|
167
207
|
get active(): number;
|
|
168
208
|
/** The number of places on the grid, which the keys walk. */
|
|
@@ -178,7 +218,7 @@ export declare class HelixHeadlessSpatialRibbonChart extends HelixHeadlessSpatia
|
|
|
178
218
|
* A touch keeps it until a tap lands elsewhere, and a mouse leaving a
|
|
179
219
|
* reading the keys moved to leaves it. Called by the connector.
|
|
180
220
|
*/
|
|
181
|
-
requestActive(
|
|
221
|
+
requestActive(at: number, kind?: 'mouse' | 'pen' | 'touch'): void;
|
|
182
222
|
/**
|
|
183
223
|
* Says where the renderer draws the reading, as fractions of the plot from
|
|
184
224
|
* its top left, or `undefined` while it draws none. The tooltip points
|