@fusion.dev/helix-headless 0.244.2 → 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
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
* calculation off by one drops a day silently. Neither is visible in a
|
|
8
8
|
* screenshot of a strip.
|
|
9
9
|
*/
|
|
10
|
+
import { type MotionItem, type MotionShares } from '@fusion.dev/helix-core';
|
|
10
11
|
/** A reading, reduced to what the bucketing needs. */
|
|
11
12
|
export interface Reading {
|
|
12
13
|
tone?: string | undefined;
|
|
@@ -78,3 +79,29 @@ export declare const overviewOf: (cells: readonly Reading[]) => Overview;
|
|
|
78
79
|
* reading past the end. Undefined where the reading at `at` carries no date.
|
|
79
80
|
*/
|
|
80
81
|
export declare const monthPage: (whens: readonly (string | undefined)[], at: number, forward: boolean) => number | undefined;
|
|
82
|
+
/** A reading as the strip's motion knows it: by its row's label, numbered where a label comes again. */
|
|
83
|
+
export interface HeatCell extends Reading {
|
|
84
|
+
key: string;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* The readings a strip draws, as its motion moves them: each drawn cell by
|
|
88
|
+
* its key, how many cells stand in a column, and the highest reading in the
|
|
89
|
+
* table, which a spatial heatmap's heights are measured against.
|
|
90
|
+
*/
|
|
91
|
+
export interface HeatField {
|
|
92
|
+
cells: HeatCell[];
|
|
93
|
+
highest: number;
|
|
94
|
+
rows: number;
|
|
95
|
+
}
|
|
96
|
+
/** Each cell as the strip's motion knows it: by its key, growing in a column at a time. */
|
|
97
|
+
export declare const heatItems: (field: HeatField) => MotionItem[];
|
|
98
|
+
/**
|
|
99
|
+
* The strip `at` the shares between `from` and `to`, which it draws while its
|
|
100
|
+
* readings move. **A cell both hold moves from its old reading to its new
|
|
101
|
+
* one**, and its tone follows the reading through the buckets between.
|
|
102
|
+
* **A cell only `to` holds grows from empty**: it has no tone until it starts,
|
|
103
|
+
* then its reading climbs from zero, or a cell's own `data-tone` shows at
|
|
104
|
+
* once. A cell `from` held and `to` does not is gone at once, since every
|
|
105
|
+
* cell after it has taken a step along the strip.
|
|
106
|
+
*/
|
|
107
|
+
export declare const heatBetween: (from: HeatField | undefined, to: HeatField, at: MotionShares) => HeatField;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { extremesOf } from '@fusion.dev/helix-core';
|
|
1
|
+
import { extremesOf, mix } from '@fusion.dev/helix-core';
|
|
2
2
|
export const toneOf = (reading, thresholds, tones) => {
|
|
3
3
|
if (reading.tone) {
|
|
4
4
|
return reading.tone;
|
|
@@ -58,3 +58,26 @@ export const monthPage = (whens, at, forward) => {
|
|
|
58
58
|
}
|
|
59
59
|
return forward ? whens.length - 1 : 0;
|
|
60
60
|
};
|
|
61
|
+
export const heatItems = (field) => field.cells.map((cell, index) => ({
|
|
62
|
+
key: cell.key,
|
|
63
|
+
step: Math.floor(index / Math.max(1, field.rows)),
|
|
64
|
+
}));
|
|
65
|
+
export const heatBetween = (from, to, at) => {
|
|
66
|
+
const before = new Map((from?.cells ?? []).map((cell) => [cell.key, cell]));
|
|
67
|
+
const cells = to.cells.map((cell) => {
|
|
68
|
+
const share = at.share(cell.key);
|
|
69
|
+
const old = before.get(cell.key);
|
|
70
|
+
if (!old || at.floor(cell.key) || old.value === undefined) {
|
|
71
|
+
if (share <= 0) {
|
|
72
|
+
return { key: cell.key, value: undefined };
|
|
73
|
+
}
|
|
74
|
+
return { ...cell, value: cell.value === undefined ? undefined : cell.value * share };
|
|
75
|
+
}
|
|
76
|
+
return {
|
|
77
|
+
...cell,
|
|
78
|
+
value: cell.value === undefined ? undefined : mix(old.value, cell.value, share),
|
|
79
|
+
};
|
|
80
|
+
});
|
|
81
|
+
const highest = from && at.axes < 1 ? mix(from.highest, to.highest, at.axes) : to.highest;
|
|
82
|
+
return { ...to, cells, highest };
|
|
83
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { AriaForwardController, HelixElement, StatusController } from '@fusion.dev/helix-core';
|
|
1
|
+
import { AriaForwardController, HelixElement, ReadingsMotionController, StatusController } from '@fusion.dev/helix-core';
|
|
2
2
|
import { nothing, type PropertyValues, type TemplateResult } from 'lit';
|
|
3
3
|
import '../../tooltip/index.js';
|
|
4
|
-
import { type Reading } from './buckets.js';
|
|
4
|
+
import { type HeatField, type Reading } from './buckets.js';
|
|
5
5
|
declare const HelixHeadlessHeatmap_base: typeof HelixElement & (new (...args: any[]) => import("@fusion.dev/helix-core").MixinChartSourceInterface) & (new (...args: any[]) => import("@fusion.dev/helix-core").MixinChartStatusInterface);
|
|
6
6
|
/**
|
|
7
7
|
* @summary A strip of cells, each colored by its reading, for uptime, contributions, or activity.
|
|
@@ -185,6 +185,30 @@ export declare class HelixHeadlessHeatmap extends HelixHeadlessHeatmap_base {
|
|
|
185
185
|
* `min-cell` is.
|
|
186
186
|
*/
|
|
187
187
|
gap: number;
|
|
188
|
+
/**
|
|
189
|
+
* Grows the cells in the first time the strip comes into view with
|
|
190
|
+
* readings, a column at a time from the first, so the drawing arrives the
|
|
191
|
+
* way a page's own picture does. Each cell starts empty and its reading
|
|
192
|
+
* climbs to its own, its tone stepping up through the tones between, fast
|
|
193
|
+
* at first and slow to rest. A cell's own `data-tone` shows as its column
|
|
194
|
+
* starts.
|
|
195
|
+
*
|
|
196
|
+
* Under `prefers-reduced-motion`, or where the page has paused its motion
|
|
197
|
+
* through `pauseMotion` or `Motion Toggle`, the cells take their tones from
|
|
198
|
+
* the start. A later table grows the cells it adds the same way, such as
|
|
199
|
+
* the newest day of a strip that keeps the latest.
|
|
200
|
+
*/
|
|
201
|
+
grow: boolean;
|
|
202
|
+
/**
|
|
203
|
+
* Grows the cells in again each time the strip comes back into view after
|
|
204
|
+
* it left it, as a pane does when it is opened again, where `grow` alone
|
|
205
|
+
* grows them the first time only. Only a strip that grows takes it.
|
|
206
|
+
*
|
|
207
|
+
* While it is out of view the cells stand empty, so the first frame after
|
|
208
|
+
* it returns is the start of the growth and never a flash of the whole
|
|
209
|
+
* strip.
|
|
210
|
+
*/
|
|
211
|
+
growAgain: boolean;
|
|
188
212
|
/**
|
|
189
213
|
* The smallest a cell may get before the strip draws fewer of them, in CSS pixels.
|
|
190
214
|
*
|
|
@@ -336,6 +360,33 @@ export declare class HelixHeadlessHeatmap extends HelixHeadlessHeatmap_base {
|
|
|
336
360
|
* image a reader lands on. The host is a generic around it.
|
|
337
361
|
*/
|
|
338
362
|
protected readonly aria: AriaForwardController;
|
|
363
|
+
/** Grows the cells in under `grow`, and moves them to new readings on `moveTiming`. */
|
|
364
|
+
protected readonly motion: ReadingsMotionController<HeatField>;
|
|
365
|
+
/**
|
|
366
|
+
* How long a cell's reading takes to move to a new one, and its curve. The
|
|
367
|
+
* flat strip moves none: a cell changes tone through the stylesheet's own
|
|
368
|
+
* transition of its color. A spatial heatmap, whose prisms rise and fall,
|
|
369
|
+
* reads its own hooks.
|
|
370
|
+
*/
|
|
371
|
+
protected moveTiming(): {
|
|
372
|
+
duration: string;
|
|
373
|
+
easing: string;
|
|
374
|
+
};
|
|
375
|
+
/**
|
|
376
|
+
* The readings drawn, read once for each table and each width, and which
|
|
377
|
+
* table they come from: a new width or row count lays the same table out
|
|
378
|
+
* anew, which is not a new reading.
|
|
379
|
+
*/
|
|
380
|
+
private heatMemo;
|
|
381
|
+
/** The table the motion last followed, by `heatMemo`'s count. */
|
|
382
|
+
private followed;
|
|
383
|
+
/**
|
|
384
|
+
* The drawn readings as the strip's motion moves them: each by its row's
|
|
385
|
+
* label, newest kept, with the highest reading in the table.
|
|
386
|
+
*/
|
|
387
|
+
protected get heatField(): HeatField;
|
|
388
|
+
/** The drawn readings as they stand this frame: on their way while they grow or move, and as the table holds them at rest. */
|
|
389
|
+
protected get movingField(): HeatField;
|
|
339
390
|
private observer;
|
|
340
391
|
private announced;
|
|
341
392
|
/**
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
|
-
import { AriaForwardController, byRow, CHART_PLOT, commaList, customElement, drawTooltip, formatWords, HelixElement, HelixReadingChangeEvent, HelixReadingPressEvent, HelixResizeEvent, MixinChartSource, MixinChartStatus, markRegion, numberConverter, pressedValue, rangeAdd, requestValue, StatusController, spokenReading, words, wordsLocale, writtenList, writtenNumbers, } from '@fusion.dev/helix-core';
|
|
2
|
+
import { AriaForwardController, byRow, CHART_PLOT, commaList, customElement, drawTooltip, formatWords, HelixElement, HelixReadingChangeEvent, HelixReadingPressEvent, HelixResizeEvent, keysOf, MixinChartSource, MixinChartStatus, markRegion, numberConverter, pressedValue, ReadingsMotionController, rangeAdd, requestValue, StatusController, spokenReading, words, wordsLocale, writtenList, writtenNumbers, } from '@fusion.dev/helix-core';
|
|
3
3
|
import { html, nothing } from 'lit';
|
|
4
4
|
import { property, state } from 'lit/decorators.js';
|
|
5
5
|
import '../../tooltip/index.js';
|
|
6
6
|
import { inSequence, rectangleOf } from '../rectangle.js';
|
|
7
|
-
import { fits, monthPage, overviewOf, toneOf } from './buckets.js';
|
|
7
|
+
import { fits, heatBetween, heatItems, monthPage, overviewOf, toneOf, } from './buckets.js';
|
|
8
8
|
const dayOf = (when, locale) => {
|
|
9
9
|
if (!when) {
|
|
10
10
|
return undefined;
|
|
@@ -30,6 +30,8 @@ let HelixHeadlessHeatmap = class HelixHeadlessHeatmap extends MixinChartStatus(M
|
|
|
30
30
|
super(...arguments);
|
|
31
31
|
this.busiestLabel = 'Busiest';
|
|
32
32
|
this.gap = 2;
|
|
33
|
+
this.grow = false;
|
|
34
|
+
this.growAgain = false;
|
|
33
35
|
this.minCell = 8;
|
|
34
36
|
this.overviewLabel = '{busiestLabel}: {busiest}; {totalLabel} {total}.';
|
|
35
37
|
this.rows = 1;
|
|
@@ -46,6 +48,14 @@ let HelixHeadlessHeatmap = class HelixHeadlessHeatmap extends MixinChartStatus(M
|
|
|
46
48
|
this.aria = new AriaForwardController(this, {
|
|
47
49
|
target: () => this.partNamed('strip'),
|
|
48
50
|
});
|
|
51
|
+
this.motion = new ReadingsMotionController(this, {
|
|
52
|
+
between: heatBetween,
|
|
53
|
+
grow: () => this.grow,
|
|
54
|
+
growAgain: () => this.growAgain,
|
|
55
|
+
items: heatItems,
|
|
56
|
+
timing: () => this.moveTiming(),
|
|
57
|
+
});
|
|
58
|
+
this.followed = -1;
|
|
49
59
|
this.observer = undefined;
|
|
50
60
|
this.announced = undefined;
|
|
51
61
|
this.anchor = -1;
|
|
@@ -123,6 +133,36 @@ let HelixHeadlessHeatmap = class HelixHeadlessHeatmap extends MixinChartStatus(M
|
|
|
123
133
|
get visible() {
|
|
124
134
|
return Math.min(this.points.length, this.room);
|
|
125
135
|
}
|
|
136
|
+
moveTiming() {
|
|
137
|
+
return { duration: '', easing: '' };
|
|
138
|
+
}
|
|
139
|
+
get heatField() {
|
|
140
|
+
const [series, rows, room, tall] = [this.series, this.sourceRows, this.room, this.rowCount];
|
|
141
|
+
const memo = this.heatMemo;
|
|
142
|
+
if (memo?.series !== series || memo.rows !== rows || memo.room !== room || memo.tall !== tall) {
|
|
143
|
+
const points = this.points;
|
|
144
|
+
const first = Math.max(0, points.length - room);
|
|
145
|
+
const drawn = points.slice(first);
|
|
146
|
+
const keys = keysOf(drawn.map((_, index) => rows[first + index]?.label ?? ''));
|
|
147
|
+
const table = memo?.series === series && memo.rows === rows ? memo.table : (memo?.table ?? -1) + 1;
|
|
148
|
+
this.heatMemo = {
|
|
149
|
+
field: {
|
|
150
|
+
cells: drawn.map((point, index) => ({ ...point, key: keys[index] })),
|
|
151
|
+
highest: points.reduce((high, point) => (point.value !== undefined && point.value > high ? point.value : high), 0),
|
|
152
|
+
rows: tall,
|
|
153
|
+
},
|
|
154
|
+
room,
|
|
155
|
+
rows,
|
|
156
|
+
series,
|
|
157
|
+
table,
|
|
158
|
+
tall,
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
return this.heatMemo.field;
|
|
162
|
+
}
|
|
163
|
+
get movingField() {
|
|
164
|
+
return this.motion.drawn ?? this.heatField;
|
|
165
|
+
}
|
|
126
166
|
keysOf(cells) {
|
|
127
167
|
const offset = this.points.length - cells.length;
|
|
128
168
|
const rows = this.sourceRows;
|
|
@@ -216,6 +256,15 @@ let HelixHeadlessHeatmap = class HelixHeadlessHeatmap extends MixinChartStatus(M
|
|
|
216
256
|
willUpdate(changed) {
|
|
217
257
|
super.willUpdate(changed);
|
|
218
258
|
this.pointer.grid = this.rowCount;
|
|
259
|
+
const field = this.heatField;
|
|
260
|
+
const table = this.heatMemo?.table ?? -1;
|
|
261
|
+
if (table === this.followed) {
|
|
262
|
+
this.motion.relayout(field, field.cells.length > 0);
|
|
263
|
+
}
|
|
264
|
+
else {
|
|
265
|
+
this.followed = table;
|
|
266
|
+
this.motion.follow(field, field.cells.length > 0);
|
|
267
|
+
}
|
|
219
268
|
}
|
|
220
269
|
pageFrom(at, forward) {
|
|
221
270
|
const offset = this.points.length - this.drawn.length;
|
|
@@ -276,8 +325,9 @@ let HelixHeadlessHeatmap = class HelixHeadlessHeatmap extends MixinChartStatus(M
|
|
|
276
325
|
const grid = readable && this.selectionMode !== undefined;
|
|
277
326
|
const keys = this.selectionMode ? this.keysOf(cells) : [];
|
|
278
327
|
const chosen = new Set(this.selectionMode ? commaList(this.value) : []);
|
|
328
|
+
const moving = this.movingField.cells;
|
|
279
329
|
const drawn = cells.map((reading, index) => {
|
|
280
|
-
const tone = toneOf(reading, bounds, palette);
|
|
330
|
+
const tone = toneOf(moving[index] ?? reading, bounds, palette);
|
|
281
331
|
const active = this.pointer.at === index;
|
|
282
332
|
const picked = chosen.has(keys[index] ?? '');
|
|
283
333
|
if (grid) {
|
|
@@ -390,6 +440,12 @@ __decorate([
|
|
|
390
440
|
__decorate([
|
|
391
441
|
property({ converter: numberConverter('gap', 2, 'pixels') })
|
|
392
442
|
], HelixHeadlessHeatmap.prototype, "gap", void 0);
|
|
443
|
+
__decorate([
|
|
444
|
+
property({ reflect: true, type: Boolean })
|
|
445
|
+
], HelixHeadlessHeatmap.prototype, "grow", void 0);
|
|
446
|
+
__decorate([
|
|
447
|
+
property({ attribute: 'grow-again', reflect: true, type: Boolean })
|
|
448
|
+
], HelixHeadlessHeatmap.prototype, "growAgain", void 0);
|
|
393
449
|
__decorate([
|
|
394
450
|
property({ attribute: 'min-cell', converter: numberConverter('min-cell', 8, 'pixels') })
|
|
395
451
|
], HelixHeadlessHeatmap.prototype, "minCell", void 0);
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* measured from anywhere but zero says one value is a multiple of another
|
|
7
7
|
* when it is not.
|
|
8
8
|
*/
|
|
9
|
-
import { type Drawn, type PagePoint, type Projection } from '@fusion.dev/helix-core';
|
|
9
|
+
import { type Drawn, type MotionItem, type MotionShares, type PagePoint, type Projection } from '@fusion.dev/helix-core';
|
|
10
10
|
import { type FieldRow, type PlotAxis } from '../spatial-scatter-chart/field.js';
|
|
11
11
|
import { type BoxExtent } from '../spatial-scatter-chart/view.js';
|
|
12
12
|
/** One place on the grid: a category across, a series in depth, and its value, where the table has one. */
|
|
@@ -26,10 +26,26 @@ export interface BarCell {
|
|
|
26
26
|
label: string;
|
|
27
27
|
/** Which row of the grid in depth it stands in: its series, or the one row of a stacked chart. */
|
|
28
28
|
lane: number;
|
|
29
|
+
/**
|
|
30
|
+
* What the cell is known by from one table to the next, on a field drawn
|
|
31
|
+
* between two while the readings move. A table's own field has none.
|
|
32
|
+
*/
|
|
33
|
+
key?: string | undefined;
|
|
29
34
|
/** The row it was read from, counting from zero. */
|
|
30
35
|
row: number;
|
|
31
36
|
/** The tone the cell names with `data-tone`, which colors its own bar, where it names one. */
|
|
32
37
|
tone?: string | undefined;
|
|
38
|
+
/**
|
|
39
|
+
* On a field drawn between two, the series whose color the cell moves
|
|
40
|
+
* from, and how far it has come, from 0 to 1, where a move takes it to
|
|
41
|
+
* another series' place in depth, such as when a series before it left.
|
|
42
|
+
* Its color moves with it, so a bar shrinking out and the one taking its
|
|
43
|
+
* place never wear one color.
|
|
44
|
+
*/
|
|
45
|
+
wore?: {
|
|
46
|
+
depth: number;
|
|
47
|
+
share: number;
|
|
48
|
+
} | undefined;
|
|
33
49
|
/** The value, where the cell holds a number. */
|
|
34
50
|
value?: number | undefined;
|
|
35
51
|
}
|
|
@@ -167,7 +183,8 @@ export interface FloorPlate {
|
|
|
167
183
|
* The places on the floor of a row, one for each category in each lane,
|
|
168
184
|
* whether a bar stands there or not: a square a little wider than a bar's
|
|
169
185
|
* footprint, turned as the bars are, where zero stands on the value axis,
|
|
170
|
-
* along the row `layout` lays.
|
|
186
|
+
* along the row `layout` lays. Between two tables, each place slides with
|
|
187
|
+
* its bar.
|
|
171
188
|
*/
|
|
172
189
|
export declare const floorOf: (field: BarField, projection: Projection, layout?: Exclude<BarLayout, 'grid'>) => FloorPlate[];
|
|
173
190
|
/** A category's name written under its place in a row. */
|
|
@@ -189,11 +206,20 @@ export interface RowName {
|
|
|
189
206
|
*/
|
|
190
207
|
export declare const namesOf: (field: BarField, plates: readonly FloorPlate[], size: number) => RowName[];
|
|
191
208
|
/**
|
|
192
|
-
*
|
|
193
|
-
*
|
|
194
|
-
*
|
|
195
|
-
|
|
209
|
+
* The key of each cell of `field`, in the order of its cells: its
|
|
210
|
+
* category's name and its series', each numbered where it comes again. A
|
|
211
|
+
* field drawn between two tables carries each cell's key with it.
|
|
212
|
+
*/
|
|
213
|
+
export declare const barKeys: (field: BarField) => string[];
|
|
214
|
+
/** Each cell of `field` as the chart's motion knows it: by its key, growing in with its category. */
|
|
215
|
+
export declare const barItems: (field: BarField) => MotionItem[];
|
|
216
|
+
/**
|
|
217
|
+
* The bars `at` the shares between `from` and `to`, which the chart draws
|
|
218
|
+
* while its readings move: `to`'s cells, each at its share of the way from
|
|
219
|
+
* its reading in `from` to its reading in `to`, then each cell `from` had
|
|
220
|
+
* and `to` does not, shrinking to the floor. **A cell moves along the floor
|
|
221
|
+
* as well as up**, so a category added before it slides it across. The axes
|
|
222
|
+
* move with `at.axes`, and the value axis's ticks are the new ones from the
|
|
223
|
+
* start. With no `from`, every bar grows from the floor.
|
|
196
224
|
*/
|
|
197
|
-
export declare const
|
|
198
|
-
/** How long the bars of `categories` take to grow in, the last one included, in milliseconds. */
|
|
199
|
-
export declare const growTime: (categories: number) => number;
|
|
225
|
+
export declare const barsBetween: (from: BarField | undefined, to: BarField, at: MotionShares) => BarField;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { depthOrder, pathData, solid, ticks, } from '@fusion.dev/helix-core';
|
|
1
|
+
import { depthOrder, keysOf, mix, mixAxis, pathData, solid, ticks, } from '@fusion.dev/helix-core';
|
|
2
2
|
import { niceRange } from '../spatial-scatter-chart/field.js';
|
|
3
3
|
import { inBox } from '../spatial-scatter-chart/view.js';
|
|
4
4
|
const HEIGHT = 0.6;
|
|
@@ -156,13 +156,16 @@ export const paintOrder = (projection, bars) => {
|
|
|
156
156
|
return [...columns.values()].flatMap((column) => column.sort((one, two) => one.base - two.base));
|
|
157
157
|
};
|
|
158
158
|
const PLATE = 0.85;
|
|
159
|
+
const ownCells = (field) => field.cells
|
|
160
|
+
.slice(0, field.categories.length * Math.max(field.series.length, 1))
|
|
161
|
+
.map((cell, index) => ({ across: Math.floor(index / Math.max(field.series.length, 1)), cell }));
|
|
159
162
|
export const floorOf = (field, projection, layout = 'row') => {
|
|
160
163
|
const { place, spacing } = placesOf(field, projection, layout);
|
|
161
164
|
const floor = inBox(field.axes.y, 0) * field.axes.extent[1];
|
|
162
165
|
const half = (spacing * PLATE) / 2;
|
|
163
166
|
const seen = new Set();
|
|
164
|
-
return field.
|
|
165
|
-
const key = `${
|
|
167
|
+
return ownCells(field).flatMap(({ across, cell }) => {
|
|
168
|
+
const key = `${across} ${cell.lane}`;
|
|
166
169
|
if (seen.has(key)) {
|
|
167
170
|
return [];
|
|
168
171
|
}
|
|
@@ -175,7 +178,7 @@ export const floorOf = (field, projection, layout = 'row') => {
|
|
|
175
178
|
projection.at(x - half, y + half, floor),
|
|
176
179
|
];
|
|
177
180
|
const front = corners.reduce((low, one) => (one.y > low.y ? one : low));
|
|
178
|
-
return [{ across
|
|
181
|
+
return [{ across, corners, d: pathData(corners), front }];
|
|
179
182
|
});
|
|
180
183
|
};
|
|
181
184
|
const NAME_WIDE = 0.58;
|
|
@@ -188,9 +191,9 @@ export const namesOf = (field, plates, size) => {
|
|
|
188
191
|
}
|
|
189
192
|
}
|
|
190
193
|
const tones = new Map();
|
|
191
|
-
for (const cell of field
|
|
192
|
-
if (cell.tone && cell.value !== undefined && !tones.has(
|
|
193
|
-
tones.set(
|
|
194
|
+
for (const { across, cell } of ownCells(field)) {
|
|
195
|
+
if (cell.tone && cell.value !== undefined && !tones.has(across)) {
|
|
196
|
+
tones.set(across, cell.tone);
|
|
194
197
|
}
|
|
195
198
|
}
|
|
196
199
|
const all = field.categories.flatMap((text, across) => {
|
|
@@ -235,15 +238,69 @@ export const namesOf = (field, plates, size) => {
|
|
|
235
238
|
}
|
|
236
239
|
return [];
|
|
237
240
|
};
|
|
238
|
-
const
|
|
239
|
-
const
|
|
240
|
-
const
|
|
241
|
-
const
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
241
|
+
const cellKey = (category, series) => `${category}\u0001${series}`;
|
|
242
|
+
export const barKeys = (field) => {
|
|
243
|
+
const categories = keysOf(field.categories);
|
|
244
|
+
const series = keysOf(field.series);
|
|
245
|
+
return field.cells.map((cell) => cell.key ?? cellKey(categories[cell.across] ?? cell.label, series[cell.depth] ?? ''));
|
|
246
|
+
};
|
|
247
|
+
export const barItems = (field) => {
|
|
248
|
+
const keys = barKeys(field);
|
|
249
|
+
return field.cells.map((cell, index) => ({ key: keys[index], step: cell.across }));
|
|
250
|
+
};
|
|
251
|
+
const grownTo = (cell, share) => ({
|
|
252
|
+
from: cell.from * share,
|
|
253
|
+
value: cell.value === undefined ? undefined : cell.value * share,
|
|
254
|
+
});
|
|
255
|
+
export const barsBetween = (from, to, at) => {
|
|
256
|
+
const keys = barKeys(to);
|
|
257
|
+
const before = new Map();
|
|
258
|
+
if (from) {
|
|
259
|
+
const had = barKeys(from);
|
|
260
|
+
from.cells.forEach((cell, index) => {
|
|
261
|
+
before.set(had[index], cell);
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
const cells = to.cells.map((cell, index) => {
|
|
265
|
+
const key = keys[index];
|
|
266
|
+
const share = at.share(key);
|
|
267
|
+
const old = before.get(key);
|
|
268
|
+
if (!old || at.floor(key) || old.value === undefined) {
|
|
269
|
+
return { ...cell, key, ...grownTo(cell, share) };
|
|
270
|
+
}
|
|
271
|
+
if (cell.value === undefined) {
|
|
272
|
+
return share >= 1 ? { ...cell, key } : { ...old, key, ...grownTo(old, 1 - share) };
|
|
273
|
+
}
|
|
274
|
+
return {
|
|
275
|
+
...cell,
|
|
276
|
+
across: mix(old.across, cell.across, share),
|
|
277
|
+
from: mix(old.from, cell.from, share),
|
|
278
|
+
key,
|
|
279
|
+
lane: mix(old.lane, cell.lane, share),
|
|
280
|
+
value: mix(old.value, cell.value, share),
|
|
281
|
+
...(old.depth !== cell.depth && share < 1 ? { wore: { depth: old.depth, share } } : {}),
|
|
282
|
+
};
|
|
283
|
+
});
|
|
284
|
+
const kept = new Set(keys);
|
|
285
|
+
for (const [key, old] of before) {
|
|
286
|
+
const share = at.share(key);
|
|
287
|
+
if (!kept.has(key) && share < 1 && old.value !== undefined) {
|
|
288
|
+
cells.push({ ...old, key, ...grownTo(old, 1 - share) });
|
|
289
|
+
}
|
|
246
290
|
}
|
|
247
|
-
|
|
291
|
+
if (!from || at.axes >= 1) {
|
|
292
|
+
return { ...to, cells };
|
|
293
|
+
}
|
|
294
|
+
const [fx, fy, fz] = from.axes.extent;
|
|
295
|
+
const [tx, ty, tz] = to.axes.extent;
|
|
296
|
+
return {
|
|
297
|
+
...to,
|
|
298
|
+
axes: {
|
|
299
|
+
extent: [mix(fx, tx, at.axes), mix(fy, ty, at.axes), mix(fz, tz, at.axes)],
|
|
300
|
+
x: mixAxis(from.axes.x, to.axes.x, at.axes),
|
|
301
|
+
y: mixAxis(from.axes.y, to.axes.y, at.axes),
|
|
302
|
+
z: mixAxis(from.axes.z, to.axes.z, at.axes),
|
|
303
|
+
},
|
|
304
|
+
cells,
|
|
305
|
+
};
|
|
248
306
|
};
|
|
249
|
-
export const growTime = (categories) => GROW + stepOf(categories) * Math.max(0, categories - 1);
|
|
@@ -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 BarField } from '../bars.js';
|
|
@@ -73,7 +73,7 @@ declare const HelixHeadlessSpatialBarChart_base: typeof HelixElement & (new (...
|
|
|
73
73
|
* @slot error - Content shown after `error-text` while it is set and there are no readings, such as a button that tries again.
|
|
74
74
|
* @slot loading - Content shown while `loading` is set and there are no readings yet. Falls back to `loading-text`.
|
|
75
75
|
*
|
|
76
|
-
* @event {HelixPlotChangeEvent} helix-plot-change - The bars or the bar the keys rest on changed, which the renderer is told. It stays on the chart.
|
|
76
|
+
* @event {HelixPlotChangeEvent} helix-plot-change - The bars or the bar the keys rest on changed, or a frame of a move drew the bars on their way, which the renderer is told. It stays on the chart.
|
|
77
77
|
* @event {HelixPlotTurnEvent} helix-plot-turn - Shift with an arrow asked the view to turn, by a step across or up.
|
|
78
78
|
* @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.
|
|
79
79
|
* @event {HelixReadingPressEvent} helix-reading-press - A bar was clicked or pressed with Enter or Space, with the same detail as `helix-reading-change`.
|
|
@@ -118,6 +118,8 @@ declare const HelixHeadlessSpatialBarChart_base: typeof HelixElement & (new (...
|
|
|
118
118
|
* @csspart tooltip-value - A column's value inside the tooltip.
|
|
119
119
|
* @csspart value - The value of a bar whose cell names a tone, written above it in the chart's own drawing.
|
|
120
120
|
*
|
|
121
|
+
* @cssproperty --spatial-bar-chart-move-duration - How long the bars take to move to a new table's readings: a bar the table keeps rises or falls to its new value, a bar it adds grows from the floor, and a bar it drops shrinks to the floor. Unset, a new table is drawn at once. The growth under `grow` keeps its own timing.
|
|
122
|
+
* @cssproperty --spatial-bar-chart-move-easing - The curve the bars move to new readings along.
|
|
121
123
|
* @cssproperty --spatial-bar-chart-shade - How far a bar's face turns from the light, from 0 for its top. The component writes it on each face, and the stylesheet that shades the face reads it.
|
|
122
124
|
* @cssproperty --spatial-bar-chart-tone-accent - The color of a bar whose cell says `data-tone="accent"`.
|
|
123
125
|
* @cssproperty --spatial-bar-chart-tone-danger - The color of a bar whose cell says `data-tone="danger"`.
|
|
@@ -147,9 +149,10 @@ export declare class HelixHeadlessSpatialBarChart extends HelixHeadlessSpatialBa
|
|
|
147
149
|
*
|
|
148
150
|
* Under `prefers-reduced-motion`, or where the page has paused its motion
|
|
149
151
|
* through `pauseMotion` or `Motion Toggle`, the bars stand at their height
|
|
150
|
-
* from the start. A later table
|
|
151
|
-
*
|
|
152
|
-
*
|
|
152
|
+
* from the start. A later table grows the bars it adds, each from the
|
|
153
|
+
* floor, so a reading that arrives while the chart is in view arrives the
|
|
154
|
+
* same way. The bars it keeps move to their new values on
|
|
155
|
+
* `--spatial-bar-chart-move-duration`, and stand at once where it is unset.
|
|
153
156
|
*/
|
|
154
157
|
grow: boolean;
|
|
155
158
|
/**
|
|
@@ -249,25 +252,13 @@ export declare class HelixHeadlessSpatialBarChart extends HelixHeadlessSpatialBa
|
|
|
249
252
|
/** Measures the box the chart's own drawing fills. */
|
|
250
253
|
private sizes;
|
|
251
254
|
/**
|
|
252
|
-
*
|
|
253
|
-
*
|
|
254
|
-
*
|
|
255
|
+
* Moves the bars from one table to the next, and grows them in under
|
|
256
|
+
* `grow`, timed by `--spatial-bar-chart-move-duration` and
|
|
257
|
+
* `--spatial-bar-chart-move-easing`.
|
|
255
258
|
*/
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
* The bars a later table added, by category label, each growing from the
|
|
260
|
-
* floor: when it started, and its place among the bars that came with it, so
|
|
261
|
-
* several arriving together follow one another as the first table's do. A
|
|
262
|
-
* bar leaves the map once it stands.
|
|
263
|
-
*/
|
|
264
|
-
private readonly fresh;
|
|
265
|
-
/** The categories of the table drawn last, so a later table's new ones are known. */
|
|
266
|
-
private drawnLabels;
|
|
267
|
-
/** Watches for the chart to leave the view, after which `grow-again` has it grow in once more. */
|
|
268
|
-
private gone;
|
|
269
|
-
/** Watches for the chart to come into view, which starts the bars growing. */
|
|
270
|
-
private seen;
|
|
259
|
+
protected readonly motion: ReadingsMotionController<BarField>;
|
|
260
|
+
/** The bars drawn last, kept so a frame of their move can be told. */
|
|
261
|
+
private lastShown;
|
|
271
262
|
/** Carries a host `aria-labelledby` and `aria-describedby` to the plot. */
|
|
272
263
|
protected readonly aria: AriaForwardController;
|
|
273
264
|
/**
|
|
@@ -277,6 +268,13 @@ export declare class HelixHeadlessSpatialBarChart extends HelixHeadlessSpatialBa
|
|
|
277
268
|
get field(): BarField;
|
|
278
269
|
/** The field last read, and the rows, columns, and series it was read from. */
|
|
279
270
|
private memo;
|
|
271
|
+
/**
|
|
272
|
+
* The bars as drawn this frame, which a renderer draws: `field` at rest,
|
|
273
|
+
* and while the readings move, every cell between its last reading and
|
|
274
|
+
* its new one, in `field`'s order, then each cell the last table had and
|
|
275
|
+
* the new one does not, shrinking to the floor.
|
|
276
|
+
*/
|
|
277
|
+
get shown(): BarField;
|
|
280
278
|
/** The bar the keys or the pointer rest on, as its place in `field.cells`, or `-1`. */
|
|
281
279
|
get active(): number;
|
|
282
280
|
/** The number of places on the grid, which the keys walk. */
|
|
@@ -292,7 +290,7 @@ export declare class HelixHeadlessSpatialBarChart extends HelixHeadlessSpatialBa
|
|
|
292
290
|
* A touch keeps it until a tap lands elsewhere, and a mouse leaving a
|
|
293
291
|
* reading the keys moved to leaves it. Called by the connector.
|
|
294
292
|
*/
|
|
295
|
-
requestActive(
|
|
293
|
+
requestActive(at: number, kind?: 'mouse' | 'pen' | 'touch'): void;
|
|
296
294
|
/**
|
|
297
295
|
* Says where the renderer draws the reading, as fractions of the plot from
|
|
298
296
|
* its top left, or `undefined` while it draws none. The tooltip points
|
|
@@ -309,8 +307,6 @@ export declare class HelixHeadlessSpatialBarChart extends HelixHeadlessSpatialBa
|
|
|
309
307
|
* the server calls this one.
|
|
310
308
|
*/
|
|
311
309
|
protected willUpdate(changed: PropertyValues<this>): void;
|
|
312
|
-
/** Draws each frame until the bars a later table added stand. */
|
|
313
|
-
private followFresh;
|
|
314
310
|
disconnectedCallback(): void;
|
|
315
311
|
/** The element the size observer watches, so a drawing drawn again is watched again. */
|
|
316
312
|
private measured;
|
|
@@ -331,14 +327,6 @@ export declare class HelixHeadlessSpatialBarChart extends HelixHeadlessSpatialBa
|
|
|
331
327
|
* the row is too long for the plot, its bars narrow until it fits.
|
|
332
328
|
*/
|
|
333
329
|
private sized;
|
|
334
|
-
/** Starts the bars growing once the chart comes into view, and draws each frame until they stand. */
|
|
335
|
-
private watchGrowth;
|
|
336
|
-
/**
|
|
337
|
-
* Under `grow-again`, waits for the chart to leave the view, then puts the
|
|
338
|
-
* bars back at the floor and waits to be seen, so growing again starts from
|
|
339
|
-
* the same place the first time did.
|
|
340
|
-
*/
|
|
341
|
-
private watchExit;
|
|
342
330
|
connectedCallback(): void;
|
|
343
331
|
protected updated(changed: PropertyValues): void;
|
|
344
332
|
/**
|