@brad-frost-web/eddie-charts 0.70.0 → 0.72.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/charts/common/bar-chart/bar-chart.d.ts +27 -7
- package/charts/common/bar-chart/bar-chart.d.ts.map +1 -1
- package/charts/common/bar-chart/bar-chart.js +68 -54
- package/charts/common/doughnut/doughnut.d.ts +16 -4
- package/charts/common/doughnut/doughnut.d.ts.map +1 -1
- package/charts/common/doughnut/doughnut.js +18 -17
- package/charts/common/line-chart/line-chart.d.ts +27 -7
- package/charts/common/line-chart/line-chart.d.ts.map +1 -1
- package/charts/common/line-chart/line-chart.js +49 -31
- package/charts/common/projection/projection.d.ts +15 -5
- package/charts/common/projection/projection.d.ts.map +1 -1
- package/charts/common/projection/projection.js +38 -37
- package/charts/gaps.js +12 -0
- package/charts/theme-bridge.js +8 -7
- package/package.json +2 -1
- package/shared/gaps.d.ts +18 -0
- package/shared/gaps.d.ts.map +1 -0
- package/shared/theme-bridge.d.ts.map +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { EdElement } from '@brad-frost-web/eddie-web-components/components/EdElement.js';
|
|
2
2
|
export interface BarChartDataset {
|
|
3
3
|
label: string;
|
|
4
|
-
values: number[];
|
|
4
|
+
values: (number | null)[];
|
|
5
5
|
semantic?: 'positive' | 'negative' | 'neutral';
|
|
6
6
|
}
|
|
7
7
|
export interface BarChartData {
|
|
@@ -26,12 +26,16 @@ export interface BarChartData {
|
|
|
26
26
|
* @dontuse For actual-versus-projected overlays — use `ed-r-projection`.
|
|
27
27
|
* @dontuse For more than ~20 categories — the chart becomes unreadable; use
|
|
28
28
|
* a sortable table or a filterable list instead.
|
|
29
|
-
* @a11y `chart-label` is required; it is announced as the
|
|
30
|
-
* accessible name and
|
|
29
|
+
* @a11y `chartLabel` (or `chart-label`) is required; it is announced as the
|
|
30
|
+
* chart region's accessible name and becomes the caption of the linked data table.
|
|
31
|
+
* Without it the region gets no `aria-label` and a console warning.
|
|
31
32
|
* @a11y `dataTable` (default `true`) exposes every data point to assistive
|
|
32
33
|
* tech via a real `<table>` inside a `<details>` toggle.
|
|
33
34
|
* @a11y `yFormat` is used for both tooltip labels and data-table cell values,
|
|
34
35
|
* so the announced text matches the visual formatting.
|
|
36
|
+
* @a11y A `null` category draws no bar and renders an em dash in the data
|
|
37
|
+
* table, announced as "no data" — the text alternative never reads an
|
|
38
|
+
* unknown as `0` (#1324).
|
|
35
39
|
* @a11y Respects `prefers-reduced-motion` — disables chart animation.
|
|
36
40
|
* @a11y Keyboard navigation across individual bars and decal/pattern fills
|
|
37
41
|
* are not yet implemented — tracked on #656 as follow-up work.
|
|
@@ -44,7 +48,7 @@ export interface BarChartData {
|
|
|
44
48
|
* @related ed-table — the accessible data-table equivalent
|
|
45
49
|
* @related ed-r-projection — actual against expected; ed-r-stat-card — one or two headline numbers
|
|
46
50
|
*
|
|
47
|
-
* @content Bars for comparing categories; use horizontal when labels are long. Always supply `dataTable`; label axes via `yFormat`.
|
|
51
|
+
* @content Bars for comparing categories; use horizontal when labels are long. Always supply `dataTable`; label axes via `yFormat`. Write a category with no data as `null`, never `0`: no bar is drawn and the table reads "no data", where a `0` draws an empty-but-real bar that says "nothing happened". Reserve `0` for a measured zero.
|
|
48
52
|
*
|
|
49
53
|
* @state `orientation` (vertical|horizontal) / `variant` (grouped|stacked). No interaction states beyond tooltips.
|
|
50
54
|
* @slot - Optional extended description (e.g., a trend callout) rendered
|
|
@@ -62,7 +66,11 @@ export interface BarChartData {
|
|
|
62
66
|
* @notWhen there are only one or two headline numbers — use `ed-r-stat-card`
|
|
63
67
|
*/
|
|
64
68
|
export declare class EdRBarChart extends EdElement {
|
|
65
|
-
/**
|
|
69
|
+
/**
|
|
70
|
+
* Chart data — labels and one or more datasets with optional semantic hints.
|
|
71
|
+
* A `null` in a dataset's `values` is a category with no data: no bar is
|
|
72
|
+
* drawn and the data table reads "no data". Use `0` only for a measured zero.
|
|
73
|
+
*/
|
|
66
74
|
data: BarChartData;
|
|
67
75
|
/**
|
|
68
76
|
* Bar orientation: `vertical` (default) or `horizontal`.
|
|
@@ -82,9 +90,15 @@ export declare class EdRBarChart extends EdElement {
|
|
|
82
90
|
* keeps a common baseline, so put the one that matters most there.
|
|
83
91
|
*/
|
|
84
92
|
variant: 'grouped' | 'stacked';
|
|
85
|
-
/**
|
|
93
|
+
/**
|
|
94
|
+
* Accessible label for the chart region (required for a11y). Write it as
|
|
95
|
+
* `chartLabel` or `chart-label`; both bind, like every multi-word Eddie prop.
|
|
96
|
+
*/
|
|
86
97
|
chartLabel: string;
|
|
87
|
-
/**
|
|
98
|
+
/**
|
|
99
|
+
* Render a toggle-able linked data table (default `true`). Write it as
|
|
100
|
+
* `dataTable` or `data-table`; both bind, like every multi-word Eddie prop.
|
|
101
|
+
*/
|
|
88
102
|
dataTable: boolean;
|
|
89
103
|
/** Formatter for numeric values — applied to ticks, tooltip, and data table. */
|
|
90
104
|
yFormat: (v: number) => string;
|
|
@@ -101,6 +115,12 @@ export declare class EdRBarChart extends EdElement {
|
|
|
101
115
|
private toChartJsOptions;
|
|
102
116
|
render(): import('lit-html').TemplateResult<1>;
|
|
103
117
|
private renderTable;
|
|
118
|
+
/**
|
|
119
|
+
* One data cell: the formatted value, or — for a category with no data — an
|
|
120
|
+
* em dash hidden from assistive tech beside the words "no data" hidden from
|
|
121
|
+
* sight, so the cell is never read as a number (#1324).
|
|
122
|
+
*/
|
|
123
|
+
private renderCell;
|
|
104
124
|
}
|
|
105
125
|
declare global {
|
|
106
126
|
interface HTMLElementTagNameMap {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bar-chart.d.ts","sourceRoot":"","sources":["../../../../../packages/eddie-charts/charts/common/bar-chart/bar-chart.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,8DAA8D,CAAC;
|
|
1
|
+
{"version":3,"file":"bar-chart.d.ts","sourceRoot":"","sources":["../../../../../packages/eddie-charts/charts/common/bar-chart/bar-chart.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,8DAA8D,CAAC;AAyBzF,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,MAAM,CAAC;IAKd,MAAM,EAAE,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE,CAAC;IAG1B,QAAQ,CAAC,EAAE,UAAU,GAAG,UAAU,GAAG,SAAS,CAAC;CAChD;AAED,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,QAAQ,EAAE,eAAe,EAAE,CAAC;CAC7B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwDG;AACH,qBAAa,WAAY,SAAQ,SAAS;IACxC;;;;OAIG;IAEH,IAAI,EAAE,YAAY,CAAgC;IAElD;;;;;;;OAOG;IAEH,WAAW,EAAE,UAAU,GAAG,YAAY,CAAc;IAEpD;;;;;;;OAOG;IAEH,OAAO,EAAE,SAAS,GAAG,SAAS,CAAa;IAE3C;;;OAGG;IAEH,UAAU,SAAM;IAEhB;;;OAGG;IAEH,SAAS,UAAQ;IAEjB,gFAAgF;IAEhF,OAAO,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,CAA6B;IAG3D,OAAO,CAAC,MAAM,CAAC,CAAoB;IAEnC,OAAO,CAAC,KAAK,CAAC,CAAQ;IACtB,OAAO,CAAC,KAAK,CAA2B;IACxC,OAAO,CAAC,SAAS,CAAC,CAAa;IAE/B,MAAM,KAAK,MAAM,4BAEhB;IAED,oBAAoB,IAAI,IAAI;IAO5B,YAAY,IAAI,IAAI;IAiBpB,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAe5C,OAAO,CAAC,WAAW;IASnB,OAAO,CAAC,aAAa;IA0BrB,OAAO,CAAC,gBAAgB;IAsDxB,MAAM;IAiBN,OAAO,CAAC,WAAW;IA2BnB;;;;OAIG;IACH,OAAO,CAAC,UAAU;CAUnB;AAMD,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,gBAAgB,EAAE,WAAW,CAAC;KAC/B;CACF"}
|
|
@@ -1,27 +1,29 @@
|
|
|
1
|
-
import { EdElement as
|
|
2
|
-
import { Chart as
|
|
3
|
-
import { unsafeCSS as y, html as
|
|
4
|
-
import { property as
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
import { EdElement as m } from "@brad-frost-web/eddie-web-components/components/EdElement.js";
|
|
2
|
+
import { Chart as p, BarController as u, BarElement as _, CategoryScale as v, LinearScale as g, Tooltip as f, Legend as C } from "chart.js";
|
|
3
|
+
import { unsafeCSS as y, html as i } from "lit";
|
|
4
|
+
import { property as h, query as k } from "lit/decorators.js";
|
|
5
|
+
import { ifDefined as w } from "lit/directives/if-defined.js";
|
|
6
|
+
import { observeThemeChange as x, prefersReducedMotion as $ } from "../../theme-bridge.js";
|
|
7
|
+
import { formatPoint as L, isGap as T, NO_DATA as z } from "../../gaps.js";
|
|
8
|
+
const F = '@charset "UTF-8";:root,:host{--size-base-unit: .5rem}*,::slotted(*),*:before,*:after{box-sizing:border-box}html{scroll-padding-block-start:var(--ed-site-header-block-size, 0px)}h1,h2,h3,h4,h5,h6{margin:0}.ed-r-bar-chart{display:block;container-type:inline-size;color:var(--ed-theme-color-content-default)}.ed-r-bar-chart__canvas{position:relative;width:100%;min-width:0;height:20rem;margin-block-end:1.5rem}.ed-r-bar-chart__canvas-el{display:block;max-width:100%}.ed-r-bar-chart__details{margin-block-end:1rem;border:var(--ed-theme-border-width-sm) solid var(--ed-theme-color-border-subtle);border-radius:var(--ed-theme-border-radius-sm);background:var(--ed-theme-color-background-subtle)}.ed-r-bar-chart__summary{padding:.5rem 1rem;cursor:pointer;font-weight:700;color:var(--ed-theme-color-content-default)}.ed-r-bar-chart__table{width:100%;border-collapse:collapse;color:var(--ed-theme-color-content-default)}.ed-r-bar-chart__caption{padding:.5rem 1rem;text-align:start;font-weight:700;caption-side:top}.ed-r-bar-chart__th,.ed-r-bar-chart__td{padding:.5rem 1rem;border-block-end:var(--ed-theme-border-width-sm) solid var(--ed-theme-color-border-subtle);text-align:start}.ed-r-bar-chart__th{background:var(--ed-theme-color-background-subtle);font-weight:700}.ed-r-bar-chart__gap-label{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0 0 0 0);clip-path:inset(50%);white-space:nowrap;border:0}';
|
|
9
|
+
var J = Object.defineProperty, c = (d, t, e, o) => {
|
|
10
|
+
for (var a = void 0, s = d.length - 1, r; s >= 0; s--)
|
|
11
|
+
(r = d[s]) && (a = r(t, e, a) || a);
|
|
12
|
+
return a && J(t, e, a), a;
|
|
11
13
|
};
|
|
12
|
-
|
|
13
|
-
class
|
|
14
|
+
p.register(u, _, v, g, f, C);
|
|
15
|
+
class l extends m {
|
|
14
16
|
constructor() {
|
|
15
17
|
super(...arguments), this.data = { labels: [], datasets: [] }, this.orientation = "vertical", this.variant = "grouped", this.chartLabel = "", this.dataTable = !0, this.yFormat = (t) => t.toLocaleString(), this.theme = null;
|
|
16
18
|
}
|
|
17
19
|
static get styles() {
|
|
18
|
-
return y(
|
|
20
|
+
return y(F);
|
|
19
21
|
}
|
|
20
22
|
disconnectedCallback() {
|
|
21
23
|
super.disconnectedCallback(), this.unobserve?.(), this.chart?.destroy(), this.chart = void 0;
|
|
22
24
|
}
|
|
23
25
|
firstUpdated() {
|
|
24
|
-
this.canvas && (this.unobserve =
|
|
26
|
+
this.chartLabel || console.warn("[Eddie] <ed-r-bar-chart> has no chartLabel, so its chart region has no accessible name."), this.canvas && (this.unobserve = x(this, (t) => {
|
|
25
27
|
this.theme = t, this.chart ? (this.chart.options = this.toChartJsOptions(), this.chart.data = this.toChartJsData(), this.chart.update()) : this.createChart();
|
|
26
28
|
}));
|
|
27
29
|
}
|
|
@@ -30,22 +32,22 @@ class i extends p {
|
|
|
30
32
|
t.has("orientation") || t.has("variant") ? (this.chart.destroy(), this.chart = void 0, this.createChart()) : (t.has("data") || t.has("yFormat")) && (this.chart.data = this.toChartJsData(), this.chart.options = this.toChartJsOptions(), this.chart.update());
|
|
31
33
|
}
|
|
32
34
|
createChart() {
|
|
33
|
-
!this.canvas || !this.theme || (this.chart = new
|
|
35
|
+
!this.canvas || !this.theme || (this.chart = new p(this.canvas, {
|
|
34
36
|
type: "bar",
|
|
35
37
|
data: this.toChartJsData(),
|
|
36
38
|
options: this.toChartJsOptions()
|
|
37
39
|
}));
|
|
38
40
|
}
|
|
39
41
|
toChartJsData() {
|
|
40
|
-
const { palette: t, positive: e, negative:
|
|
42
|
+
const { palette: t, positive: e, negative: o, neutral: a } = this.theme, s = (r) => {
|
|
41
43
|
if (r === "positive") return e;
|
|
42
|
-
if (r === "negative") return
|
|
44
|
+
if (r === "negative") return o;
|
|
43
45
|
if (r === "neutral") return a;
|
|
44
46
|
};
|
|
45
47
|
return {
|
|
46
48
|
labels: this.data.labels,
|
|
47
49
|
datasets: this.data.datasets.map((r, n) => {
|
|
48
|
-
const b =
|
|
50
|
+
const b = s(r.semantic) ?? t[n % t.length];
|
|
49
51
|
return {
|
|
50
52
|
label: r.label,
|
|
51
53
|
data: r.values,
|
|
@@ -57,12 +59,12 @@ class i extends p {
|
|
|
57
59
|
};
|
|
58
60
|
}
|
|
59
61
|
toChartJsOptions() {
|
|
60
|
-
const t = this.theme, e = this.yFormat,
|
|
62
|
+
const t = this.theme, e = this.yFormat, o = this.variant === "stacked", a = this.orientation === "horizontal", s = (r) => e(Number(r));
|
|
61
63
|
return {
|
|
62
64
|
indexAxis: a ? "y" : "x",
|
|
63
65
|
responsive: !0,
|
|
64
66
|
maintainAspectRatio: !1,
|
|
65
|
-
animation:
|
|
67
|
+
animation: $() ? !1 : { duration: 400 },
|
|
66
68
|
plugins: {
|
|
67
69
|
legend: {
|
|
68
70
|
display: this.data.datasets.length > 1,
|
|
@@ -77,21 +79,21 @@ class i extends p {
|
|
|
77
79
|
callbacks: {
|
|
78
80
|
label: (r) => {
|
|
79
81
|
const n = a ? r.parsed.x : r.parsed.y;
|
|
80
|
-
return `${r.dataset.label}: ${
|
|
82
|
+
return `${r.dataset.label}: ${L(n, e)}`;
|
|
81
83
|
}
|
|
82
84
|
}
|
|
83
85
|
}
|
|
84
86
|
},
|
|
85
87
|
scales: {
|
|
86
88
|
x: {
|
|
87
|
-
stacked:
|
|
88
|
-
ticks: a ? { color: t.tickColor, callback:
|
|
89
|
+
stacked: o,
|
|
90
|
+
ticks: a ? { color: t.tickColor, callback: s } : { color: t.tickColor },
|
|
89
91
|
grid: { color: t.gridlineColor },
|
|
90
92
|
border: { color: t.axisColor }
|
|
91
93
|
},
|
|
92
94
|
y: {
|
|
93
|
-
stacked:
|
|
94
|
-
ticks: a ? { color: t.tickColor } : { color: t.tickColor, callback:
|
|
95
|
+
stacked: o,
|
|
96
|
+
ticks: a ? { color: t.tickColor } : { color: t.tickColor, callback: s },
|
|
95
97
|
grid: { color: t.gridlineColor },
|
|
96
98
|
border: { color: t.axisColor }
|
|
97
99
|
}
|
|
@@ -103,9 +105,9 @@ class i extends p {
|
|
|
103
105
|
"ed-r-bar-chart--horizontal": this.orientation === "horizontal",
|
|
104
106
|
"ed-r-bar-chart--stacked": this.variant === "stacked"
|
|
105
107
|
});
|
|
106
|
-
return
|
|
108
|
+
return i`
|
|
107
109
|
<div class="${t}">
|
|
108
|
-
<div class="ed-r-bar-chart__canvas" role="img" aria-label=${this.chartLabel}>
|
|
110
|
+
<div class="ed-r-bar-chart__canvas" role="img" aria-label=${w(this.chartLabel || void 0)}>
|
|
109
111
|
<canvas class="ed-r-bar-chart__canvas-el"></canvas>
|
|
110
112
|
</div>
|
|
111
113
|
<slot></slot>
|
|
@@ -115,7 +117,7 @@ class i extends p {
|
|
|
115
117
|
}
|
|
116
118
|
renderTable() {
|
|
117
119
|
const { labels: t, datasets: e } = this.data;
|
|
118
|
-
return
|
|
120
|
+
return i`
|
|
119
121
|
<details class="ed-r-bar-chart__details">
|
|
120
122
|
<summary class="ed-r-bar-chart__summary">View data table</summary>
|
|
121
123
|
<table class="ed-r-bar-chart__table">
|
|
@@ -123,14 +125,14 @@ class i extends p {
|
|
|
123
125
|
<thead class="ed-r-bar-chart__thead">
|
|
124
126
|
<tr class="ed-r-bar-chart__row">
|
|
125
127
|
<th scope="col" class="ed-r-bar-chart__th">Category</th>
|
|
126
|
-
${e.map((
|
|
128
|
+
${e.map((o) => i`<th scope="col" class="ed-r-bar-chart__th">${o.label}</th>`)}
|
|
127
129
|
</tr>
|
|
128
130
|
</thead>
|
|
129
131
|
<tbody class="ed-r-bar-chart__tbody">
|
|
130
|
-
${t.map((
|
|
132
|
+
${t.map((o, a) => i`
|
|
131
133
|
<tr class="ed-r-bar-chart__row">
|
|
132
|
-
<th scope="row" class="ed-r-bar-chart__th">${
|
|
133
|
-
${e.map((
|
|
134
|
+
<th scope="row" class="ed-r-bar-chart__th">${o}</th>
|
|
135
|
+
${e.map((s) => this.renderCell(s.values[a]))}
|
|
134
136
|
</tr>
|
|
135
137
|
`)}
|
|
136
138
|
</tbody>
|
|
@@ -138,29 +140,41 @@ class i extends p {
|
|
|
138
140
|
</details>
|
|
139
141
|
`;
|
|
140
142
|
}
|
|
143
|
+
/**
|
|
144
|
+
* One data cell: the formatted value, or — for a category with no data — an
|
|
145
|
+
* em dash hidden from assistive tech beside the words "no data" hidden from
|
|
146
|
+
* sight, so the cell is never read as a number (#1324).
|
|
147
|
+
*/
|
|
148
|
+
renderCell(t) {
|
|
149
|
+
if (T(t)) {
|
|
150
|
+
const e = i`<span class="ed-r-bar-chart__gap-glyph" aria-hidden="true">—</span>`, o = i`<span class="ed-r-bar-chart__gap-label">${z}</span>`;
|
|
151
|
+
return i`<td class="ed-r-bar-chart__td">${e}${o}</td>`;
|
|
152
|
+
}
|
|
153
|
+
return i`<td class="ed-r-bar-chart__td">${this.yFormat(t)}</td>`;
|
|
154
|
+
}
|
|
141
155
|
}
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
],
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
],
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
],
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
],
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
],
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
],
|
|
160
|
-
|
|
156
|
+
c([
|
|
157
|
+
h({ attribute: !1 })
|
|
158
|
+
], l.prototype, "data");
|
|
159
|
+
c([
|
|
160
|
+
h({ reflect: !0 })
|
|
161
|
+
], l.prototype, "orientation");
|
|
162
|
+
c([
|
|
163
|
+
h({ reflect: !0 })
|
|
164
|
+
], l.prototype, "variant");
|
|
165
|
+
c([
|
|
166
|
+
h()
|
|
167
|
+
], l.prototype, "chartLabel");
|
|
168
|
+
c([
|
|
169
|
+
h({ type: Boolean })
|
|
170
|
+
], l.prototype, "dataTable");
|
|
171
|
+
c([
|
|
172
|
+
h({ attribute: !1 })
|
|
173
|
+
], l.prototype, "yFormat");
|
|
174
|
+
c([
|
|
161
175
|
k("canvas")
|
|
162
|
-
],
|
|
163
|
-
customElements.get("ed-r-bar-chart") === void 0 && customElements.define("ed-r-bar-chart",
|
|
176
|
+
], l.prototype, "canvas");
|
|
177
|
+
customElements.get("ed-r-bar-chart") === void 0 && customElements.define("ed-r-bar-chart", l);
|
|
164
178
|
export {
|
|
165
|
-
|
|
179
|
+
l as EdRBarChart
|
|
166
180
|
};
|
|
@@ -22,8 +22,9 @@ export interface DoughnutSlice {
|
|
|
22
22
|
* @dontuse For time-series — use `ed-r-line-chart`.
|
|
23
23
|
* @dontuse When precise value comparison matters more than proportion —
|
|
24
24
|
* humans read bar length more accurately than arc angle.
|
|
25
|
-
* @a11y `chart-label` is required; announced as the
|
|
26
|
-
* name and becomes the caption of the data table.
|
|
25
|
+
* @a11y `chartLabel` (or `chart-label`) is required; it is announced as the
|
|
26
|
+
* chart region's accessible name and becomes the caption of the data table.
|
|
27
|
+
* Without it the region gets no `aria-label` and a console warning.
|
|
27
28
|
* @a11y The linked data table includes a computed `%` column so assistive
|
|
28
29
|
* tech announces the same proportion a sighted user perceives.
|
|
29
30
|
* @a11y Legend is keyboard-reachable through Chart.js defaults but does not
|
|
@@ -67,11 +68,22 @@ export declare class EdRDoughnut extends EdElement {
|
|
|
67
68
|
* `none` only when the shares are named somewhere else close by — in an `ed-table` beside
|
|
68
69
|
* it, or in the sentence that introduces it — because to a sighted reader a ring with no
|
|
69
70
|
* legend says nothing (assistive technology still gets the chart's data table).
|
|
71
|
+
*
|
|
72
|
+
* Write it as `legendPosition` or `legend-position`; both bind, like every multi-word
|
|
73
|
+
* Eddie prop. It reflects to the host as `legendposition`, the squashed name every other
|
|
74
|
+
* reflecting multi-word Eddie prop uses (`fullwidth`, `itemwidth`, `labelreveal`), so
|
|
75
|
+
* select on that (#2327).
|
|
70
76
|
*/
|
|
71
77
|
legendPosition: 'bottom' | 'right' | 'none';
|
|
72
|
-
/**
|
|
78
|
+
/**
|
|
79
|
+
* Accessible label for the chart region (required for a11y). Write it as
|
|
80
|
+
* `chartLabel` or `chart-label`; both bind, like every multi-word Eddie prop.
|
|
81
|
+
*/
|
|
73
82
|
chartLabel: string;
|
|
74
|
-
/**
|
|
83
|
+
/**
|
|
84
|
+
* Render a toggle-able linked data table (default `true`). Write it as
|
|
85
|
+
* `dataTable` or `data-table`; both bind, like every multi-word Eddie prop.
|
|
86
|
+
*/
|
|
75
87
|
dataTable: boolean;
|
|
76
88
|
/** Formatter for each slice's numeric value. */
|
|
77
89
|
valueFormat: (v: number) => string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"doughnut.d.ts","sourceRoot":"","sources":["../../../../../packages/eddie-charts/charts/common/doughnut/doughnut.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,8DAA8D,CAAC;
|
|
1
|
+
{"version":3,"file":"doughnut.d.ts","sourceRoot":"","sources":["../../../../../packages/eddie-charts/charts/common/doughnut/doughnut.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,8DAA8D,CAAC;AAqBzF,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IAGd,QAAQ,CAAC,EAAE,UAAU,GAAG,UAAU,GAAG,SAAS,CAAC;CAChD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoDG;AACH,qBAAa,WAAY,SAAQ,SAAS;IACxC,kEAAkE;IAElE,IAAI,EAAE,aAAa,EAAE,CAAM;IAE3B;;;;;;;;;;;;;OAaG;IAEH,cAAc,EAAE,QAAQ,GAAG,OAAO,GAAG,MAAM,CAAY;IAEvD;;;OAGG;IAEH,UAAU,SAAM;IAEhB;;;OAGG;IAEH,SAAS,UAAQ;IAEjB,gDAAgD;IAEhD,WAAW,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,CAA6B;IAE/D,kEAAkE;IAElE,WAAW,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,MAAM,CAAkB;IAG/D,OAAO,CAAC,MAAM,CAAC,CAAoB;IAEnC,OAAO,CAAC,KAAK,CAAC,CAAQ;IACtB,OAAO,CAAC,KAAK,CAA2B;IACxC,OAAO,CAAC,SAAS,CAAC,CAAa;IAE/B,MAAM,KAAK,MAAM,4BAEhB;IAED,oBAAoB,IAAI,IAAI;IAO5B,YAAY,IAAI,IAAI;IAiBpB,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAa5C,OAAO,CAAC,WAAW;IASnB,OAAO,CAAC,aAAa;IAuBrB,OAAO,CAAC,gBAAgB;IA4BxB,OAAO,CAAC,KAAK;IAIb,MAAM;IAcN,OAAO,CAAC,WAAW;CA8BpB;AAMD,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,eAAe,EAAE,WAAW,CAAC;KAC9B;CACF"}
|
|
@@ -1,27 +1,28 @@
|
|
|
1
1
|
import { EdElement as m } from "@brad-frost-web/eddie-web-components/components/EdElement.js";
|
|
2
|
-
import { Chart as u, DoughnutController as p, ArcElement as b, Tooltip as g, Legend as
|
|
3
|
-
import { unsafeCSS as
|
|
2
|
+
import { Chart as u, DoughnutController as p, ArcElement as b, Tooltip as g, Legend as v } from "chart.js";
|
|
3
|
+
import { unsafeCSS as _, html as n } from "lit";
|
|
4
4
|
import { property as i, query as f } from "lit/decorators.js";
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
import { ifDefined as y } from "lit/directives/if-defined.js";
|
|
6
|
+
import { observeThemeChange as C, prefersReducedMotion as k } from "../../theme-bridge.js";
|
|
7
|
+
const w = '@charset "UTF-8";:root,:host{--size-base-unit: .5rem}*,::slotted(*),*:before,*:after{box-sizing:border-box}html{scroll-padding-block-start:var(--ed-site-header-block-size, 0px)}h1,h2,h3,h4,h5,h6{margin:0}.ed-r-doughnut{display:block;container-type:inline-size;color:var(--ed-theme-color-content-default)}.ed-r-doughnut__canvas{position:relative;width:100%;min-width:0;height:20rem;margin-block-end:1.5rem}.ed-r-doughnut__canvas-el{display:block;max-width:100%}.ed-r-doughnut__details{margin-block-end:1rem;border:var(--ed-theme-border-width-sm) solid var(--ed-theme-color-border-subtle);border-radius:var(--ed-theme-border-radius-sm);background:var(--ed-theme-color-background-subtle)}.ed-r-doughnut__summary{padding:.5rem 1rem;cursor:pointer;font-weight:700;color:var(--ed-theme-color-content-default)}.ed-r-doughnut__table{width:100%;border-collapse:collapse;color:var(--ed-theme-color-content-default)}.ed-r-doughnut__caption{padding:.5rem 1rem;text-align:start;font-weight:700;caption-side:top}.ed-r-doughnut__th,.ed-r-doughnut__td{padding:.5rem 1rem;border-block-end:var(--ed-theme-border-width-sm) solid var(--ed-theme-color-border-subtle);text-align:start}.ed-r-doughnut__th{background:var(--ed-theme-color-background-subtle);font-weight:700}';
|
|
8
|
+
var F = Object.defineProperty, d = (l, t, a, e) => {
|
|
9
|
+
for (var r = void 0, h = l.length - 1, o; h >= 0; h--)
|
|
10
|
+
(o = l[h]) && (r = o(t, a, r) || r);
|
|
10
11
|
return r && F(t, a, r), r;
|
|
11
12
|
};
|
|
12
|
-
u.register(p, b, g,
|
|
13
|
+
u.register(p, b, g, v);
|
|
13
14
|
class s extends m {
|
|
14
15
|
constructor() {
|
|
15
16
|
super(...arguments), this.data = [], this.legendPosition = "bottom", this.chartLabel = "", this.dataTable = !0, this.valueFormat = (t) => t.toLocaleString(), this.labelFormat = (t) => t.label, this.theme = null;
|
|
16
17
|
}
|
|
17
18
|
static get styles() {
|
|
18
|
-
return
|
|
19
|
+
return _(w);
|
|
19
20
|
}
|
|
20
21
|
disconnectedCallback() {
|
|
21
22
|
super.disconnectedCallback(), this.unobserve?.(), this.chart?.destroy(), this.chart = void 0;
|
|
22
23
|
}
|
|
23
24
|
firstUpdated() {
|
|
24
|
-
this.canvas && (this.unobserve =
|
|
25
|
+
this.chartLabel || console.warn("[Eddie] <ed-r-doughnut> has no chartLabel, so its chart region has no accessible name."), this.canvas && (this.unobserve = C(this, (t) => {
|
|
25
26
|
this.theme = t, this.chart ? (this.chart.options = this.toChartJsOptions(), this.chart.data = this.toChartJsData(), this.chart.update()) : this.createChart();
|
|
26
27
|
}));
|
|
27
28
|
}
|
|
@@ -36,13 +37,13 @@ class s extends m {
|
|
|
36
37
|
}));
|
|
37
38
|
}
|
|
38
39
|
toChartJsData() {
|
|
39
|
-
const { palette: t, positive: a, negative: e, neutral: r } = this.theme,
|
|
40
|
+
const { palette: t, positive: a, negative: e, neutral: r } = this.theme, h = this.data.map((o, c) => o.semantic === "positive" ? a : o.semantic === "negative" ? e : o.semantic === "neutral" ? r : t[c % t.length]);
|
|
40
41
|
return {
|
|
41
42
|
labels: this.data.map((o) => this.labelFormat(o)),
|
|
42
43
|
datasets: [
|
|
43
44
|
{
|
|
44
45
|
data: this.data.map((o) => o.value),
|
|
45
|
-
backgroundColor:
|
|
46
|
+
backgroundColor: h,
|
|
46
47
|
borderColor: this.theme.tooltipBg,
|
|
47
48
|
borderWidth: 2
|
|
48
49
|
}
|
|
@@ -54,7 +55,7 @@ class s extends m {
|
|
|
54
55
|
return {
|
|
55
56
|
responsive: !0,
|
|
56
57
|
maintainAspectRatio: !1,
|
|
57
|
-
animation:
|
|
58
|
+
animation: k() ? !1 : { duration: 400 },
|
|
58
59
|
plugins: {
|
|
59
60
|
legend: {
|
|
60
61
|
display: this.legendPosition !== "none",
|
|
@@ -81,7 +82,7 @@ class s extends m {
|
|
|
81
82
|
const t = this.componentClassNames("ed-r-doughnut", {});
|
|
82
83
|
return n`
|
|
83
84
|
<div class="${t}">
|
|
84
|
-
<div class="ed-r-doughnut__canvas" role="img" aria-label=${this.chartLabel}>
|
|
85
|
+
<div class="ed-r-doughnut__canvas" role="img" aria-label=${y(this.chartLabel || void 0)}>
|
|
85
86
|
<canvas class="ed-r-doughnut__canvas-el"></canvas>
|
|
86
87
|
</div>
|
|
87
88
|
<slot></slot>
|
|
@@ -121,13 +122,13 @@ d([
|
|
|
121
122
|
i({ attribute: !1 })
|
|
122
123
|
], s.prototype, "data");
|
|
123
124
|
d([
|
|
124
|
-
i({ reflect: !0
|
|
125
|
+
i({ reflect: !0 })
|
|
125
126
|
], s.prototype, "legendPosition");
|
|
126
127
|
d([
|
|
127
|
-
i(
|
|
128
|
+
i()
|
|
128
129
|
], s.prototype, "chartLabel");
|
|
129
130
|
d([
|
|
130
|
-
i({ type: Boolean
|
|
131
|
+
i({ type: Boolean })
|
|
131
132
|
], s.prototype, "dataTable");
|
|
132
133
|
d([
|
|
133
134
|
i({ attribute: !1 })
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { EdElement } from '@brad-frost-web/eddie-web-components/components/EdElement.js';
|
|
2
2
|
export interface LineChartDataset {
|
|
3
3
|
label: string;
|
|
4
|
-
values: number[];
|
|
4
|
+
values: (number | null)[];
|
|
5
5
|
dashed?: boolean;
|
|
6
6
|
}
|
|
7
7
|
export interface LineChartData {
|
|
@@ -33,13 +33,17 @@ export interface LineChartPaceLine {
|
|
|
33
33
|
* spurious implied continuity. Use `ed-r-bar-chart` instead.
|
|
34
34
|
* @dontuse For actual-vs-projected overlays — use `ed-r-projection` which
|
|
35
35
|
* enforces visual separation between the two phases.
|
|
36
|
-
* @a11y `chart-label` is required; announced as the
|
|
37
|
-
* name and becomes the caption of the data table.
|
|
36
|
+
* @a11y `chartLabel` (or `chart-label`) is required; it is announced as the
|
|
37
|
+
* chart region's accessible name and becomes the caption of the data table.
|
|
38
|
+
* Without it the region gets no `aria-label` and a console warning.
|
|
38
39
|
* @a11y Dashed datasets (`dashed: true`) are announced in the tooltip with
|
|
39
40
|
* the same label as solid datasets — the visual distinction does not
|
|
40
41
|
* currently reach the accessibility tree. Use a clear `label` field.
|
|
41
42
|
* @a11y The pace line, when enabled, appears as an additional row in the
|
|
42
43
|
* data table so screen-reader users see the same reference values.
|
|
44
|
+
* @a11y A `null` point is a visible gap on the canvas and an em dash in the
|
|
45
|
+
* data table, announced as "no data" — the text alternative never
|
|
46
|
+
* reads an unknown as `0` (#1324).
|
|
43
47
|
* @a11y Respects `prefers-reduced-motion`.
|
|
44
48
|
* @a11y Keyboard navigation across data points is not implemented yet —
|
|
45
49
|
* tracked on #658 as follow-up work.
|
|
@@ -52,7 +56,7 @@ export interface LineChartPaceLine {
|
|
|
52
56
|
* @related ed-table — the accessible data-table equivalent
|
|
53
57
|
* @related ed-r-stat-card — the latest figure, when the trend is not the story
|
|
54
58
|
*
|
|
55
|
-
* @content Lines for trends over a continuous axis. Keep to a few series; always supply `dataTable`.
|
|
59
|
+
* @content Lines for trends over a continuous axis. Keep to a few series; always supply `dataTable`. Write a point with no data as `null`, never `0`: the line breaks there and the table reads "no data", where a `0` draws flat along the axis and says "nothing happened". Reserve `0` for a measured zero.
|
|
56
60
|
*
|
|
57
61
|
* @state `showPaceLine` toggles a reference line. Tooltips on hover.
|
|
58
62
|
* @slot - Optional extended description rendered between the chart and the
|
|
@@ -71,13 +75,23 @@ export interface LineChartPaceLine {
|
|
|
71
75
|
* @notWhen only the latest figure matters — use `ed-r-stat-card`
|
|
72
76
|
*/
|
|
73
77
|
export declare class EdRLineChart extends EdElement {
|
|
74
|
-
/**
|
|
78
|
+
/**
|
|
79
|
+
* Time-series data — labels and one or more datasets. A `null` in a dataset's
|
|
80
|
+
* `values` is a point with no data: the line breaks there (`spanGaps` stays
|
|
81
|
+
* off) and the data table reads "no data". Use `0` only for a measured zero.
|
|
82
|
+
*/
|
|
75
83
|
data: LineChartData;
|
|
76
84
|
/** Optional pace-line overlay for target-tracking charts. */
|
|
77
85
|
showPaceLine?: LineChartPaceLine;
|
|
78
|
-
/**
|
|
86
|
+
/**
|
|
87
|
+
* Accessible label for the chart region (required for a11y). Write it as
|
|
88
|
+
* `chartLabel` or `chart-label`; both bind, like every multi-word Eddie prop.
|
|
89
|
+
*/
|
|
79
90
|
chartLabel: string;
|
|
80
|
-
/**
|
|
91
|
+
/**
|
|
92
|
+
* Render a toggle-able linked data table (default `true`). Write it as
|
|
93
|
+
* `dataTable` or `data-table`; both bind, like every multi-word Eddie prop.
|
|
94
|
+
*/
|
|
81
95
|
dataTable: boolean;
|
|
82
96
|
/** Formatter for numeric values — applied to ticks, tooltip, and data table. */
|
|
83
97
|
yFormat: (v: number) => string;
|
|
@@ -95,6 +109,12 @@ export declare class EdRLineChart extends EdElement {
|
|
|
95
109
|
private toChartJsOptions;
|
|
96
110
|
render(): import('lit-html').TemplateResult<1>;
|
|
97
111
|
private renderTable;
|
|
112
|
+
/**
|
|
113
|
+
* One data cell: the formatted value, or — for a point with no data — an em
|
|
114
|
+
* dash hidden from assistive tech beside the words "no data" hidden from
|
|
115
|
+
* sight, so the cell is never read as a number (#1324).
|
|
116
|
+
*/
|
|
117
|
+
private renderCell;
|
|
98
118
|
}
|
|
99
119
|
declare global {
|
|
100
120
|
interface HTMLElementTagNameMap {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"line-chart.d.ts","sourceRoot":"","sources":["../../../../../packages/eddie-charts/charts/common/line-chart/line-chart.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,8DAA8D,CAAC;
|
|
1
|
+
{"version":3,"file":"line-chart.d.ts","sourceRoot":"","sources":["../../../../../packages/eddie-charts/charts/common/line-chart/line-chart.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,8DAA8D,CAAC;AAmCzF,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,MAAM,CAAC;IAKd,MAAM,EAAE,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE,CAAC;IAE1B,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,QAAQ,EAAE,gBAAgB,EAAE,CAAC;CAC9B;AAID,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,MAAM,CAAC;IAIf,UAAU,EAAE,MAAM,CAAC;IAEnB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4DG;AACH,qBAAa,YAAa,SAAQ,SAAS;IACzC;;;;OAIG;IAEH,IAAI,EAAE,aAAa,CAAgC;IAEnD,6DAA6D;IAE7D,YAAY,CAAC,EAAE,iBAAiB,CAAC;IAEjC;;;OAGG;IAEH,UAAU,SAAM;IAEhB;;;OAGG;IAEH,SAAS,UAAQ;IAEjB,gFAAgF;IAEhF,OAAO,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,CAA6B;IAG3D,OAAO,CAAC,MAAM,CAAC,CAAoB;IAEnC,OAAO,CAAC,KAAK,CAAC,CAAQ;IACtB,OAAO,CAAC,KAAK,CAA2B;IACxC,OAAO,CAAC,SAAS,CAAC,CAAa;IAE/B,MAAM,KAAK,MAAM,4BAEhB;IAED,oBAAoB,IAAI,IAAI;IAO5B,YAAY,IAAI,IAAI;IAiBpB,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAS5C,OAAO,CAAC,WAAW;IASnB,OAAO,CAAC,UAAU;IAelB,OAAO,CAAC,aAAa;IAqCrB,OAAO,CAAC,gBAAgB;IA0CxB,MAAM;IAcN,OAAO,CAAC,WAAW;IA+BnB;;;;OAIG;IACH,OAAO,CAAC,UAAU;CAUnB;AAMD,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,iBAAiB,EAAE,YAAY,CAAC;KACjC;CACF"}
|
|
@@ -1,36 +1,38 @@
|
|
|
1
|
-
import { EdElement as
|
|
2
|
-
import { Chart as d, LineController as m, LineElement as u, PointElement as _, CategoryScale as
|
|
3
|
-
import { unsafeCSS as
|
|
4
|
-
import { property as h, query as
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
import { EdElement as b } from "@brad-frost-web/eddie-web-components/components/EdElement.js";
|
|
2
|
+
import { Chart as d, LineController as m, LineElement as u, PointElement as _, CategoryScale as f, LinearScale as g, Filler as v, Tooltip as C, Legend as y } from "chart.js";
|
|
3
|
+
import { unsafeCSS as w, html as o } from "lit";
|
|
4
|
+
import { property as h, query as k } from "lit/decorators.js";
|
|
5
|
+
import { ifDefined as L } from "lit/directives/if-defined.js";
|
|
6
|
+
import { observeThemeChange as $, prefersReducedMotion as x } from "../../theme-bridge.js";
|
|
7
|
+
import { formatPoint as P, isGap as F, NO_DATA as T } from "../../gaps.js";
|
|
8
|
+
const D = '@charset "UTF-8";:root,:host{--size-base-unit: .5rem}*,::slotted(*),*:before,*:after{box-sizing:border-box}html{scroll-padding-block-start:var(--ed-site-header-block-size, 0px)}h1,h2,h3,h4,h5,h6{margin:0}.ed-r-line-chart{display:block;container-type:inline-size;color:var(--ed-theme-color-content-default)}.ed-r-line-chart__canvas{position:relative;width:100%;min-width:0;height:20rem;margin-block-end:1.5rem}.ed-r-line-chart__canvas-el{display:block;max-width:100%}.ed-r-line-chart__details{margin-block-end:1rem;border:var(--ed-theme-border-width-sm) solid var(--ed-theme-color-border-subtle);border-radius:var(--ed-theme-border-radius-sm);background:var(--ed-theme-color-background-subtle)}.ed-r-line-chart__summary{padding:.5rem 1rem;cursor:pointer;font-weight:700;color:var(--ed-theme-color-content-default)}.ed-r-line-chart__table{width:100%;border-collapse:collapse;color:var(--ed-theme-color-content-default)}.ed-r-line-chart__caption{padding:.5rem 1rem;text-align:start;font-weight:700;caption-side:top}.ed-r-line-chart__th,.ed-r-line-chart__td{padding:.5rem 1rem;border-block-end:var(--ed-theme-border-width-sm) solid var(--ed-theme-color-border-subtle);text-align:start}.ed-r-line-chart__th{background:var(--ed-theme-color-background-subtle);font-weight:700}.ed-r-line-chart__gap-label{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0 0 0 0);clip-path:inset(50%);white-space:nowrap;border:0}';
|
|
9
|
+
var E = Object.defineProperty, n = (c, t, e, a) => {
|
|
10
|
+
for (var r = void 0, s = c.length - 1, l; s >= 0; s--)
|
|
11
|
+
(l = c[s]) && (r = l(t, e, r) || r);
|
|
12
|
+
return r && E(t, e, r), r;
|
|
11
13
|
};
|
|
12
14
|
d.register(
|
|
13
15
|
m,
|
|
14
16
|
u,
|
|
15
17
|
_,
|
|
16
|
-
v,
|
|
17
18
|
f,
|
|
18
19
|
g,
|
|
20
|
+
v,
|
|
19
21
|
C,
|
|
20
22
|
y
|
|
21
23
|
);
|
|
22
|
-
class i extends
|
|
24
|
+
class i extends b {
|
|
23
25
|
constructor() {
|
|
24
26
|
super(...arguments), this.data = { labels: [], datasets: [] }, this.chartLabel = "", this.dataTable = !0, this.yFormat = (t) => t.toLocaleString(), this.theme = null;
|
|
25
27
|
}
|
|
26
28
|
static get styles() {
|
|
27
|
-
return
|
|
29
|
+
return w(D);
|
|
28
30
|
}
|
|
29
31
|
disconnectedCallback() {
|
|
30
32
|
super.disconnectedCallback(), this.unobserve?.(), this.chart?.destroy(), this.chart = void 0;
|
|
31
33
|
}
|
|
32
34
|
firstUpdated() {
|
|
33
|
-
this.canvas && (this.unobserve =
|
|
35
|
+
this.chartLabel || console.warn("[Eddie] <ed-r-line-chart> has no chartLabel, so its chart region has no accessible name."), this.canvas && (this.unobserve = $(this, (t) => {
|
|
34
36
|
this.theme = t, this.chart ? (this.chart.data = this.toChartJsData(), this.chart.options = this.toChartJsOptions(), this.chart.update()) : this.createChart();
|
|
35
37
|
}));
|
|
36
38
|
}
|
|
@@ -56,17 +58,19 @@ class i extends p {
|
|
|
56
58
|
}
|
|
57
59
|
toChartJsData() {
|
|
58
60
|
const { palette: t } = this.theme, e = this.data.datasets.map((r, s) => {
|
|
59
|
-
const
|
|
61
|
+
const l = t[s % t.length];
|
|
60
62
|
return {
|
|
61
63
|
label: r.label,
|
|
62
64
|
data: r.values,
|
|
63
|
-
borderColor:
|
|
64
|
-
backgroundColor:
|
|
65
|
+
borderColor: l,
|
|
66
|
+
backgroundColor: l,
|
|
65
67
|
borderDash: r.dashed ? [6, 4] : void 0,
|
|
66
68
|
tension: 0.25,
|
|
67
69
|
pointRadius: 3,
|
|
68
70
|
pointHoverRadius: 5,
|
|
69
|
-
fill: !1
|
|
71
|
+
fill: !1,
|
|
72
|
+
// Never bridge a gap — a null point must stay visible as missing (#1324).
|
|
73
|
+
spanGaps: !1
|
|
70
74
|
};
|
|
71
75
|
}), a = this.paceValues();
|
|
72
76
|
return a && e.push({
|
|
@@ -86,7 +90,7 @@ class i extends p {
|
|
|
86
90
|
return {
|
|
87
91
|
responsive: !0,
|
|
88
92
|
maintainAspectRatio: !1,
|
|
89
|
-
animation:
|
|
93
|
+
animation: x() ? !1 : { duration: 400 },
|
|
90
94
|
interaction: { mode: "index", intersect: !1 },
|
|
91
95
|
plugins: {
|
|
92
96
|
legend: {
|
|
@@ -100,7 +104,9 @@ class i extends p {
|
|
|
100
104
|
borderColor: t.tooltipBorder,
|
|
101
105
|
borderWidth: 1,
|
|
102
106
|
callbacks: {
|
|
103
|
-
|
|
107
|
+
// A null point is excluded from index-mode tooltips, but the
|
|
108
|
+
// callback must still never turn one into `fmt(Number(null))` = 0.
|
|
109
|
+
label: (a) => `${a.dataset.label}: ${P(a.parsed.y, e)}`
|
|
104
110
|
}
|
|
105
111
|
}
|
|
106
112
|
},
|
|
@@ -120,9 +126,9 @@ class i extends p {
|
|
|
120
126
|
}
|
|
121
127
|
render() {
|
|
122
128
|
const t = this.componentClassNames("ed-r-line-chart", {});
|
|
123
|
-
return
|
|
129
|
+
return o`
|
|
124
130
|
<div class="${t}">
|
|
125
|
-
<div class="ed-r-line-chart__canvas" role="img" aria-label=${this.chartLabel}>
|
|
131
|
+
<div class="ed-r-line-chart__canvas" role="img" aria-label=${L(this.chartLabel || void 0)}>
|
|
126
132
|
<canvas class="ed-r-line-chart__canvas-el"></canvas>
|
|
127
133
|
</div>
|
|
128
134
|
<slot></slot>
|
|
@@ -132,7 +138,7 @@ class i extends p {
|
|
|
132
138
|
}
|
|
133
139
|
renderTable() {
|
|
134
140
|
const { labels: t, datasets: e } = this.data, a = this.paceValues(), r = this.showPaceLine?.label ?? "Pace";
|
|
135
|
-
return
|
|
141
|
+
return o`
|
|
136
142
|
<details class="ed-r-line-chart__details">
|
|
137
143
|
<summary class="ed-r-line-chart__summary">View data table</summary>
|
|
138
144
|
<table class="ed-r-line-chart__table">
|
|
@@ -140,16 +146,16 @@ class i extends p {
|
|
|
140
146
|
<thead class="ed-r-line-chart__thead">
|
|
141
147
|
<tr class="ed-r-line-chart__row">
|
|
142
148
|
<th scope="col" class="ed-r-line-chart__th">Point</th>
|
|
143
|
-
${e.map((s) =>
|
|
144
|
-
${a ?
|
|
149
|
+
${e.map((s) => o`<th scope="col" class="ed-r-line-chart__th">${s.label}</th>`)}
|
|
150
|
+
${a ? o`<th scope="col" class="ed-r-line-chart__th">${r}</th>` : null}
|
|
145
151
|
</tr>
|
|
146
152
|
</thead>
|
|
147
153
|
<tbody class="ed-r-line-chart__tbody">
|
|
148
|
-
${t.map((s,
|
|
154
|
+
${t.map((s, l) => o`
|
|
149
155
|
<tr class="ed-r-line-chart__row">
|
|
150
156
|
<th scope="row" class="ed-r-line-chart__th">${s}</th>
|
|
151
|
-
${e.map((
|
|
152
|
-
${a ?
|
|
157
|
+
${e.map((p) => this.renderCell(p.values[l]))}
|
|
158
|
+
${a ? o`<td class="ed-r-line-chart__td">${this.yFormat(a[l])}</td>` : null}
|
|
153
159
|
</tr>
|
|
154
160
|
`)}
|
|
155
161
|
</tbody>
|
|
@@ -157,6 +163,18 @@ class i extends p {
|
|
|
157
163
|
</details>
|
|
158
164
|
`;
|
|
159
165
|
}
|
|
166
|
+
/**
|
|
167
|
+
* One data cell: the formatted value, or — for a point with no data — an em
|
|
168
|
+
* dash hidden from assistive tech beside the words "no data" hidden from
|
|
169
|
+
* sight, so the cell is never read as a number (#1324).
|
|
170
|
+
*/
|
|
171
|
+
renderCell(t) {
|
|
172
|
+
if (F(t)) {
|
|
173
|
+
const e = o`<span class="ed-r-line-chart__gap-glyph" aria-hidden="true">—</span>`, a = o`<span class="ed-r-line-chart__gap-label">${T}</span>`;
|
|
174
|
+
return o`<td class="ed-r-line-chart__td">${e}${a}</td>`;
|
|
175
|
+
}
|
|
176
|
+
return o`<td class="ed-r-line-chart__td">${this.yFormat(t)}</td>`;
|
|
177
|
+
}
|
|
160
178
|
}
|
|
161
179
|
n([
|
|
162
180
|
h({ attribute: !1 })
|
|
@@ -165,16 +183,16 @@ n([
|
|
|
165
183
|
h({ attribute: !1 })
|
|
166
184
|
], i.prototype, "showPaceLine");
|
|
167
185
|
n([
|
|
168
|
-
h(
|
|
186
|
+
h()
|
|
169
187
|
], i.prototype, "chartLabel");
|
|
170
188
|
n([
|
|
171
|
-
h({ type: Boolean
|
|
189
|
+
h({ type: Boolean })
|
|
172
190
|
], i.prototype, "dataTable");
|
|
173
191
|
n([
|
|
174
192
|
h({ attribute: !1 })
|
|
175
193
|
], i.prototype, "yFormat");
|
|
176
194
|
n([
|
|
177
|
-
|
|
195
|
+
k("canvas")
|
|
178
196
|
], i.prototype, "canvas");
|
|
179
197
|
customElements.get("ed-r-line-chart") === void 0 && customElements.define("ed-r-line-chart", i);
|
|
180
198
|
export {
|
|
@@ -21,8 +21,9 @@ import { EdElement } from '@brad-frost-web/eddie-web-components/components/EdEle
|
|
|
21
21
|
* @dontuse When there are multiple actual series — this recipe models one
|
|
22
22
|
* actual + one projection. For multi-series forecasts, build on
|
|
23
23
|
* `ed-r-line-chart` with `dashed: true` and a legend note.
|
|
24
|
-
* @a11y `chart-label` is required; announced as the
|
|
25
|
-
* accessible name and becomes the caption of the data table.
|
|
24
|
+
* @a11y `chartLabel` (or `chart-label`) is required; it is announced as the
|
|
25
|
+
* chart region's accessible name and becomes the caption of the data table.
|
|
26
|
+
* Without it the region gets no `aria-label` and a console warning.
|
|
26
27
|
* @a11y The data table's third column labels each row as `actual` or
|
|
27
28
|
* `projected`, so screen-reader users get the visual distinction
|
|
28
29
|
* as structured text, not just via dash pattern or opacity.
|
|
@@ -64,11 +65,20 @@ export declare class EdRProjection extends EdElement {
|
|
|
64
65
|
actual: (number | null)[];
|
|
65
66
|
/** Projected (future) values; `null` marks past points where projection is not applicable. */
|
|
66
67
|
projected: (number | null)[];
|
|
67
|
-
/**
|
|
68
|
+
/**
|
|
69
|
+
* Label for the vertical rule at the actual-to-projected boundary. Write it as
|
|
70
|
+
* `cutoffLabel` or `cutoff-label`; both bind, like every multi-word Eddie prop.
|
|
71
|
+
*/
|
|
68
72
|
cutoffLabel: string;
|
|
69
|
-
/**
|
|
73
|
+
/**
|
|
74
|
+
* Accessible label for the chart region (required for a11y). Write it as
|
|
75
|
+
* `chartLabel` or `chart-label`; both bind, like every multi-word Eddie prop.
|
|
76
|
+
*/
|
|
70
77
|
chartLabel: string;
|
|
71
|
-
/**
|
|
78
|
+
/**
|
|
79
|
+
* Render a toggle-able linked data table (default `true`). Write it as
|
|
80
|
+
* `dataTable` or `data-table`; both bind, like every multi-word Eddie prop.
|
|
81
|
+
*/
|
|
72
82
|
dataTable: boolean;
|
|
73
83
|
/** Formatter for numeric values — applied to ticks, tooltip, and data table. */
|
|
74
84
|
yFormat: (v: number) => string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"projection.d.ts","sourceRoot":"","sources":["../../../../../packages/eddie-charts/charts/common/projection/projection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,8DAA8D,CAAC;
|
|
1
|
+
{"version":3,"file":"projection.d.ts","sourceRoot":"","sources":["../../../../../packages/eddie-charts/charts/common/projection/projection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,8DAA8D,CAAC;AAgCzF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0DG;AACH,qBAAa,aAAc,SAAQ,SAAS;IAC1C,wDAAwD;IAExD,MAAM,EAAE,MAAM,EAAE,CAAM;IAEtB,0EAA0E;IAE1E,MAAM,EAAE,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE,CAAM;IAE/B,8FAA8F;IAE9F,SAAS,EAAE,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE,CAAM;IAElC;;;OAGG;IAEH,WAAW,SAAe;IAE1B;;;OAGG;IAEH,UAAU,SAAM;IAEhB;;;OAGG;IAEH,SAAS,UAAQ;IAEjB,gFAAgF;IAEhF,OAAO,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,CAA6B;IAG3D,OAAO,CAAC,MAAM,CAAC,CAAoB;IAEnC,OAAO,CAAC,KAAK,CAAC,CAAQ;IACtB,OAAO,CAAC,KAAK,CAA2B;IACxC,OAAO,CAAC,SAAS,CAAC,CAAa;IAE/B,MAAM,KAAK,MAAM,4BAEhB;IAED,oBAAoB,IAAI,IAAI;IAO5B,YAAY,IAAI,IAAI;IAiBpB,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAe5C,+DAA+D;IAC/D,OAAO,CAAC,WAAW;IAQnB,OAAO,CAAC,WAAW;IAUnB,OAAO,CAAC,aAAa;IAkCrB,OAAO,CAAC,gBAAgB;IA0CxB;;;OAGG;IACH,OAAO,CAAC,gBAAgB;IAiCxB,iEAAiE;IACjE,OAAO,CAAC,SAAS;IA0BjB,MAAM;IAcN,OAAO,CAAC,WAAW;CA0CpB;AAMD,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,iBAAiB,EAAE,aAAa,CAAC;KAClC;CACF"}
|
|
@@ -2,12 +2,13 @@ import { EdElement as m } from "@brad-frost-web/eddie-web-components/components/
|
|
|
2
2
|
import { Chart as u, LineController as f, LineElement as _, PointElement as g, CategoryScale as v, LinearScale as j, Tooltip as C, Legend as y } from "chart.js";
|
|
3
3
|
import { unsafeCSS as k, html as p } from "lit";
|
|
4
4
|
import { property as c, query as x } from "lit/decorators.js";
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
import { ifDefined as w } from "lit/directives/if-defined.js";
|
|
6
|
+
import { observeThemeChange as L, prefersReducedMotion as $ } from "../../theme-bridge.js";
|
|
7
|
+
const P = '@charset "UTF-8";:root,:host{--size-base-unit: .5rem}*,::slotted(*),*:before,*:after{box-sizing:border-box}html{scroll-padding-block-start:var(--ed-site-header-block-size, 0px)}h1,h2,h3,h4,h5,h6{margin:0}.ed-r-projection{display:block;container-type:inline-size;color:var(--ed-theme-color-content-default)}.ed-r-projection__canvas{position:relative;width:100%;min-width:0;height:20rem;margin-block-end:1.5rem}.ed-r-projection__canvas-el{display:block;max-width:100%}.ed-r-projection__details{margin-block-end:1rem;border:var(--ed-theme-border-width-sm) solid var(--ed-theme-color-border-subtle);border-radius:var(--ed-theme-border-radius-sm);background:var(--ed-theme-color-background-subtle)}.ed-r-projection__summary{padding:.5rem 1rem;cursor:pointer;font-weight:700;color:var(--ed-theme-color-content-default)}.ed-r-projection__table{width:100%;border-collapse:collapse;color:var(--ed-theme-color-content-default)}.ed-r-projection__caption{padding:.5rem 1rem;text-align:start;font-weight:700;caption-side:top}.ed-r-projection__th,.ed-r-projection__td{padding:.5rem 1rem;border-block-end:var(--ed-theme-border-width-sm) solid var(--ed-theme-color-border-subtle);text-align:start}.ed-r-projection__th{background:var(--ed-theme-color-background-subtle);font-weight:700}';
|
|
8
|
+
var N = Object.defineProperty, n = (d, t, r, o) => {
|
|
8
9
|
for (var e = void 0, a = d.length - 1, s; a >= 0; a--)
|
|
9
|
-
(s = d[a]) && (e = s(t,
|
|
10
|
-
return e &&
|
|
10
|
+
(s = d[a]) && (e = s(t, r, e) || e);
|
|
11
|
+
return e && N(t, r, e), e;
|
|
11
12
|
};
|
|
12
13
|
u.register(
|
|
13
14
|
f,
|
|
@@ -23,13 +24,13 @@ class i extends m {
|
|
|
23
24
|
super(...arguments), this.labels = [], this.actual = [], this.projected = [], this.cutoffLabel = "Projected", this.chartLabel = "", this.dataTable = !0, this.yFormat = (t) => t.toLocaleString(), this.theme = null;
|
|
24
25
|
}
|
|
25
26
|
static get styles() {
|
|
26
|
-
return k(
|
|
27
|
+
return k(P);
|
|
27
28
|
}
|
|
28
29
|
disconnectedCallback() {
|
|
29
30
|
super.disconnectedCallback(), this.unobserve?.(), this.chart?.destroy(), this.chart = void 0;
|
|
30
31
|
}
|
|
31
32
|
firstUpdated() {
|
|
32
|
-
this.canvas && (this.unobserve =
|
|
33
|
+
this.chartLabel || console.warn("[Eddie] <ed-r-projection> has no chartLabel, so its chart region has no accessible name."), this.canvas && (this.unobserve = L(this, (t) => {
|
|
33
34
|
this.theme = t, this.chart ? (this.chart.data = this.toChartJsData(), this.chart.options = this.toChartJsOptions(), this.chart.update()) : this.createChart();
|
|
34
35
|
}));
|
|
35
36
|
}
|
|
@@ -51,15 +52,15 @@ class i extends m {
|
|
|
51
52
|
}));
|
|
52
53
|
}
|
|
53
54
|
toChartJsData() {
|
|
54
|
-
const { palette: t } = this.theme,
|
|
55
|
+
const { palette: t } = this.theme, r = t[0];
|
|
55
56
|
return {
|
|
56
57
|
labels: this.labels,
|
|
57
58
|
datasets: [
|
|
58
59
|
{
|
|
59
60
|
label: "Actual",
|
|
60
|
-
data: this.actual.map((
|
|
61
|
-
borderColor:
|
|
62
|
-
backgroundColor:
|
|
61
|
+
data: this.actual.map((o) => o === null ? NaN : o),
|
|
62
|
+
borderColor: r,
|
|
63
|
+
backgroundColor: r,
|
|
63
64
|
tension: 0.25,
|
|
64
65
|
pointRadius: 3,
|
|
65
66
|
pointHoverRadius: 5,
|
|
@@ -68,9 +69,9 @@ class i extends m {
|
|
|
68
69
|
},
|
|
69
70
|
{
|
|
70
71
|
label: "Projected",
|
|
71
|
-
data: this.projected.map((
|
|
72
|
-
borderColor: this.withAlpha(
|
|
73
|
-
backgroundColor: this.withAlpha(
|
|
72
|
+
data: this.projected.map((o) => o === null ? NaN : o),
|
|
73
|
+
borderColor: this.withAlpha(r, 0.55),
|
|
74
|
+
backgroundColor: this.withAlpha(r, 0.55),
|
|
74
75
|
borderDash: [6, 4],
|
|
75
76
|
tension: 0.25,
|
|
76
77
|
pointRadius: 3,
|
|
@@ -82,7 +83,7 @@ class i extends m {
|
|
|
82
83
|
};
|
|
83
84
|
}
|
|
84
85
|
toChartJsOptions() {
|
|
85
|
-
const t = this.theme,
|
|
86
|
+
const t = this.theme, r = this.yFormat;
|
|
86
87
|
return {
|
|
87
88
|
responsive: !0,
|
|
88
89
|
maintainAspectRatio: !1,
|
|
@@ -97,9 +98,9 @@ class i extends m {
|
|
|
97
98
|
borderColor: t.tooltipBorder,
|
|
98
99
|
borderWidth: 1,
|
|
99
100
|
callbacks: {
|
|
100
|
-
label: (
|
|
101
|
-
const e = Number(
|
|
102
|
-
return Number.isNaN(e) ? "" : `${
|
|
101
|
+
label: (o) => {
|
|
102
|
+
const e = Number(o.parsed.y);
|
|
103
|
+
return Number.isNaN(e) ? "" : `${o.dataset.label}: ${r(e)}`;
|
|
103
104
|
}
|
|
104
105
|
}
|
|
105
106
|
}
|
|
@@ -111,7 +112,7 @@ class i extends m {
|
|
|
111
112
|
border: { color: t.axisColor }
|
|
112
113
|
},
|
|
113
114
|
y: {
|
|
114
|
-
ticks: { color: t.tickColor, callback: (
|
|
115
|
+
ticks: { color: t.tickColor, callback: (o) => r(Number(o)) },
|
|
115
116
|
grid: { color: t.gridlineColor },
|
|
116
117
|
border: { color: t.axisColor }
|
|
117
118
|
}
|
|
@@ -126,12 +127,12 @@ class i extends m {
|
|
|
126
127
|
const t = this.theme;
|
|
127
128
|
return {
|
|
128
129
|
id: "ed-r-projection-cutoff",
|
|
129
|
-
afterDatasetsDraw: (
|
|
130
|
-
const
|
|
131
|
-
if (
|
|
132
|
-
const { ctx: e, chartArea: a, scales: s } =
|
|
130
|
+
afterDatasetsDraw: (r) => {
|
|
131
|
+
const o = this.cutoffIndex();
|
|
132
|
+
if (o < 0 || o >= this.labels.length - 1) return;
|
|
133
|
+
const { ctx: e, chartArea: a, scales: s } = r, l = s.x;
|
|
133
134
|
if (!l) return;
|
|
134
|
-
const h = l.getPixelForValue(
|
|
135
|
+
const h = l.getPixelForValue(o);
|
|
135
136
|
e.save(), e.strokeStyle = t.axisColor, e.setLineDash([4, 4]), e.lineWidth = 1, e.beginPath(), e.moveTo(h, a.top), e.lineTo(h, a.bottom), e.stroke(), e.setLineDash([]);
|
|
136
137
|
const b = (h + a.right) / 2;
|
|
137
138
|
e.font = "12px sans-serif", e.fillStyle = t.tickColor, e.textAlign = "center", e.textBaseline = "top", e.fillText(this.cutoffLabel, b, a.top + 4), e.restore();
|
|
@@ -139,20 +140,20 @@ class i extends m {
|
|
|
139
140
|
};
|
|
140
141
|
}
|
|
141
142
|
/** Convert a hex or rgb color to rgba() with the given alpha. */
|
|
142
|
-
withAlpha(t,
|
|
143
|
-
const
|
|
144
|
-
if (
|
|
143
|
+
withAlpha(t, r) {
|
|
144
|
+
const o = t.trim();
|
|
145
|
+
if (o.startsWith("#") && (o.length === 7 || o.length === 4)) {
|
|
145
146
|
let a, s, l;
|
|
146
|
-
return
|
|
147
|
+
return o.length === 4 ? (a = parseInt(o[1] + o[1], 16), s = parseInt(o[2] + o[2], 16), l = parseInt(o[3] + o[3], 16)) : (a = parseInt(o.slice(1, 3), 16), s = parseInt(o.slice(3, 5), 16), l = parseInt(o.slice(5, 7), 16)), `rgba(${a}, ${s}, ${l}, ${r})`;
|
|
147
148
|
}
|
|
148
|
-
const e =
|
|
149
|
-
return e ? `rgba(${e[1]}, ${e[2]}, ${e[3]}, ${
|
|
149
|
+
const e = o.match(/^rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/);
|
|
150
|
+
return e ? `rgba(${e[1]}, ${e[2]}, ${e[3]}, ${r})` : o;
|
|
150
151
|
}
|
|
151
152
|
render() {
|
|
152
153
|
const t = this.componentClassNames("ed-r-projection", {});
|
|
153
154
|
return p`
|
|
154
155
|
<div class="${t}">
|
|
155
|
-
<div class="ed-r-projection__canvas" role="img" aria-label=${this.chartLabel}>
|
|
156
|
+
<div class="ed-r-projection__canvas" role="img" aria-label=${w(this.chartLabel || void 0)}>
|
|
156
157
|
<canvas class="ed-r-projection__canvas-el"></canvas>
|
|
157
158
|
</div>
|
|
158
159
|
<slot></slot>
|
|
@@ -177,11 +178,11 @@ class i extends m {
|
|
|
177
178
|
</tr>
|
|
178
179
|
</thead>
|
|
179
180
|
<tbody class="ed-r-projection__tbody">
|
|
180
|
-
${this.labels.map((
|
|
181
|
-
const e = this.actual[
|
|
181
|
+
${this.labels.map((r, o) => {
|
|
182
|
+
const e = this.actual[o], a = this.projected[o], s = e ?? a, l = e != null ? "Actual" : o > t ? this.cutoffLabel : "—";
|
|
182
183
|
return p`
|
|
183
184
|
<tr class="ed-r-projection__row">
|
|
184
|
-
<th scope="row" class="ed-r-projection__th">${
|
|
185
|
+
<th scope="row" class="ed-r-projection__th">${r}</th>
|
|
185
186
|
<td class="ed-r-projection__td">
|
|
186
187
|
${s != null ? this.yFormat(s) : "—"}
|
|
187
188
|
</td>
|
|
@@ -205,13 +206,13 @@ n([
|
|
|
205
206
|
c({ attribute: !1 })
|
|
206
207
|
], i.prototype, "projected");
|
|
207
208
|
n([
|
|
208
|
-
c(
|
|
209
|
+
c()
|
|
209
210
|
], i.prototype, "cutoffLabel");
|
|
210
211
|
n([
|
|
211
|
-
c(
|
|
212
|
+
c()
|
|
212
213
|
], i.prototype, "chartLabel");
|
|
213
214
|
n([
|
|
214
|
-
c({ type: Boolean
|
|
215
|
+
c({ type: Boolean })
|
|
215
216
|
], i.prototype, "dataTable");
|
|
216
217
|
n([
|
|
217
218
|
c({ attribute: !1 })
|
package/charts/gaps.js
ADDED
package/charts/theme-bridge.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
function o(e, d, t) {
|
|
2
2
|
return getComputedStyle(e).getPropertyValue(d).trim() || t;
|
|
3
3
|
}
|
|
4
|
-
|
|
4
|
+
const i = 12;
|
|
5
|
+
function u(e) {
|
|
5
6
|
const d = getComputedStyle(e), t = [];
|
|
6
|
-
for (let r = 1; r <=
|
|
7
|
+
for (let r = 1; r <= i; r++) {
|
|
7
8
|
const n = d.getPropertyValue(`--ed-theme-color-background-viz-${r}`).trim();
|
|
8
9
|
n && t.push(n);
|
|
9
10
|
}
|
|
@@ -26,7 +27,7 @@ function i(e) {
|
|
|
26
27
|
}
|
|
27
28
|
function c(e) {
|
|
28
29
|
return {
|
|
29
|
-
palette:
|
|
30
|
+
palette: u(e),
|
|
30
31
|
axisColor: o(
|
|
31
32
|
e,
|
|
32
33
|
"--ed-theme-color-border-viz-axis",
|
|
@@ -55,7 +56,7 @@ function c(e) {
|
|
|
55
56
|
neutral: "#757575"
|
|
56
57
|
};
|
|
57
58
|
}
|
|
58
|
-
function
|
|
59
|
+
function a(e, d) {
|
|
59
60
|
d(c(e));
|
|
60
61
|
const t = new MutationObserver(() => d(c(e)));
|
|
61
62
|
return t.observe(document.documentElement, {
|
|
@@ -63,10 +64,10 @@ function u(e, d) {
|
|
|
63
64
|
attributeFilter: ["class", "data-theme"]
|
|
64
65
|
}), () => t.disconnect();
|
|
65
66
|
}
|
|
66
|
-
function
|
|
67
|
+
function l() {
|
|
67
68
|
return typeof window > "u" || !window.matchMedia ? !1 : window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
68
69
|
}
|
|
69
70
|
export {
|
|
70
|
-
|
|
71
|
-
|
|
71
|
+
a as observeThemeChange,
|
|
72
|
+
l as prefersReducedMotion
|
|
72
73
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@brad-frost-web/eddie-charts",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.72.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
"scripts": {
|
|
11
11
|
"build": "vite build",
|
|
12
12
|
"build:cdn": "vite build --config vite.config.cdn.ts",
|
|
13
|
+
"test": "vitest run --project unit",
|
|
13
14
|
"plop": "plop chart"
|
|
14
15
|
},
|
|
15
16
|
"dependencies": {
|
package/shared/gaps.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Missing data (#1324).
|
|
3
|
+
*
|
|
4
|
+
* A `null` in a dataset's `values` is a point with no data, as distinct from a
|
|
5
|
+
* measured `0`. Chart.js already draws it honestly — a gap in a line, no bar in
|
|
6
|
+
* a bar chart. These helpers keep the recipes' text surfaces (tooltip, data
|
|
7
|
+
* table) just as honest, so an unknown is never read out as `0`.
|
|
8
|
+
*/
|
|
9
|
+
/** The words a tooltip or table cell uses for a point with no data. */
|
|
10
|
+
export declare const NO_DATA = "no data";
|
|
11
|
+
/**
|
|
12
|
+
* `null` is the documented gap. `undefined` is a dataset shorter than its
|
|
13
|
+
* labels — the same absence, so it is treated the same way.
|
|
14
|
+
*/
|
|
15
|
+
export declare function isGap(value: unknown): value is null | undefined;
|
|
16
|
+
/** Format a value for a text surface, saying "no data" rather than coercing a gap to `0`. */
|
|
17
|
+
export declare function formatPoint(value: number | null | undefined, format: (v: number) => string): string;
|
|
18
|
+
//# sourceMappingURL=gaps.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gaps.d.ts","sourceRoot":"","sources":["../../../packages/eddie-charts/shared/gaps.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,uEAAuE;AACvE,eAAO,MAAM,OAAO,YAAY,CAAC;AAEjC;;;GAGG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,IAAI,GAAG,SAAS,CAE/D;AAED,6FAA6F;AAC7F,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAAE,MAAM,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,GAAG,MAAM,CAEnG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"theme-bridge.d.ts","sourceRoot":"","sources":["../../../packages/eddie-charts/shared/theme-bridge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;IACtB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;CACjB;
|
|
1
|
+
{"version":3,"file":"theme-bridge.d.ts","sourceRoot":"","sources":["../../../packages/eddie-charts/shared/theme-bridge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;IACtB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;CACjB;AAoDD,wBAAgB,cAAc,CAAC,EAAE,EAAE,WAAW,GAAG,UAAU,CAkB1D;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAChC,EAAE,EAAE,WAAW,EACf,EAAE,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,GAC9B,MAAM,IAAI,CASZ;AAED,wBAAgB,oBAAoB,IAAI,OAAO,CAI9C"}
|