@design.estate/dees-catalog 22.4.1 → 22.5.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 (60) hide show
  1. package/dist_bundle/bundle.js +370 -174
  2. package/dist_bundle/bundle.js.map +1 -1
  3. package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{chunk-RITCTBBY.js → chunk-K2WA4NFI.js} +2 -2
  4. package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{chunk-IGD4DLG4.js → chunk-OFVHJYUS.js} +3 -3
  5. package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{chunk-MK42UYWT.js → chunk-TCT6JQUS.js} +5 -2
  6. package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{chunk-MK42UYWT.js.map → chunk-TCT6JQUS.js.map} +1 -1
  7. package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{de-TN6FRTSU.js → de-VUUYAWTZ.js} +5 -2
  8. package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/de-VUUYAWTZ.js.map +1 -0
  9. package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{dees-modal-PLLCPO5V.js → dees-modal-KNFCFUX6.js} +3 -3
  10. package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{dees-workspace-terminal-7N6EXGH6.js → dees-workspace-terminal-GCBL7RVQ.js} +4 -4
  11. package/dist_ts_web/00_commitinfo_data.js +1 -1
  12. package/dist_ts_web/demos/appui.state.d.ts +7 -0
  13. package/dist_ts_web/demos/charts.d.ts +14 -0
  14. package/dist_ts_web/demos/charts.js +62 -20
  15. package/dist_ts_web/elements/00firstload.d.ts +24 -0
  16. package/dist_ts_web/elements/00firstload.js +52 -0
  17. package/dist_ts_web/elements/00group-chart/dees-chart-echarts-base.d.ts +29 -1
  18. package/dist_ts_web/elements/00group-chart/dees-chart-echarts-base.js +64 -15
  19. package/dist_ts_web/elements/00group-chart/dees-chart-frame.d.ts +15 -0
  20. package/dist_ts_web/elements/00group-chart/dees-chart-frame.js +20 -2
  21. package/dist_ts_web/elements/00group-chart/dees-chart-gauge/component.d.ts +2 -0
  22. package/dist_ts_web/elements/00group-chart/dees-chart-gauge/component.js +3 -1
  23. package/dist_ts_web/elements/00group-chart/dees-chart-line/component.d.ts +33 -0
  24. package/dist_ts_web/elements/00group-chart/dees-chart-line/component.js +104 -8
  25. package/dist_ts_web/elements/00group-feedback/dees-progressbar/dees-progressbar.js +5 -2
  26. package/dist_ts_web/elements/00group-harness/dees-harness-chat/dees-harness-chat.d.ts +4 -0
  27. package/dist_ts_web/elements/00group-harness/dees-harness-chat/dees-harness-chat.js +22 -2
  28. package/dist_ts_web/elements/00group-harness/dees-harness-session-sidebar/dees-harness-session-sidebar.d.ts +16 -1
  29. package/dist_ts_web/elements/00group-harness/dees-harness-session-sidebar/dees-harness-session-sidebar.demo.js +9 -2
  30. package/dist_ts_web/elements/00group-harness/dees-harness-session-sidebar/dees-harness-session-sidebar.js +55 -6
  31. package/dist_ts_web/elements/00group-kanban/dees-kanban/dees-kanban.js +3 -3
  32. package/dist_ts_web/elements/00group-kanban/dees-kanban-activity/dees-kanban-activity.js +3 -3
  33. package/dist_ts_web/i18n/de.d.ts +12 -0
  34. package/dist_ts_web/i18n/de.js +4 -1
  35. package/dist_ts_web/i18n/messages.d.ts +12 -0
  36. package/dist_ts_web/i18n/messages.js +4 -1
  37. package/package.json +2 -2
  38. package/readme.md +36 -2
  39. package/ts_web/00_commitinfo_data.ts +1 -1
  40. package/ts_web/demos/charts.ts +48 -18
  41. package/ts_web/elements/{00group-kanban/kanban.firstload.ts → 00firstload.ts} +8 -7
  42. package/ts_web/elements/00group-chart/dees-chart-echarts-base.ts +55 -4
  43. package/ts_web/elements/00group-chart/dees-chart-frame.ts +31 -1
  44. package/ts_web/elements/00group-chart/dees-chart-gauge/component.ts +2 -0
  45. package/ts_web/elements/00group-chart/dees-chart-line/component.ts +100 -7
  46. package/ts_web/elements/00group-feedback/dees-progressbar/dees-progressbar.ts +4 -1
  47. package/ts_web/elements/00group-harness/dees-harness-chat/dees-harness-chat.ts +10 -0
  48. package/ts_web/elements/00group-harness/dees-harness-session-sidebar/dees-harness-session-sidebar.demo.ts +9 -1
  49. package/ts_web/elements/00group-harness/dees-harness-session-sidebar/dees-harness-session-sidebar.ts +43 -4
  50. package/ts_web/elements/00group-kanban/dees-kanban/dees-kanban.ts +2 -2
  51. package/ts_web/elements/00group-kanban/dees-kanban-activity/dees-kanban-activity.ts +2 -2
  52. package/ts_web/i18n/de.ts +3 -0
  53. package/ts_web/i18n/messages.ts +3 -0
  54. package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/de-TN6FRTSU.js.map +0 -1
  55. package/dist_ts_web/elements/00group-kanban/kanban.firstload.d.ts +0 -23
  56. package/dist_ts_web/elements/00group-kanban/kanban.firstload.js +0 -51
  57. /package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{chunk-RITCTBBY.js.map → chunk-K2WA4NFI.js.map} +0 -0
  58. /package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{chunk-IGD4DLG4.js.map → chunk-OFVHJYUS.js.map} +0 -0
  59. /package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{dees-modal-PLLCPO5V.js.map → dees-modal-KNFCFUX6.js.map} +0 -0
  60. /package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{dees-workspace-terminal-7N6EXGH6.js.map → dees-workspace-terminal-GCBL7RVQ.js.map} +0 -0
package/readme.md CHANGED
@@ -4336,6 +4336,22 @@ html`<dees-chart-line label="Bank balances" meta="as each bank statement states
4336
4336
  </dees-chart-line>`;
4337
4337
  ```
4338
4338
 
4339
+ While the host loads a chart's data it sets `loading` (reflected) on any ECharts chart — bar,
4340
+ donut, gauge, line or radar. The first load, while the chart has no data on show, follows the
4341
+ catalog's first-load standard: the plot is covered at once, a placeholder takes its place once
4342
+ the load has run 200 ms, so a quick load never flashes it, and pulses on
4343
+ `--dees-loading-pulse-duration` and `--dees-loading-pulse-opacity`; it holds still under
4344
+ `prefers-reduced-motion: reduce`. After `stillLoadingAfter` (a static, 10 s) the placeholder holds
4345
+ still and the chart says "Still loading chart…" over it. The tile is `aria-busy` while `loading`
4346
+ holds, a visually hidden status says "Loading chart…", and the placeholder is hidden from
4347
+ assistive technology. Data the host sets ends the first load at once; data already on show stays
4348
+ while a refresh loads. A gauge always holds a value, so its first load ends when `loading` does.
4349
+
4350
+ ```typescript
4351
+ html`<dees-chart-bar label="Requests" ?loading=${!report} .categories=${report?.days ?? []}
4352
+ .series=${report?.series ?? []}></dees-chart-bar>`;
4353
+ ```
4354
+
4339
4355
  A series or a slice says what it stands for with `tone` — `'neutral'`, `'accent'`,
4340
4356
  `'success'`, `'warning'` or `'danger'` — and is drawn in the theme's colour for it, in the
4341
4357
  bright and the dark theme alike, so a host never passes a hex for "paid" or "overdue". An
@@ -4526,6 +4542,24 @@ readable, in either theme; a series whose `color` is not a hex colour is tinted
4526
4542
  `showLatestValue` puts each series' latest stated value, formatted by `valueFormatter`, beside
4527
4543
  its name in the legend.
4528
4544
 
4545
+ `stacked` (reflected) stacks the series, the first at the bottom: each is drawn on top of the
4546
+ ones before it, so the topmost line is their total at each moment, a value above zero on those
4547
+ above zero beneath it and a value below zero under those below zero. Series stated on different
4548
+ moments stack all the same: where a series states no value at a moment another one states, it
4549
+ adds what its own drawing reads there — under `step` its value before, under `line` its line
4550
+ between the two values around the moment — and nothing under `points`, before its first value,
4551
+ after its last or beside a missing one. With `fillArea`, each series tints the band between its
4552
+ line and the one beneath it evenly in its colour. The value axis includes zero. A series switched
4553
+ off in the legend leaves the stack, and the others close up. Hovering, the legend and the text
4554
+ summary keep each series' own stated values, and `axisValueFormatter` words the stacked axis.
4555
+
4556
+ ```typescript
4557
+ html`<dees-chart-line label="Cloud spend by service" meta="per week, stacked into the total"
4558
+ presentation="line" stacked fillArea .series=${spendByService}
4559
+ .valueFormatter=${(value: number) => `${value.toFixed(2)} €`}
4560
+ ></dees-chart-line>`;
4561
+ ```
4562
+
4529
4563
  `showMarkers` (default `true`) marks every value with a dot. Turn it off for long series, such as
4530
4564
  a year of daily balances, where a dot on every value crowds the line: `line` and `step` then draw
4531
4565
  the course alone, and while the pointer is over the plot, the moment nearest it is marked and the
@@ -5948,7 +5982,7 @@ chat.refreshMessages();
5948
5982
  chat.refreshMessages([]);
5949
5983
  ```
5950
5984
 
5951
- Key props: `messages`, `permissions`, `questions`, `status`, `transcriptKey`, `hasEarlierMessages`/`loadingEarlier`, `usage`, `todos`/`todosAuthoritative`/`showTodosPanel`, `sessionMetrics`, `scratchpad`/`scratchpadBusy`/`scratchpadError`, `attachedResources`, `workers`/`selectedWorkerId`, `sessionIntelligenceEnabled`/`intelligenceExchanges`/`intelligenceBusy`/`intelligenceError`/`intelligenceAvailabilityStatus`/`intelligenceUnavailableReason`/`intelligenceAvailabilityAction`/`intelligenceHeading`, `showSessionSidebar`, `heading`, `subheading`, `toolbarActions`, `showToolbar`, `busy`, `busyDeliveryModes`, `queuedCount`, `disabled`, `inputLocked`, `abortEnabled`, `abortDisabledReason`, `commands`, `starterPrompts`, `account`/`accountOptions`/`accountNote`, `model`/`modelOptions`, `reasoningEffort`/`effortOptions`, `mode`/`modeOptions`, `menuActions`, `markdownWhileStreaming`, `toolRegistry`. `toolbarActions` accepts `IHarnessChatToolbarAction[]`; each action has `id`, human-readable `label`, `iconName`, `action`, and optional `tooltip`/`disabled`, and renders immediately before the session-details toggle. `disabled: true` makes only that toolbar action inert and prevents its callback without changing the chat-level `disabled` state. `markdownWhileStreaming` defaults to `true`; setting it to `false` keeps active outer and nested subtask markdown as plain text, then performs the final markdown parse when `message-end` arrives. `commands` is forwarded unchanged to the controlled composer. `starterPrompts` (`IHarnessStarterPrompt[]`, each `{ label, prompt? }`) shows as buttons under the empty transcript's text while the composer accepts input; choosing one puts its `prompt` (else its `label`) into the composer, focused and unsent, and emits `harness-input` as typing would. Account options use human-readable `label` values and opaque stable `value` identifiers. The status line renders inside the transcript column (it never pushes between the session panel and the composer), and both the toolbar and the docked composer cast a subtle shadow over the scrolling messages.
5985
+ Key props: `messages`, `permissions`, `questions`, `status`, `transcriptKey`, `hasEarlierMessages`/`loadingEarlier`, `usage`, `todos`/`todosAuthoritative`/`showTodosPanel`, `sessionMetrics`, `scratchpad`/`scratchpadBusy`/`scratchpadError`, `attachedResources`, `workers`/`selectedWorkerId`/`workersHeading`/`workerQuestionCounts`, `sessionIntelligenceEnabled`/`intelligenceExchanges`/`intelligenceBusy`/`intelligenceError`/`intelligenceAvailabilityStatus`/`intelligenceUnavailableReason`/`intelligenceAvailabilityAction`/`intelligenceHeading`, `showSessionSidebar`, `heading`, `subheading`, `toolbarActions`, `showToolbar`, `busy`, `busyDeliveryModes`, `queuedCount`, `disabled`, `inputLocked`, `abortEnabled`, `abortDisabledReason`, `commands`, `starterPrompts`, `account`/`accountOptions`/`accountNote`, `model`/`modelOptions`, `reasoningEffort`/`effortOptions`, `mode`/`modeOptions`, `menuActions`, `markdownWhileStreaming`, `toolRegistry`. `toolbarActions` accepts `IHarnessChatToolbarAction[]`; each action has `id`, human-readable `label`, `iconName`, `action`, and optional `tooltip`/`disabled`, and renders immediately before the session-details toggle. `disabled: true` makes only that toolbar action inert and prevents its callback without changing the chat-level `disabled` state. `markdownWhileStreaming` defaults to `true`; setting it to `false` keeps active outer and nested subtask markdown as plain text, then performs the final markdown parse when `message-end` arrives. `commands` is forwarded unchanged to the controlled composer. `starterPrompts` (`IHarnessStarterPrompt[]`, each `{ label, prompt? }`) shows as buttons under the empty transcript's text while the composer accepts input; choosing one puts its `prompt` (else its `label`) into the composer, focused and unsent, and emits `harness-input` as typing would. Account options use human-readable `label` values and opaque stable `value` identifiers. The status line renders inside the transcript column (it never pushes between the session panel and the composer), and both the toolbar and the docked composer cast a subtle shadow over the scrolling messages.
5952
5986
 
5953
5987
  Light-DOM content assigned to `slot="composer-status"` renders between the transcript and composer, outside the transcript scroller. `inputLocked` keeps the controlled draft readable, focusable, and copyable while blocking every mutation control and canceling queued or in-flight attachment ingestion. It does not disable Stop or the More options menu of `menuActions`. While busy, Stop remains visible; `abortEnabled=${false}` disables it, suppresses `harness-abort`, and exposes `abortDisabledReason` as its explanation.
5954
5988
 
@@ -6287,7 +6321,7 @@ Direct sidebar hosts can set `intelligenceAvailabilityStatus`, `intelligenceUnav
6287
6321
 
6288
6322
  Set `attachedResources` (`IHarnessResourceMeta[]`) to show the terminals, browsers and other host resources attached to the session, between Session Scratchpad and Session Intelligence. `undefined`, the default, leaves the section out; an empty array shows it with "No resources attached." Each row shows the resource's icon, title and state over its kind and preview, and is one button that emits `harness-attached-resource-open` with `{ resource }` (`IHarnessAttachedResourceOpenDetail`), bubbling and composed; the host opens the resource. `DeesHarnessChat` forwards `attachedResources`, and a defined value keeps its session panel available.
6289
6323
 
6290
- Set `workers` (`IHarnessSessionMeta[]`) to list the sessions this session runs, such as a driver's workers, right after Tasks. `undefined`, the default, leaves the section out; an empty array shows it with "No workers." The panel opens on Workers when there are workers and no tasks. Each row shows the worker's icon (else its harness's, else a bot), title and `statusLabel`, coloured by `state`, over its harness name and preview, and is one button that emits `harness-worker-open` with `{ worker }` (`IHarnessWorkerOpenDetail`), bubbling and composed; the host opens the worker. `selectedWorkerId` marks the row of the worker the host shows with `aria-current="true"`. `DeesHarnessChat` forwards `workers` and `selectedWorkerId`, and a defined `workers` keeps its session panel available.
6324
+ Set `workers` (`IHarnessSessionMeta[]`) to list the sessions this session runs, such as a driver's workers, right after Tasks. `undefined`, the default, leaves the section out; an empty array shows it with "No workers." The panel opens on Workers when there are workers and no tasks. Each row shows the worker's icon (else its harness's, else a bot), title and `statusLabel`, coloured by `state`, over its harness name, its `projectLabel` and its preview, and is one button that emits `harness-worker-open` with `{ worker }` (`IHarnessWorkerOpenDetail`), bubbling and composed; the host opens the worker. `selectedWorkerId` marks the row of the worker the host shows with `aria-current="true"`. `workersHeading` (reflected) names the section in the host's words, such as "Direct reports"; empty, the default, it keeps the catalog's "Workers". `workerQuestionCounts` (`Record<string, number>`, by worker id) counts the questions each worker has open for its owner: a worker with one or more shows the count as a compact warning [`dees-badge`](#deesbadge) after its title, whose title and the row's accessible name say "2 open questions"; a missing, zero or invalid count shows none. `DeesHarnessChat` forwards `workers`, `selectedWorkerId`, `workersHeading` and `workerQuestionCounts`, and a defined `workers` keeps its session panel available.
6291
6325
 
6292
6326
  `openSection(section)` expands and focuses an available section and returns false when that section has no current content. Its argument is the exported `THarnessSessionSidebarSection` union: `'tasks' | 'workers' | 'activity' | 'metrics' | 'scratchpad' | 'resources' | 'intelligence'`.
6293
6327
 
@@ -3,6 +3,6 @@
3
3
  */
4
4
  export const commitinfo = {
5
5
  name: '@design.estate/dees-catalog',
6
- version: '22.4.1',
6
+ version: '22.5.1',
7
7
  description: 'A comprehensive library that provides dynamic web components for building sophisticated and modern web applications using JavaScript and TypeScript.'
8
8
  }
@@ -1,4 +1,4 @@
1
- import { DeesElement, customElement, html, css, property, state, cssManager, provideI18n } from '@design.estate/dees-element';
1
+ import { DeesElement, customElement, html, css, property, state, cssManager, provideI18n, directives } from '@design.estate/dees-element';
2
2
  import * as plugins from '../elements/00plugins.js';
3
3
  import { demoPage } from './templates.js';
4
4
  import { operationsDemoStyles } from './operations.js';
@@ -59,6 +59,18 @@ export const chartSamples = (step = 0, sampledAt = Date.now()) => {
59
59
  { time: '2026-08-31', value: 8100.15 }, { time: '2026-09-30', value: 5600.4 + offset * 10 },
60
60
  ] },
61
61
  ],
62
+ // Cloud spend by service, stacked into the week's total: compute every Monday, storage as its
63
+ // invoices state it, and a network service booked from August on.
64
+ cloudSpend: [
65
+ { name: 'Compute', data: [1840, 1920, 2010, 1980, 2240, 2310, 2190, 2460, 2520 + offset * 10, 2380, 2610, 2700]
66
+ .map((value, index) => ({ time: new Date(Date.UTC(2026, 6, 6 + index * 7)).toISOString().slice(0, 10), value })) },
67
+ { name: 'Storage', data: [
68
+ { time: '2026-07-06', value: 640 }, { time: '2026-07-24', value: 700 }, { time: '2026-08-14', value: 760 },
69
+ { time: '2026-09-04', value: 820 + offset * 5 }, { time: '2026-09-21', value: 880 },
70
+ ] },
71
+ { name: 'Network', data: [420, 460, 510, 480, 530, 590, 620 + offset * 5, 640]
72
+ .map((value, index) => ({ time: new Date(Date.UTC(2026, 7, 3 + index * 7)).toISOString().slice(0, 10), value })) },
73
+ ],
62
74
  // A dollar account stated on two days in a row, and a year of month-end statements.
63
75
  dayApart: [{ name: 'Dollar account', data: [{ time: '2026-09-29', value: 3120 + offset * 10 }, { time: '2026-09-30', value: 2980 }] }],
64
76
  monthEnds: [{ name: 'Current account', data: [8200, 9400, 7600, 10100, 11800, 9900, 12400, 13100, 11200, 14300, 12900, 15234 + offset * 10]
@@ -78,7 +90,7 @@ const descriptions = {
78
90
  bar: ['Compare traffic', 'Compare requests and cache hits across the week. Switch orientation or stack related series. Below, each month has two columns that reach both ways from zero: money in above, money out below, and the operating column marks its surplus or deficit at its end. Its header states what the chart covers beside the title, and a line of the host\'s own under the plot, at the header\'s inset, names what the chart leaves out: the legend stays the tile\'s last row.'],
79
91
  donut: ['Traffic distribution', 'Understand the share of requests from each region. Labels and legends remain optional. Below, three months of spending: each donut keeps one size whatever its legend holds, and the host\'s own list draws its dots in the charts\' palette.'],
80
92
  gauge: ['Capacity', 'See used capacity against a defined range and warning thresholds.'],
81
- line: ['Stated balances', 'Balances where the statements state them, on an axis proportional to time. A quarterly statement sits three months after the one before. With lines, an area can tint each course down to zero, and the legend can state each account\'s latest balance. The time axis labels whole days, months or years that differ and keep apart at any width: two statements a day apart are labelled by their days, and a year of month ends month by month where there is room. The value axis of the balances states whole euros, while hovering, the legend and the text summary keep the cents. A year of daily balances crowds its line with a dot a day: with markers hidden, lines and steps draw the course alone, hovering marks and reads out the day nearest the pointer, and a value with no neighbour, such as the single savings statement, keeps its dot. The balances state their terms beside the title, with a notice of the host\'s own over the plot and the balances the course does not end on under it, at the header\'s inset: the chart grows with these rows, its plot keeping 240 px, and the legend stays the tile\'s last row.'],
93
+ line: ['Stated balances', 'Balances where the statements state them, on an axis proportional to time. A quarterly statement sits three months after the one before. With lines, an area can tint each course down to zero, and the legend can state each account\'s latest balance. The time axis labels whole days, months or years that differ and keep apart at any width: two statements a day apart are labelled by their days, and a year of month ends month by month where there is room. The value axis of the balances states whole euros, while hovering, the legend and the text summary keep the cents. A year of daily balances crowds its line with a dot a day: with markers hidden, lines and steps draw the course alone, hovering marks and reads out the day nearest the pointer, and a value with no neighbour, such as the single savings statement, keeps its dot. Stacked, each account sits on the ones before it, so the topmost line is the total held, and the cloud spend below stacks services stated on different days into the week\'s total: each tints its own band, a service switched off in the legend leaves the stack, and hovering reads each service\'s own amount. The balances state their terms beside the title, with a notice of the host\'s own over the plot and the balances the course does not end on under it, at the header\'s inset: the chart grows with these rows, its plot keeping 240 px, and the legend stays the tile\'s last row.'],
82
94
  radar: ['Service profile', 'Compare the current service with its targets across five dimensions.'],
83
95
  };
84
96
 
@@ -92,6 +104,9 @@ export class DeesDemoChartWorkspace extends DeesElement {
92
104
  @state() private accessor filled = false;
93
105
  @state() private accessor latest = false;
94
106
  @state() private accessor dotless = false;
107
+ @state() private accessor stackedLines = false;
108
+ /** The host's load: none, a first one with nothing to show yet, or a refresh of what is shown. */
109
+ @state() private accessor load: 'none' | 'first' | 'refresh' = 'none';
95
110
  @state() private accessor language = 'en';
96
111
  private sampledAt = Date.now();
97
112
  /** The language this demo's charts speak, apart from the page's: their own words and the host's numbers follow it. */
@@ -119,6 +134,19 @@ export class DeesDemoChartWorkspace extends DeesElement {
119
134
  .narrow { width: 420px; }
120
135
  `];
121
136
 
137
+ /** A refresh loads over what the charts show: from a first load, the charts show their data first. */
138
+ private async toggleRefresh() {
139
+ if (this.load === 'first') {
140
+ this.load = 'none';
141
+ // the charts render their data once, so the refresh keeps it on show
142
+ await new Promise((resolve) => requestAnimationFrame(resolve));
143
+ }
144
+ this.load = this.load === 'refresh' ? 'none' : 'refresh';
145
+ }
146
+
147
+ /** Nothing to show: an empty period, or a first load still on its way. */
148
+ private get noData() { return this.empty || this.load === 'first'; }
149
+
122
150
  constructor() {
123
151
  super();
124
152
  // lives with this element: the charts in its shadow root speak the demo's language
@@ -149,7 +177,7 @@ export class DeesDemoChartWorkspace extends DeesElement {
149
177
  const palette = getChartPalette(this.goBright);
150
178
  const totals = new Map<string, number>();
151
179
  for (const { data: slices } of data.spending) for (const slice of slices) totals.set(slice.name, (totals.get(slice.name) ?? 0) + slice.value);
152
- return html`<div class="donuts" role="group" aria-label="Spending by month">${data.spending.map(({ month: moment, data: slices }) => html`<dees-chart-donut label=${month.format(moment)} .data=${this.empty ? [] : slices} .showLabels=${!this.alternate} .showLegend=${!this.secondary} .valueFormatter=${wholeEuro}></dees-chart-donut>`)}</div>
180
+ return html`<div class="donuts" role="group" aria-label="Spending by month">${data.spending.map(({ month: moment, data: slices }) => html`<dees-chart-donut .loading=${this.load !== 'none'} label=${month.format(moment)} .data=${this.noData ? [] : slices} .showLabels=${!this.alternate} .showLegend=${!this.secondary} .valueFormatter=${wholeEuro}></dees-chart-donut>`)}</div>
153
181
  <ul class="key" aria-label="Spending over the quarter">${[...totals].map(([name, total], index) => html`<li><span class="dot" style="background: ${palette[index % palette.length]}"></span>${name} <strong>${wholeEuro(total)}</strong></li>`)}</ul>`;
154
182
  }
155
183
 
@@ -159,7 +187,7 @@ export class DeesDemoChartWorkspace extends DeesElement {
159
187
  const toggle = (name: string, active: boolean, action: () => void) => html`<button type="button" aria-pressed=${active} @click=${action}>${name}</button>`;
160
188
  const presentation = this.alternate ? 'step' : this.secondary ? 'line' : 'points';
161
189
  return html`<div class="toolbar"><p class="caption">API gateway · sample ${this.sample + 1}</p>
162
- <div class="dees-demo-row"><dees-button type="ghost" text="Reset chart" @clicked=${() => { this.sample = 0; this.empty = false; this.alternate = false; this.secondary = false; this.filled = false; this.latest = false; this.dotless = false; }}></dees-button>
190
+ <div class="dees-demo-row"><dees-button type="ghost" text="Reset chart" @clicked=${() => { this.sample = 0; this.empty = false; this.alternate = false; this.secondary = false; this.filled = false; this.latest = false; this.dotless = false; this.stackedLines = false; this.load = 'none'; }}></dees-button>
163
191
  <dees-button type="outline" text="Next sample" icon="lucide:RefreshCw" @clicked=${() => { this.sample++; this.empty = false; }}></dees-button></div></div>
164
192
  <div class="options" role="group" aria-label="Chart options">
165
193
  ${this.kind !== 'gauge' ? toggle('Empty period', this.empty, () => { this.empty = !this.empty; }) : ''}
@@ -167,35 +195,37 @@ export class DeesDemoChartWorkspace extends DeesElement {
167
195
  ${this.kind === 'donut' ? html`${toggle('Hide labels', this.alternate, () => { this.alternate = !this.alternate; })}${toggle('Hide legend', this.secondary, () => { this.secondary = !this.secondary; })}` : ''}
168
196
  ${this.kind === 'gauge' ? toggle('Show scale ticks', this.alternate, () => { this.alternate = !this.alternate; }) : ''}
169
197
  ${this.kind === 'radar' ? toggle('Outline only', this.alternate, () => { this.alternate = !this.alternate; }) : ''}
170
- ${this.kind === 'line' ? html`${toggle('Steps', this.alternate, () => { this.alternate = !this.alternate; this.secondary = false; })}${toggle('Lines', this.secondary, () => { this.secondary = !this.secondary; this.alternate = false; })}${toggle('Area', this.filled, () => { this.filled = !this.filled; if (this.filled && !this.alternate) this.secondary = true; })}${toggle('Hide markers', this.dotless, () => { this.dotless = !this.dotless; if (this.dotless && !this.alternate) this.secondary = true; })}${toggle('Latest values', this.latest, () => { this.latest = !this.latest; })}` : ''}
198
+ ${this.kind === 'line' ? html`${toggle('Steps', this.alternate, () => { this.alternate = !this.alternate; this.secondary = false; })}${toggle('Lines', this.secondary, () => { this.secondary = !this.secondary; this.alternate = false; })}${toggle('Area', this.filled, () => { this.filled = !this.filled; if (this.filled && !this.alternate) this.secondary = true; })}${toggle('Hide markers', this.dotless, () => { this.dotless = !this.dotless; if (this.dotless && !this.alternate) this.secondary = true; })}${toggle('Latest values', this.latest, () => { this.latest = !this.latest; })}${toggle('Stack series', this.stackedLines, () => { this.stackedLines = !this.stackedLines; })}` : ''}
199
+ ${this.kind !== 'area' ? html`${toggle('First load', this.load === 'first', () => { this.load = this.load === 'first' ? 'none' : 'first'; })}${toggle('Loading a refresh', this.load === 'refresh', () => { void this.toggleRefresh(); })}` : ''}
171
200
  </div>
172
201
  <div class="options" role="group" aria-label="Language of the charts">${languages.map(({ key, label }) => toggle(label, this.language === key, () => { void this.setLanguage(key); }))}</div>
173
- ${this.kind === 'bar' ? html`<dees-chart-bar label="Requests and cache hits" .categories=${data.categories} .series=${this.empty ? [] : data.series} .horizontal=${this.alternate} .stacked=${this.secondary} .valueFormatter=${(value: number) => `${Math.round(value)}k`}></dees-chart-bar>
174
- <dees-chart-bar label="Month by month, as booked" meta="Fiscal year 2026 to date · net of VAT" .categories=${data.bookings.categories} .series=${this.empty ? [] : data.bookings.series} .stacks=${data.bookings.stacks} .nets=${data.bookings.nets} .horizontal=${this.alternate} .valueFormatter=${this.euro(2)} .netLabelFormatter=${this.compactEuro()}>
202
+ ${directives.keyed(this.load === 'first', html`${this.kind === 'bar' ? html`<dees-chart-bar .loading=${this.load !== 'none'} label="Requests and cache hits" .categories=${data.categories} .series=${this.noData ? [] : data.series} .horizontal=${this.alternate} .stacked=${this.secondary} .valueFormatter=${(value: number) => `${Math.round(value)}k`}></dees-chart-bar>
203
+ <dees-chart-bar .loading=${this.load !== 'none'} label="Month by month, as booked" meta="Fiscal year 2026 to date · net of VAT" .categories=${data.bookings.categories} .series=${this.noData ? [] : data.bookings.series} .stacks=${data.bookings.stacks} .nets=${data.bookings.nets} .horizontal=${this.alternate} .valueFormatter=${this.euro(2)} .netLabelFormatter=${this.compactEuro()}>
175
204
  <p slot="below" class="note">Left out: 0480 Office equipment and 1800 Private withdrawals, which are none of these parts.</p>
176
205
  </dees-chart-bar>` : ''}
177
- ${this.kind === 'area' ? html`<dees-chart-area label="Requests per minute" .series=${this.empty ? [] : data.timeline} .yAxisFormatter=${(value: number) => `${Math.round(value)}k`} .legendStats=${['latest', 'min', 'max']} .chartLines=${[]} .rangeSelectionEnabled=${true}></dees-chart-area>
178
- <dees-chart-area class="withRows" label="Network throughput" meta="edge-1 · per minute" .series=${this.empty ? [] : data.throughput} .yAxisFormatter=${(value: number) => `${value} Mbit/s`} .legendStats=${['latest', 'max']}>
206
+ ${this.kind === 'area' ? html`<dees-chart-area label="Requests per minute" .series=${this.noData ? [] : data.timeline} .yAxisFormatter=${(value: number) => `${Math.round(value)}k`} .legendStats=${['latest', 'min', 'max']} .chartLines=${[]} .rangeSelectionEnabled=${true}></dees-chart-area>
207
+ <dees-chart-area class="withRows" label="Network throughput" meta="edge-1 · per minute" .series=${this.noData ? [] : data.throughput} .yAxisFormatter=${(value: number) => `${value} Mbit/s`} .legendStats=${['latest', 'max']}>
179
208
  <p slot="below" class="note">Outbound leaves out the nightly backup to the offsite store, which runs on a link of its own.</p>
180
209
  </dees-chart-area>` : ''}
181
- ${this.kind === 'donut' ? html`<dees-chart-donut label="Requests by region" .data=${this.empty ? [] : data.regions} .showLabels=${!this.alternate} .showLegend=${!this.secondary} .valueFormatter=${(value: number) => `${Math.round(value)}k`}></dees-chart-donut>
210
+ ${this.kind === 'donut' ? html`<dees-chart-donut .loading=${this.load !== 'none'} label="Requests by region" .data=${this.noData ? [] : data.regions} .showLabels=${!this.alternate} .showLegend=${!this.secondary} .valueFormatter=${(value: number) => `${Math.round(value)}k`}></dees-chart-donut>
182
211
  ${this.renderSpending(data)}` : ''}
183
- ${this.kind === 'gauge' ? html`<dees-chart-gauge label="Queue capacity" .value=${data.capacity} .showTicks=${this.alternate} .thresholds=${[{value:60,tone:'success'},{value:80,tone:'warning'},{value:100,tone:'danger'}]}></dees-chart-gauge>` : ''}
184
- ${this.kind === 'line' ? html`<dees-chart-line class="withRows" label="Account balances" meta="as each bank statement states them" .series=${this.empty ? [] : data.statements} .presentation=${presentation} .fillArea=${this.filled} .showMarkers=${!this.dotless} .showLatestValue=${this.latest} .valueFormatter=${this.euro(2)} .axisValueFormatter=${wholeEuro}>
212
+ ${this.kind === 'gauge' ? html`<dees-chart-gauge .loading=${this.load !== 'none'} label="Queue capacity" .value=${data.capacity} .showTicks=${this.alternate} .thresholds=${[{value:60,tone:'success'},{value:80,tone:'warning'},{value:100,tone:'danger'}]}></dees-chart-gauge>` : ''}
213
+ ${this.kind === 'line' ? html`<dees-chart-line .loading=${this.load !== 'none'} class="withRows" label="Account balances" meta="as each bank statement states them" .series=${this.noData ? [] : data.statements} .presentation=${presentation} .fillArea=${this.filled} .showMarkers=${!this.dotless} .showLatestValue=${this.latest} .valueFormatter=${this.euro(2)} .stacked=${this.stackedLines} .axisValueFormatter=${wholeEuro}>
185
214
  <dees-hint slot="above" type="warning" text="Two statements of the current account for 30 September 2026 state different balances: 2,246.86 € and 2,264.86 €."></dees-hint>
186
215
  <ul slot="below" class="rowList">
187
216
  <li>Savings: 6,000.00 € on 31 July 2026, its latest statement</li>
188
217
  <li>Credit card: no statement states a balance</li>
189
218
  </ul>
190
219
  </dees-chart-line>
191
- <dees-chart-line label="Stated a day apart" .series=${this.empty ? [] : data.dayApart} .presentation=${presentation} .fillArea=${this.filled} .showMarkers=${!this.dotless} .showLatestValue=${this.latest} .valueFormatter=${(value: number) => `$${this.i18n.format.number(value, 'integer')}`}></dees-chart-line>
192
- <dees-chart-line label="A year of daily balances" .series=${this.empty ? [] : data.daily} .presentation=${presentation} .fillArea=${this.filled} .showMarkers=${!this.dotless} .showLatestValue=${this.latest} .valueFormatter=${this.euro(2)} .axisValueFormatter=${wholeEuro}></dees-chart-line>
220
+ <dees-chart-line .loading=${this.load !== 'none'} label="Cloud spend by service" meta="per week, stacked into the total" stacked fillArea .series=${this.noData ? [] : data.cloudSpend} .presentation=${this.alternate ? 'step' : 'line'} .showMarkers=${!this.dotless} .showLatestValue=${this.latest} .valueFormatter=${this.euro(2)} .axisValueFormatter=${wholeEuro}></dees-chart-line>
221
+ <dees-chart-line .loading=${this.load !== 'none'} label="Stated a day apart" .series=${this.noData ? [] : data.dayApart} .presentation=${presentation} .fillArea=${this.filled} .showMarkers=${!this.dotless} .showLatestValue=${this.latest} .valueFormatter=${(value: number) => `$${this.i18n.format.number(value, 'integer')}`}></dees-chart-line>
222
+ <dees-chart-line .loading=${this.load !== 'none'} label="A year of daily balances" .series=${this.noData ? [] : data.daily} .presentation=${presentation} .fillArea=${this.filled} .showMarkers=${!this.dotless} .showLatestValue=${this.latest} .valueFormatter=${this.euro(2)} .axisValueFormatter=${wholeEuro}></dees-chart-line>
193
223
  <div class="widths" role="group" aria-label="A year of month ends at two widths">
194
- <dees-chart-line class="wide" label="A year of month ends, 1440 px wide" .series=${this.empty ? [] : data.monthEnds} .presentation=${presentation} .fillArea=${this.filled} .showMarkers=${!this.dotless} .showLatestValue=${this.latest} .valueFormatter=${wholeEuro}></dees-chart-line>
195
- <dees-chart-line class="narrow" label="420 px wide" .series=${this.empty ? [] : data.monthEnds} .presentation=${presentation} .fillArea=${this.filled} .showMarkers=${!this.dotless} .showLatestValue=${this.latest} .valueFormatter=${wholeEuro}></dees-chart-line>
224
+ <dees-chart-line .loading=${this.load !== 'none'} class="wide" label="A year of month ends, 1440 px wide" .series=${this.noData ? [] : data.monthEnds} .presentation=${presentation} .fillArea=${this.filled} .showMarkers=${!this.dotless} .showLatestValue=${this.latest} .valueFormatter=${wholeEuro}></dees-chart-line>
225
+ <dees-chart-line .loading=${this.load !== 'none'} class="narrow" label="420 px wide" .series=${this.noData ? [] : data.monthEnds} .presentation=${presentation} .fillArea=${this.filled} .showMarkers=${!this.dotless} .showLatestValue=${this.latest} .valueFormatter=${wholeEuro}></dees-chart-line>
196
226
  </div>` : ''}
197
- ${this.kind === 'radar' ? html`<dees-chart-radar label="Current service and target" .indicators=${data.indicators} .series=${this.empty ? [] : data.profiles} .fillArea=${!this.alternate}></dees-chart-radar>` : ''}
198
- <p class="feedback" role="status">${this.empty ? 'There are no measurements for this period.' : `Sample ${this.sample + 1} · Values stay in this example. Use Next sample to compare an update.`}</p>`;
227
+ ${this.kind === 'radar' ? html`<dees-chart-radar .loading=${this.load !== 'none'} label="Current service and target" .indicators=${data.indicators} .series=${this.noData ? [] : data.profiles} .fillArea=${!this.alternate}></dees-chart-radar>` : ''}`)}
228
+ <p class="feedback" role="status">${this.load === 'first' ? 'First load: each chart keeps its place empty for a moment, then shows its placeholder, and after ten seconds says it is still loading.' : this.load === 'refresh' ? 'Loading a refresh: each chart keeps what it shows and states that it is busy.' : this.empty ? 'There are no measurements for this period.' : `Sample ${this.sample + 1} · Values stay in this example. Use Next sample to compare an update.`}</p>`;
199
229
  }
200
230
  }
201
231
  export const chartDemo = (kind: TChartDemo) => demoPage(descriptions[kind][0], descriptions[kind][1], html`<dees-demo-chart-workspace .kind=${kind}></dees-demo-chart-workspace>`);
@@ -1,14 +1,15 @@
1
1
  import type { DeesElement } from '@design.estate/dees-element';
2
- import type { TReactiveController } from '../00controller.js';
2
+ import type { TReactiveController } from './00controller.js';
3
3
 
4
4
  /**
5
- * Counts a first load towards its "still loading", as the catalog's session list does: while
6
- * `isFirstLoad()` holds — loading, with nothing to show yet — the host draws placeholders, and once
7
- * it has held for `stillLoadingAfter()` milliseconds, `stillLoading` turns true and the host
8
- * renders again to say so. Ending the load, or content arriving, forgets the count; a first load
9
- * under way when the host left the page counts again from its return.
5
+ * Counts a first load towards its "still loading", as the catalog's session list does; the Kanban
6
+ * board and the charts count theirs with it. While `isFirstLoad()` holds — loading, with nothing
7
+ * to show yet — the host draws placeholders, and once it has held for `stillLoadingAfter()`
8
+ * milliseconds, `stillLoading` turns true and the host renders again to say so. Ending the load,
9
+ * or content arriving, forgets the count; a first load under way when the host left the page
10
+ * counts again from its return.
10
11
  */
11
- export class KanbanFirstLoadController implements TReactiveController {
12
+ export class FirstLoadController implements TReactiveController {
12
13
  private timer: ReturnType<typeof setTimeout> | undefined;
13
14
  private stalled = false;
14
15
 
@@ -14,6 +14,7 @@ import { chartFrame } from './dees-chart-frame.js';
14
14
  import './dees-legend/dees-legend.js';
15
15
  import type { IDeesLegendItem, IDeesLegendToggleDetail } from './dees-legend/dees-legend.js';
16
16
  import { dcLocalize } from '../../i18n/localize.js';
17
+ import { FirstLoadController } from '../00firstload.js';
17
18
 
18
19
  /**
19
20
  * Abstract base class for ECharts-based chart components.
@@ -35,11 +36,29 @@ import { dcLocalize } from '../../i18n/localize.js';
35
36
  * legend, the plot taking what the rest leaves. A chart whose rows vary takes `height: auto`, and
36
37
  * its plot is then `--dees-chart-plot-height` tall (320px by default, what the default height
37
38
  * leaves the plot under a header and a legend of one row).
39
+ *
40
+ * While the host loads the chart's data it sets `loading`. The first load, before the chart has
41
+ * shown data, covers the plot at once and draws a placeholder in its place once it has taken
42
+ * 200 ms, so a quick load never flashes it; the placeholder pulses on `--dees-loading-pulse-*`,
43
+ * holds still under reduced motion, and after `stillLoadingAfter` (10 s) the chart says it is
44
+ * still loading. The tile is `aria-busy` while loading, a visually hidden status says the load,
45
+ * and the placeholder is hidden from assistive technology. Data already on show stays while a
46
+ * refresh loads.
38
47
  */
39
48
  export abstract class DeesChartEchartsBase extends DeesElement {
49
+ /** How long a first load runs, in milliseconds, before the chart says it is still loading. */
50
+ public static stillLoadingAfter = 10_000;
51
+
40
52
  /** The chart's words and formats, in the reader's language. */
41
53
  protected readonly t = dcLocalize(this);
42
54
 
55
+ /**
56
+ * The host is loading the chart's data. Before the chart has shown data, it draws a placeholder
57
+ * in place of the plot (see the class); data on show stays while it loads again.
58
+ */
59
+ @property({ type: Boolean, reflect: true })
60
+ accessor loading: boolean = false;
61
+
43
62
  /**
44
63
  * The chart's heading, in its tile's standard header bar. Empty, the chart draws no header row,
45
64
  * as in a pane whose header names it; its text alternative then starts with the catalog's
@@ -71,8 +90,16 @@ export abstract class DeesChartEchartsBase extends DeesElement {
71
90
  protected chartInstance: IEchartsInstance | null = null;
72
91
  protected echartsBundle: IEchartsBundle | null = null;
73
92
  private resizeObserver: ResizeObserver | null = null;
74
- @state() private accessor loading = true;
93
+ /** ECharts itself is loading. */
94
+ @state() private accessor libraryLoading = true;
75
95
  @state() private accessor loadError = '';
96
+ /** The chart has shown data: from then on, a load keeps it on show. */
97
+ private shownData = false;
98
+ private readonly firstLoad = new FirstLoadController(
99
+ this,
100
+ () => this.isFirstLoad(),
101
+ () => (this.constructor as typeof DeesChartEchartsBase).stillLoadingAfter,
102
+ );
76
103
  @state() private accessor hiddenSeries = new Set<string>();
77
104
  protected legendItems(): Array<{name: string; color: string; value?: string}> { return []; }
78
105
  /** Whether the reader left a legend entry switched on. */
@@ -94,7 +121,7 @@ export abstract class DeesChartEchartsBase extends DeesElement {
94
121
  super();
95
122
  domtools.elementBasic.setup();
96
123
  this.registerStartupFunction(async (signal) => {
97
- this.loading = true; this.loadError = '';
124
+ this.libraryLoading = true; this.loadError = '';
98
125
  const motion = matchMedia(reducedMotionQuery);
99
126
  const updateMotion = () => { this.reducedMotion = motion.matches; this.updateChart(); };
100
127
  this.reducedMotion = motion.matches;
@@ -127,7 +154,7 @@ export abstract class DeesChartEchartsBase extends DeesElement {
127
154
  if (!signal.aborted) this.loadError = this.t('chart.loadFailed');
128
155
  console.error('Failed to initialize ECharts:', error);
129
156
  } finally {
130
- if (!signal.aborted) this.loading = false;
157
+ if (!signal.aborted) this.libraryLoading = false;
131
158
  }
132
159
  });
133
160
  this.registerGarbageFunction(async () => {
@@ -148,8 +175,29 @@ export abstract class DeesChartEchartsBase extends DeesElement {
148
175
 
149
176
  public render(): TemplateResult { return this.renderChartFrame(); }
150
177
 
178
+ /**
179
+ * Whether data the host sets while it still loads has arrived: the chart shows it at once. A
180
+ * chart that always holds a value to draw, such as a gauge, says no, and its first load ends
181
+ * when the host stops loading.
182
+ */
183
+ protected dataArrivesWhileLoading(): boolean { return true; }
184
+
185
+ /** The first load: the host loads, and the chart has no data on show. */
186
+ protected isFirstLoad(): boolean {
187
+ return this.loading && !(this.hasChartData() && (this.shownData || this.dataArrivesWhileLoading()));
188
+ }
189
+
190
+ public willUpdate(changedProperties: Map<PropertyKey, unknown>): void {
191
+ super.willUpdate(changedProperties);
192
+ if (!this.loading && this.hasChartData()) this.shownData = true;
193
+ }
194
+
151
195
  public renderChartFrame(): TemplateResult {
152
- const message = this.loadError || (this.loading ? this.t('chart.loading') : !this.hasChartData() ? this.t('chart.noData') : '');
196
+ // a library that failed to load says so in place of the placeholder
197
+ const firstLoad = this.isFirstLoad() && !this.loadError;
198
+ const stillLoading = firstLoad && this.firstLoad.stillLoading;
199
+ const message = this.loadError || (firstLoad ? ''
200
+ : this.libraryLoading ? this.t('chart.loading') : !this.hasChartData() ? this.t('chart.noData') : '');
153
201
  const legend: IDeesLegendItem[] = this.legendItems().map((item) => ({
154
202
  label: item.name,
155
203
  color: item.color,
@@ -162,6 +210,9 @@ export abstract class DeesChartEchartsBase extends DeesElement {
162
210
  frameless: this.frameless,
163
211
  plot: html`<div class="chartContainer" aria-hidden="true"><div class="chartPlot"></div></div>`,
164
212
  state: message,
213
+ busy: this.loading,
214
+ firstLoad: firstLoad ? { stillLoading, stillLoadingText: this.t('chart.stillLoading') } : undefined,
215
+ loadingStatus: firstLoad ? this.t(stillLoading ? 'chart.stillLoading' : 'chart.loading') : '',
165
216
  summary: this.summary || this.dataSummary(),
166
217
  footer: legend.length ? html`<dees-legend interactive label=${this.t('chart.series')} .items=${legend} @item-toggle=${(event: CustomEvent<IDeesLegendToggleDetail>) => {
167
218
  const hidden = new Set(this.hiddenSeries);
@@ -41,6 +41,18 @@ export const chartFrameStyles = css`
41
41
  .chartContainer { position: absolute; inset: 0; }
42
42
  .chartState { position: absolute; inset: 0; display: grid; place-content: center; padding: 24px; text-align: center; color: var(--dees-color-text-muted); background: var(--dees-color-bg-primary); }
43
43
  .chartSummary { ${visuallyHidden} }
44
+ /* The first load covers the plot at once, so a quick load flashes neither empty axes nor a
45
+ placeholder; the placeholder shows after 200 ms, pulsing until the load is said to take long. */
46
+ .chartLoading { position: absolute; inset: 0; display: grid; padding: var(--dees-spacing-lg); background: var(--dees-color-bg-primary); }
47
+ .chartPlaceholder { grid-area: 1 / 1; border-radius: var(--dees-radius-md); corner-shape: var(--dees-corner-shape); background: var(--dees-color-fill-secondary); visibility: hidden; animation: dees-chart-placeholder-reveal 1ms linear 200ms both, dees-chart-placeholder-pulse var(--dees-loading-pulse-duration) var(--dees-ease-standard) 200ms infinite; }
48
+ .chartLoading.stalled .chartPlaceholder { animation: dees-chart-placeholder-reveal 1ms linear 200ms both; }
49
+ .chartStillLoading { grid-area: 1 / 1; place-self: center; padding: var(--dees-spacing-lg); text-align: center; color: var(--dees-color-text-muted); }
50
+ .chartLoadingStatus { ${visuallyHidden} }
51
+ @keyframes dees-chart-placeholder-reveal { from { visibility: hidden; } to { visibility: visible; } }
52
+ @keyframes dees-chart-placeholder-pulse { 0%, 100% { opacity: 1; } 50% { opacity: var(--dees-loading-pulse-opacity); } }
53
+ @media (prefers-reduced-motion: reduce) {
54
+ .chartPlaceholder { animation: dees-chart-placeholder-reveal 1ms linear 200ms both; }
55
+ }
44
56
  `;
45
57
 
46
58
  /** What a chart puts into its frame; see `chartFrame`. */
@@ -60,6 +72,18 @@ export interface IChartFrameContent {
60
72
  summary?: string;
61
73
  /** The footer bar's content: the legend, figures about the chart. */
62
74
  footer?: TemplateResult;
75
+ /** The host is loading: the tile is `aria-busy`. */
76
+ busy?: boolean;
77
+ /**
78
+ * The first load, which has nothing to show yet: the plot is covered at once and a placeholder
79
+ * takes its place after 200 ms; `stillLoading` holds it still and says `stillLoadingText` over it.
80
+ */
81
+ firstLoad?: { stillLoading: boolean; stillLoadingText: string };
82
+ /**
83
+ * What a screen reader hears while the first load runs, in a visually hidden status that is
84
+ * there before it speaks; empty otherwise. Unset, the frame has no such status.
85
+ */
86
+ loadingStatus?: string;
63
87
  }
64
88
 
65
89
  /**
@@ -84,7 +108,8 @@ export const chartFrame = (hostArg: DeesElement, contentArg: IChartFrameContent)
84
108
  ? html`<h2 class="chartLabel">${contentArg.label}</h2>`
85
109
  : ''}${contentArg.meta ? html`<span class="chartMeta">${contentArg.meta}</span>` : ''}</div>`
86
110
  : '';
87
- return html`<dees-tile .frameless=${contentArg.frameless}>
111
+ const firstLoad = contentArg.firstLoad;
112
+ return html`<dees-tile .frameless=${contentArg.frameless} aria-busy=${contentArg.busy ? 'true' : 'false'}>
88
113
  ${heading || contentArg.headerTools
89
114
  ? html`<div slot="header" class="chartHeader">${heading}${contentArg.headerTools ?? ''}</div>`
90
115
  : ''}
@@ -92,7 +117,12 @@ export const chartFrame = (hostArg: DeesElement, contentArg: IChartFrameContent)
92
117
  <div class="chartArea">
93
118
  ${contentArg.plot}
94
119
  ${contentArg.state ? html`<div class="chartState" role="status">${contentArg.state}</div>` : ''}
120
+ ${firstLoad ? html`<div class="chartLoading ${firstLoad.stillLoading ? 'stalled' : ''}" aria-hidden="true">
121
+ <span class="chartPlaceholder"></span>
122
+ ${firstLoad.stillLoading ? html`<span class="chartStillLoading">${firstLoad.stillLoadingText}</span>` : ''}
123
+ </div>` : ''}
95
124
  </div>
125
+ ${contentArg.loadingStatus === undefined ? '' : html`<p class="chartLoadingStatus" role="status">${contentArg.loadingStatus}</p>`}
96
126
  ${chartRows(hostArg, 'below')}
97
127
  ${contentArg.summary === undefined ? '' : html`<p class="chartSummary">${contentArg.summary}</p>`}
98
128
  ${contentArg.footer ? html`<div slot="footer" class="chartLegend">${contentArg.footer}</div>` : ''}
@@ -69,6 +69,8 @@ export class DeesChartGauge extends DeesChartEchartsBase {
69
69
  }
70
70
 
71
71
  protected hasChartData() { return Number.isFinite(this.value); }
72
+ /** The gauge always holds a value: its first load ends when the host stops loading. */
73
+ protected dataArrivesWhileLoading() { return false; }
72
74
  protected dataSummary() { return `${this.value}${this.unit}, range ${this.min} to ${this.max}`; }
73
75
 
74
76
  protected buildOption(): Record<string, any> {
@@ -115,6 +115,20 @@ export class DeesChartLine extends DeesChartEchartsBase {
115
115
  @property({ type: Boolean, reflect: true })
116
116
  accessor fillArea: boolean = false;
117
117
 
118
+ /**
119
+ * Stacks the series: each is drawn on top of the ones before it, so the topmost line is their
120
+ * total at each moment. A value above zero stacks on the values above zero beneath it, one below
121
+ * zero under those below zero. Where a series states no value at a moment another series states
122
+ * one, it adds there what its own drawing reads: with `step` its value before, with `line` its
123
+ * line between the two values around the moment; nothing with `points`, before its first value,
124
+ * after its last or beside a missing one. With `fillArea`, each series tints the band between its
125
+ * line and the one beneath it evenly in its colour. The value axis includes zero, and a series
126
+ * switched off in the legend leaves the stack. The tooltip, the legend and the text summary keep
127
+ * each series' own values.
128
+ */
129
+ @property({ type: Boolean, reflect: true })
130
+ accessor stacked: boolean = false;
131
+
118
132
  /**
119
133
  * Marks every value with a dot. Turn off for long series, where a dot on every value crowds the
120
134
  * line: `line` and `step` then draw the line alone, and while the pointer is over the plot, the
@@ -192,6 +206,7 @@ export class DeesChartLine extends DeesChartEchartsBase {
192
206
  changedProperties.has('presentation') ||
193
207
  changedProperties.has('includeZero') ||
194
208
  changedProperties.has('fillArea') ||
209
+ changedProperties.has('stacked') ||
195
210
  changedProperties.has('showMarkers') ||
196
211
  changedProperties.has('showLegend') ||
197
212
  changedProperties.has('valueFormatter') ||
@@ -346,6 +361,66 @@ export class DeesChartLine extends DeesChartEchartsBase {
346
361
  return { origin: 0, color: { type: 'linear', x: 0, y: 0, x2: 0, y2: 1, colorStops } };
347
362
  }
348
363
 
364
+ /**
365
+ * The series on the moments any of them states, in time order, as a stack needs them: ECharts
366
+ * stacks values on a time axis by their index, so each series takes a row of the same moments.
367
+ * At a moment a series states, its value (or `null`); at one it does not, what its drawing reads
368
+ * there, marked `derived`: under `step` its value before, under `line` its line between the
369
+ * values around the moment. `null` under `points`, before its first value, after its last and
370
+ * beside a missing one, where its drawing reads nothing.
371
+ */
372
+ public static stackRows(
373
+ normalizedArg: Array<Array<[number, number | null]>>,
374
+ presentationArg: TChartLinePresentation,
375
+ ): Array<Array<{ time: number; value: number | null; derived: boolean }>> {
376
+ const moments = DeesChartLine.allMoments(normalizedArg);
377
+ return normalizedArg.map((points) => {
378
+ let next = 0;
379
+ return moments.map((time) => {
380
+ while (next < points.length && points[next][0] < time) next++;
381
+ if (points[next]?.[0] === time) return { time, value: points[next][1], derived: false };
382
+ const before = points[next - 1]?.[1] ?? null;
383
+ const after = points[next]?.[1] ?? null;
384
+ if (presentationArg === 'points' || before === null || after === null) return { time, value: null, derived: false };
385
+ const value = presentationArg === 'step'
386
+ ? before
387
+ : before + (after - before) * (time - points[next - 1][0]) / (points[next][0] - points[next - 1][0]);
388
+ return { time, value, derived: true };
389
+ });
390
+ });
391
+ }
392
+
393
+ /** Every moment of the series, stated or missing, in time order and each once. */
394
+ private static allMoments(normalizedArg: Array<Array<[number, number | null]>>): number[] {
395
+ const moments: number[] = [];
396
+ for (const points of normalizedArg) for (const [time] of points) moments.push(time);
397
+ moments.sort((left, right) => left - right);
398
+ return moments.filter((moment, index) => index === 0 || moment !== moments[index - 1]);
399
+ }
400
+
401
+ /**
402
+ * Where each shown series' line runs in the stack, moment by moment, as ECharts stacks them
403
+ * (`samesign`): a value adds the top of the nearest shown series beneath it whose top lies on
404
+ * its side of zero. `null` where the series has no value, and for a series switched off.
405
+ */
406
+ private static stackTops(
407
+ rowsArg: Array<Array<{ value: number | null }>>,
408
+ shownArg: boolean[],
409
+ ): Array<Array<number | null>> {
410
+ const tops: Array<Array<number | null>> = [];
411
+ rowsArg.forEach((row, index) => {
412
+ tops[index] = row.map(({ value }, at) => {
413
+ if (!shownArg[index] || value === null) return null;
414
+ for (let below = index - 1; below >= 0; below--) {
415
+ const top = tops[below][at];
416
+ if (top !== null && ((value >= 0 && top > 0) || (value <= 0 && top < 0))) return value + top;
417
+ }
418
+ return value;
419
+ });
420
+ });
421
+ return tops;
422
+ }
423
+
349
424
  /**
350
425
  * The values of a series that state no neighbour before or after them: no line reaches them,
351
426
  * so a drawing without dots would not show them at all.
@@ -388,6 +463,8 @@ export class DeesChartLine extends DeesChartEchartsBase {
388
463
  } : undefined;
389
464
  const ticks = this.timeAxis ? this.labelTimeAxis(length) : undefined;
390
465
  const filled = this.fillArea && this.presentation !== 'points';
466
+ const stacked = this.stacked;
467
+ const rows = stacked ? DeesChartLine.stackRows(normalized, this.presentation) : undefined;
391
468
  const alpha = this.goBright ? areaAlpha.bright : areaAlpha.dark;
392
469
  // Without markers a line draws no dots: ECharts draws the dots of the moment the pointer is
393
470
  // nearest while it is there, and a value no line reaches keeps its dot, drawn by a series of
@@ -400,7 +477,14 @@ export class DeesChartLine extends DeesChartEchartsBase {
400
477
  return {
401
478
  name: series.name,
402
479
  type: 'line' as const,
403
- data: normalized[index],
480
+ // stacked, each series on every moment; a value its drawing reads between two it states
481
+ // takes no dot and no tooltip
482
+ data: rows
483
+ ? rows[index].map(({ time, value, derived }) => derived
484
+ ? { value: [time, value], derived: true, symbol: 'none' }
485
+ : [time, value])
486
+ : normalized[index],
487
+ ...(stacked ? { stack: 'total', stackStrategy: 'samesign' } : {}),
404
488
  connectNulls: false,
405
489
  showSymbol: !dotless,
406
490
  symbol: 'circle',
@@ -408,14 +492,23 @@ export class DeesChartLine extends DeesChartEchartsBase {
408
492
  step: this.presentation === 'step' ? 'end' : false,
409
493
  itemStyle: dotStyle(color),
410
494
  lineStyle: this.presentation === 'points' ? { width: 0, opacity: 0 } : { width: 2, color },
411
- areaStyle: filled ? DeesChartLine.areaFill(color, alpha, normalized[index]) : undefined,
495
+ areaStyle: filled
496
+ ? stacked ? { color, opacity: alpha } : DeesChartLine.areaFill(color, alpha, normalized[index])
497
+ : undefined,
412
498
  emphasis: this.presentation === 'points'
413
499
  ? { scale: 1.4, lineStyle: { width: 0, opacity: 0 } }
414
500
  : { scale: 1.4, lineStyle: { width: 2 } },
415
501
  };
416
502
  });
503
+ // stacked, a lone value's dot sits where its series runs in the stack
504
+ const shown = this.series.map((series) => this.legendShown(series.name));
505
+ const tops = rows && dotless ? DeesChartLine.stackTops(rows, shown) : undefined;
417
506
  const loneDots = dotless ? this.series.flatMap((series, index) => {
418
- const lone = DeesChartLine.loneValues(normalized[index]);
507
+ const lone = rows
508
+ ? DeesChartLine.loneValues(rows[index].map(({ time, value }) => [time, value] as [number, number | null]))
509
+ .map(([time]): [number, number] => [time, tops![index][rows[index].findIndex((row) => row.time === time)]!])
510
+ .filter(([, top]) => top !== null && top !== undefined)
511
+ : DeesChartLine.loneValues(normalized[index]);
419
512
  return lone.length === 0 ? [] : [{
420
513
  name: series.name,
421
514
  type: 'line' as const,
@@ -440,8 +533,8 @@ export class DeesChartLine extends DeesChartEchartsBase {
440
533
  trigger: 'axis',
441
534
  axisPointer: { type: 'line', snap: true, lineStyle: { color: colors.borderStrong } },
442
535
  formatter: (params: any) => {
443
- const stated = (params as Array<{ value: [number, number | null]; color: string; seriesName: string }>)
444
- .filter((param) => param.value[1] !== null);
536
+ const stated = (params as Array<{ value: [number, number | null]; data: unknown; color: string; seriesName: string }>)
537
+ .filter((param) => param.value[1] !== null && !(param.data as { derived?: boolean } | null)?.derived);
445
538
  if (stated.length === 0) return '';
446
539
  return `<strong>${timeFormatter(stated[0].value[0])}</strong>`
447
540
  + stated.map((param) => `<br/>${reading(param.color, param.seriesName, param.value[1]!)}`).join('');
@@ -450,7 +543,7 @@ export class DeesChartLine extends DeesChartEchartsBase {
450
543
  trigger: 'item',
451
544
  formatter: (params: any) => {
452
545
  const [time, value] = params.value as [number, number | null];
453
- if (value === null) return '';
546
+ if (value === null || params.data?.derived) return '';
454
547
  return `<strong>${timeFormatter(time)}</strong><br/>${reading(params.color, params.seriesName, value)}`;
455
548
  },
456
549
  },
@@ -478,7 +571,7 @@ export class DeesChartLine extends DeesChartEchartsBase {
478
571
  },
479
572
  yAxis: {
480
573
  type: 'value',
481
- scale: !(this.includeZero || filled),
574
+ scale: !(this.includeZero || filled || stacked),
482
575
  axisLine: { show: false },
483
576
  axisLabel: {
484
577
  color: colors.textMuted,