@brad-frost-web/eddie-charts 0.48.0 → 0.49.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/package.json +1 -1
- package/cdn/charts/common/bar-chart/bar-chart.js +0 -164
- package/cdn/charts/common/doughnut/doughnut.js +0 -142
- package/cdn/charts/common/line-chart/line-chart.js +0 -180
- package/cdn/charts/common/projection/projection.js +0 -223
- package/cdn/chunks/chart-js.CauhgCYq.js +0 -8010
- package/cdn/chunks/lit.CdaoESnp.js +0 -537
- package/cdn/chunks/theme-bridge.B5tQ30cd.js +0 -197
- package/cdn/chunks/vendor.lY5z9hnC.js +0 -42
package/package.json
CHANGED
|
@@ -1,164 +0,0 @@
|
|
|
1
|
-
import { E as m, o as u, p as _ } from "../../../chunks/theme-bridge.B5tQ30cd.js";
|
|
2
|
-
import { C as p, B as v, a as g, b as C, L as f, p as y, c as k } from "../../../chunks/chart-js.CauhgCYq.js";
|
|
3
|
-
import { r as w, b as h, n as c, e as x } from "../../../chunks/lit.CdaoESnp.js";
|
|
4
|
-
const $ = '@charset "UTF-8";:root,:host{--size-base-unit: .5rem}*,::slotted(*),*:before,*:after{box-sizing:border-box}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}';
|
|
5
|
-
var F = Object.defineProperty, l = (d, t, e, s) => {
|
|
6
|
-
for (var r = void 0, o = d.length - 1, a; o >= 0; o--)
|
|
7
|
-
(a = d[o]) && (r = a(t, e, r) || r);
|
|
8
|
-
return r && F(t, e, r), r;
|
|
9
|
-
};
|
|
10
|
-
p.register(v, g, C, f, y, k);
|
|
11
|
-
class i extends m {
|
|
12
|
-
constructor() {
|
|
13
|
-
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;
|
|
14
|
-
}
|
|
15
|
-
static get styles() {
|
|
16
|
-
return w($);
|
|
17
|
-
}
|
|
18
|
-
disconnectedCallback() {
|
|
19
|
-
super.disconnectedCallback(), this.unobserve?.(), this.chart?.destroy(), this.chart = void 0;
|
|
20
|
-
}
|
|
21
|
-
firstUpdated() {
|
|
22
|
-
this.canvas && (this.unobserve = u(this, (t) => {
|
|
23
|
-
this.theme = t, this.chart ? (this.chart.options = this.toChartJsOptions(), this.chart.data = this.toChartJsData(), this.chart.update()) : this.createChart();
|
|
24
|
-
}));
|
|
25
|
-
}
|
|
26
|
-
updated(t) {
|
|
27
|
-
if (!this.chart || !this.theme) return;
|
|
28
|
-
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());
|
|
29
|
-
}
|
|
30
|
-
createChart() {
|
|
31
|
-
!this.canvas || !this.theme || (this.chart = new p(this.canvas, {
|
|
32
|
-
type: "bar",
|
|
33
|
-
data: this.toChartJsData(),
|
|
34
|
-
options: this.toChartJsOptions()
|
|
35
|
-
}));
|
|
36
|
-
}
|
|
37
|
-
toChartJsData() {
|
|
38
|
-
const { palette: t, positive: e, negative: s, neutral: r } = this.theme, o = (a) => {
|
|
39
|
-
if (a === "positive") return e;
|
|
40
|
-
if (a === "negative") return s;
|
|
41
|
-
if (a === "neutral") return r;
|
|
42
|
-
};
|
|
43
|
-
return {
|
|
44
|
-
labels: this.data.labels,
|
|
45
|
-
datasets: this.data.datasets.map((a, n) => {
|
|
46
|
-
const b = o(a.semantic) ?? t[n % t.length];
|
|
47
|
-
return {
|
|
48
|
-
label: a.label,
|
|
49
|
-
data: a.values,
|
|
50
|
-
backgroundColor: b,
|
|
51
|
-
borderColor: b,
|
|
52
|
-
borderWidth: 1
|
|
53
|
-
};
|
|
54
|
-
})
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
toChartJsOptions() {
|
|
58
|
-
const t = this.theme, e = this.yFormat, s = this.variant === "stacked", r = this.orientation === "horizontal", o = (a) => e(Number(a));
|
|
59
|
-
return {
|
|
60
|
-
indexAxis: r ? "y" : "x",
|
|
61
|
-
responsive: !0,
|
|
62
|
-
maintainAspectRatio: !1,
|
|
63
|
-
animation: _() ? !1 : { duration: 400 },
|
|
64
|
-
plugins: {
|
|
65
|
-
legend: {
|
|
66
|
-
display: this.data.datasets.length > 1,
|
|
67
|
-
labels: { color: t.labelColor }
|
|
68
|
-
},
|
|
69
|
-
tooltip: {
|
|
70
|
-
backgroundColor: t.tooltipBg,
|
|
71
|
-
titleColor: t.tooltipFg,
|
|
72
|
-
bodyColor: t.tooltipFg,
|
|
73
|
-
borderColor: t.tooltipBorder,
|
|
74
|
-
borderWidth: 1,
|
|
75
|
-
callbacks: {
|
|
76
|
-
label: (a) => {
|
|
77
|
-
const n = r ? a.parsed.x : a.parsed.y;
|
|
78
|
-
return `${a.dataset.label}: ${e(Number(n))}`;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
},
|
|
83
|
-
scales: {
|
|
84
|
-
x: {
|
|
85
|
-
stacked: s,
|
|
86
|
-
ticks: r ? { color: t.tickColor, callback: o } : { color: t.tickColor },
|
|
87
|
-
grid: { color: t.gridlineColor },
|
|
88
|
-
border: { color: t.axisColor }
|
|
89
|
-
},
|
|
90
|
-
y: {
|
|
91
|
-
stacked: s,
|
|
92
|
-
ticks: r ? { color: t.tickColor } : { color: t.tickColor, callback: o },
|
|
93
|
-
grid: { color: t.gridlineColor },
|
|
94
|
-
border: { color: t.axisColor }
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
render() {
|
|
100
|
-
const t = this.componentClassNames("ed-r-bar-chart", {
|
|
101
|
-
"ed-r-bar-chart--horizontal": this.orientation === "horizontal",
|
|
102
|
-
"ed-r-bar-chart--stacked": this.variant === "stacked"
|
|
103
|
-
});
|
|
104
|
-
return h`
|
|
105
|
-
<div class="${t}">
|
|
106
|
-
<div class="ed-r-bar-chart__canvas" role="img" aria-label=${this.chartLabel}>
|
|
107
|
-
<canvas class="ed-r-bar-chart__canvas-el"></canvas>
|
|
108
|
-
</div>
|
|
109
|
-
<slot></slot>
|
|
110
|
-
${this.dataTable ? this.renderTable() : null}
|
|
111
|
-
</div>
|
|
112
|
-
`;
|
|
113
|
-
}
|
|
114
|
-
renderTable() {
|
|
115
|
-
const { labels: t, datasets: e } = this.data;
|
|
116
|
-
return h`
|
|
117
|
-
<details class="ed-r-bar-chart__details">
|
|
118
|
-
<summary class="ed-r-bar-chart__summary">View data table</summary>
|
|
119
|
-
<table class="ed-r-bar-chart__table">
|
|
120
|
-
<caption class="ed-r-bar-chart__caption">${this.chartLabel}</caption>
|
|
121
|
-
<thead class="ed-r-bar-chart__thead">
|
|
122
|
-
<tr class="ed-r-bar-chart__row">
|
|
123
|
-
<th scope="col" class="ed-r-bar-chart__th">Category</th>
|
|
124
|
-
${e.map((s) => h`<th scope="col" class="ed-r-bar-chart__th">${s.label}</th>`)}
|
|
125
|
-
</tr>
|
|
126
|
-
</thead>
|
|
127
|
-
<tbody class="ed-r-bar-chart__tbody">
|
|
128
|
-
${t.map((s, r) => h`
|
|
129
|
-
<tr class="ed-r-bar-chart__row">
|
|
130
|
-
<th scope="row" class="ed-r-bar-chart__th">${s}</th>
|
|
131
|
-
${e.map((o) => h`<td class="ed-r-bar-chart__td">${this.yFormat(o.values[r])}</td>`)}
|
|
132
|
-
</tr>
|
|
133
|
-
`)}
|
|
134
|
-
</tbody>
|
|
135
|
-
</table>
|
|
136
|
-
</details>
|
|
137
|
-
`;
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
l([
|
|
141
|
-
c({ attribute: !1 })
|
|
142
|
-
], i.prototype, "data");
|
|
143
|
-
l([
|
|
144
|
-
c({ reflect: !0 })
|
|
145
|
-
], i.prototype, "orientation");
|
|
146
|
-
l([
|
|
147
|
-
c({ reflect: !0 })
|
|
148
|
-
], i.prototype, "variant");
|
|
149
|
-
l([
|
|
150
|
-
c({ attribute: "chart-label" })
|
|
151
|
-
], i.prototype, "chartLabel");
|
|
152
|
-
l([
|
|
153
|
-
c({ type: Boolean, attribute: "data-table" })
|
|
154
|
-
], i.prototype, "dataTable");
|
|
155
|
-
l([
|
|
156
|
-
c({ attribute: !1 })
|
|
157
|
-
], i.prototype, "yFormat");
|
|
158
|
-
l([
|
|
159
|
-
x("canvas")
|
|
160
|
-
], i.prototype, "canvas");
|
|
161
|
-
customElements.get("ed-r-bar-chart") === void 0 && customElements.define("ed-r-bar-chart", i);
|
|
162
|
-
export {
|
|
163
|
-
i as EdRBarChart
|
|
164
|
-
};
|
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
import { E as m, o as p, p as b } from "../../../chunks/theme-bridge.B5tQ30cd.js";
|
|
2
|
-
import { C as u, D as g, A as _, p as v, c as f } from "../../../chunks/chart-js.CauhgCYq.js";
|
|
3
|
-
import { r as C, b as n, n as i, e as y } from "../../../chunks/lit.CdaoESnp.js";
|
|
4
|
-
const F = '@charset "UTF-8";:root,:host{--size-base-unit: .5rem}*,::slotted(*),*:before,*:after{box-sizing:border-box}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}';
|
|
5
|
-
var k = Object.defineProperty, d = (h, t, a, e) => {
|
|
6
|
-
for (var r = void 0, l = h.length - 1, o; l >= 0; l--)
|
|
7
|
-
(o = h[l]) && (r = o(t, a, r) || r);
|
|
8
|
-
return r && k(t, a, r), r;
|
|
9
|
-
};
|
|
10
|
-
u.register(g, _, v, f);
|
|
11
|
-
class s extends m {
|
|
12
|
-
constructor() {
|
|
13
|
-
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;
|
|
14
|
-
}
|
|
15
|
-
static get styles() {
|
|
16
|
-
return C(F);
|
|
17
|
-
}
|
|
18
|
-
disconnectedCallback() {
|
|
19
|
-
super.disconnectedCallback(), this.unobserve?.(), this.chart?.destroy(), this.chart = void 0;
|
|
20
|
-
}
|
|
21
|
-
firstUpdated() {
|
|
22
|
-
this.canvas && (this.unobserve = p(this, (t) => {
|
|
23
|
-
this.theme = t, this.chart ? (this.chart.options = this.toChartJsOptions(), this.chart.data = this.toChartJsData(), this.chart.update()) : this.createChart();
|
|
24
|
-
}));
|
|
25
|
-
}
|
|
26
|
-
updated(t) {
|
|
27
|
-
!this.chart || !this.theme || (t.has("legendPosition") ? (this.chart.destroy(), this.chart = void 0, this.createChart()) : (t.has("data") || t.has("valueFormat") || t.has("labelFormat")) && (this.chart.data = this.toChartJsData(), this.chart.options = this.toChartJsOptions(), this.chart.update()));
|
|
28
|
-
}
|
|
29
|
-
createChart() {
|
|
30
|
-
!this.canvas || !this.theme || (this.chart = new u(this.canvas, {
|
|
31
|
-
type: "doughnut",
|
|
32
|
-
data: this.toChartJsData(),
|
|
33
|
-
options: this.toChartJsOptions()
|
|
34
|
-
}));
|
|
35
|
-
}
|
|
36
|
-
toChartJsData() {
|
|
37
|
-
const { palette: t, positive: a, negative: e, neutral: r } = this.theme, l = this.data.map((o, c) => o.semantic === "positive" ? a : o.semantic === "negative" ? e : o.semantic === "neutral" ? r : t[c % t.length]);
|
|
38
|
-
return {
|
|
39
|
-
labels: this.data.map((o) => this.labelFormat(o)),
|
|
40
|
-
datasets: [
|
|
41
|
-
{
|
|
42
|
-
data: this.data.map((o) => o.value),
|
|
43
|
-
backgroundColor: l,
|
|
44
|
-
borderColor: this.theme.tooltipBg,
|
|
45
|
-
borderWidth: 2
|
|
46
|
-
}
|
|
47
|
-
]
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
toChartJsOptions() {
|
|
51
|
-
const t = this.theme, a = this.valueFormat;
|
|
52
|
-
return {
|
|
53
|
-
responsive: !0,
|
|
54
|
-
maintainAspectRatio: !1,
|
|
55
|
-
animation: b() ? !1 : { duration: 400 },
|
|
56
|
-
plugins: {
|
|
57
|
-
legend: {
|
|
58
|
-
display: this.legendPosition !== "none",
|
|
59
|
-
position: this.legendPosition === "none" ? "bottom" : this.legendPosition,
|
|
60
|
-
labels: { color: t.labelColor }
|
|
61
|
-
},
|
|
62
|
-
tooltip: {
|
|
63
|
-
backgroundColor: t.tooltipBg,
|
|
64
|
-
titleColor: t.tooltipFg,
|
|
65
|
-
bodyColor: t.tooltipFg,
|
|
66
|
-
borderColor: t.tooltipBorder,
|
|
67
|
-
borderWidth: 1,
|
|
68
|
-
callbacks: {
|
|
69
|
-
label: (e) => `${e.label}: ${a(Number(e.parsed))}`
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
total() {
|
|
76
|
-
return this.data.reduce((t, a) => t + a.value, 0);
|
|
77
|
-
}
|
|
78
|
-
render() {
|
|
79
|
-
const t = this.componentClassNames("ed-r-doughnut", {});
|
|
80
|
-
return n`
|
|
81
|
-
<div class="${t}">
|
|
82
|
-
<div class="ed-r-doughnut__canvas" role="img" aria-label=${this.chartLabel}>
|
|
83
|
-
<canvas class="ed-r-doughnut__canvas-el"></canvas>
|
|
84
|
-
</div>
|
|
85
|
-
<slot></slot>
|
|
86
|
-
${this.dataTable ? this.renderTable() : null}
|
|
87
|
-
</div>
|
|
88
|
-
`;
|
|
89
|
-
}
|
|
90
|
-
renderTable() {
|
|
91
|
-
const t = this.total(), a = (e) => t === 0 ? "—" : `${(e / t * 100).toFixed(1)}%`;
|
|
92
|
-
return n`
|
|
93
|
-
<details class="ed-r-doughnut__details">
|
|
94
|
-
<summary class="ed-r-doughnut__summary">View data table</summary>
|
|
95
|
-
<table class="ed-r-doughnut__table">
|
|
96
|
-
<caption class="ed-r-doughnut__caption">${this.chartLabel}</caption>
|
|
97
|
-
<thead class="ed-r-doughnut__thead">
|
|
98
|
-
<tr class="ed-r-doughnut__row">
|
|
99
|
-
<th scope="col" class="ed-r-doughnut__th">Category</th>
|
|
100
|
-
<th scope="col" class="ed-r-doughnut__th">Value</th>
|
|
101
|
-
<th scope="col" class="ed-r-doughnut__th">Share</th>
|
|
102
|
-
</tr>
|
|
103
|
-
</thead>
|
|
104
|
-
<tbody class="ed-r-doughnut__tbody">
|
|
105
|
-
${this.data.map((e) => n`
|
|
106
|
-
<tr class="ed-r-doughnut__row">
|
|
107
|
-
<th scope="row" class="ed-r-doughnut__th">${this.labelFormat(e)}</th>
|
|
108
|
-
<td class="ed-r-doughnut__td">${this.valueFormat(e.value)}</td>
|
|
109
|
-
<td class="ed-r-doughnut__td">${a(e.value)}</td>
|
|
110
|
-
</tr>
|
|
111
|
-
`)}
|
|
112
|
-
</tbody>
|
|
113
|
-
</table>
|
|
114
|
-
</details>
|
|
115
|
-
`;
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
d([
|
|
119
|
-
i({ attribute: !1 })
|
|
120
|
-
], s.prototype, "data");
|
|
121
|
-
d([
|
|
122
|
-
i({ reflect: !0, attribute: "legend-position" })
|
|
123
|
-
], s.prototype, "legendPosition");
|
|
124
|
-
d([
|
|
125
|
-
i({ attribute: "chart-label" })
|
|
126
|
-
], s.prototype, "chartLabel");
|
|
127
|
-
d([
|
|
128
|
-
i({ type: Boolean, attribute: "data-table" })
|
|
129
|
-
], s.prototype, "dataTable");
|
|
130
|
-
d([
|
|
131
|
-
i({ attribute: !1 })
|
|
132
|
-
], s.prototype, "valueFormat");
|
|
133
|
-
d([
|
|
134
|
-
i({ attribute: !1 })
|
|
135
|
-
], s.prototype, "labelFormat");
|
|
136
|
-
d([
|
|
137
|
-
y("canvas")
|
|
138
|
-
], s.prototype, "canvas");
|
|
139
|
-
customElements.get("ed-r-doughnut") === void 0 && customElements.define("ed-r-doughnut", s);
|
|
140
|
-
export {
|
|
141
|
-
s as EdRDoughnut
|
|
142
|
-
};
|
|
@@ -1,180 +0,0 @@
|
|
|
1
|
-
import { E as p, o as m, p as u } from "../../../chunks/theme-bridge.B5tQ30cd.js";
|
|
2
|
-
import { C as d, d as _, e as g, P as v, b as f, L as C, i as y, p as k, c as w } from "../../../chunks/chart-js.CauhgCYq.js";
|
|
3
|
-
import { r as L, b as l, n as h, e as $ } from "../../../chunks/lit.CdaoESnp.js";
|
|
4
|
-
const P = '@charset "UTF-8";:root,:host{--size-base-unit: .5rem}*,::slotted(*),*:before,*:after{box-sizing:border-box}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}';
|
|
5
|
-
var x = Object.defineProperty, n = (c, t, e, a) => {
|
|
6
|
-
for (var r = void 0, s = c.length - 1, o; s >= 0; s--)
|
|
7
|
-
(o = c[s]) && (r = o(t, e, r) || r);
|
|
8
|
-
return r && x(t, e, r), r;
|
|
9
|
-
};
|
|
10
|
-
d.register(
|
|
11
|
-
_,
|
|
12
|
-
g,
|
|
13
|
-
v,
|
|
14
|
-
f,
|
|
15
|
-
C,
|
|
16
|
-
y,
|
|
17
|
-
k,
|
|
18
|
-
w
|
|
19
|
-
);
|
|
20
|
-
class i extends p {
|
|
21
|
-
constructor() {
|
|
22
|
-
super(...arguments), this.data = { labels: [], datasets: [] }, this.chartLabel = "", this.dataTable = !0, this.yFormat = (t) => t.toLocaleString(), this.theme = null;
|
|
23
|
-
}
|
|
24
|
-
static get styles() {
|
|
25
|
-
return L(P);
|
|
26
|
-
}
|
|
27
|
-
disconnectedCallback() {
|
|
28
|
-
super.disconnectedCallback(), this.unobserve?.(), this.chart?.destroy(), this.chart = void 0;
|
|
29
|
-
}
|
|
30
|
-
firstUpdated() {
|
|
31
|
-
this.canvas && (this.unobserve = m(this, (t) => {
|
|
32
|
-
this.theme = t, this.chart ? (this.chart.data = this.toChartJsData(), this.chart.options = this.toChartJsOptions(), this.chart.update()) : this.createChart();
|
|
33
|
-
}));
|
|
34
|
-
}
|
|
35
|
-
updated(t) {
|
|
36
|
-
!this.chart || !this.theme || (t.has("data") || t.has("showPaceLine") || t.has("yFormat")) && (this.chart.data = this.toChartJsData(), this.chart.options = this.toChartJsOptions(), this.chart.update());
|
|
37
|
-
}
|
|
38
|
-
createChart() {
|
|
39
|
-
!this.canvas || !this.theme || (this.chart = new d(this.canvas, {
|
|
40
|
-
type: "line",
|
|
41
|
-
data: this.toChartJsData(),
|
|
42
|
-
options: this.toChartJsOptions()
|
|
43
|
-
}));
|
|
44
|
-
}
|
|
45
|
-
paceValues() {
|
|
46
|
-
const t = this.showPaceLine;
|
|
47
|
-
if (!t) return null;
|
|
48
|
-
const e = this.data.labels.length;
|
|
49
|
-
if (e < 2 || t.completion <= 0) return null;
|
|
50
|
-
const a = t.target / t.completion;
|
|
51
|
-
return this.data.labels.map(
|
|
52
|
-
(r, s) => a * s / (e - 1)
|
|
53
|
-
);
|
|
54
|
-
}
|
|
55
|
-
toChartJsData() {
|
|
56
|
-
const { palette: t } = this.theme, e = this.data.datasets.map((r, s) => {
|
|
57
|
-
const o = t[s % t.length];
|
|
58
|
-
return {
|
|
59
|
-
label: r.label,
|
|
60
|
-
data: r.values,
|
|
61
|
-
borderColor: o,
|
|
62
|
-
backgroundColor: o,
|
|
63
|
-
borderDash: r.dashed ? [6, 4] : void 0,
|
|
64
|
-
tension: 0.25,
|
|
65
|
-
pointRadius: 3,
|
|
66
|
-
pointHoverRadius: 5,
|
|
67
|
-
fill: !1
|
|
68
|
-
};
|
|
69
|
-
}), a = this.paceValues();
|
|
70
|
-
return a && e.push({
|
|
71
|
-
label: this.showPaceLine.label ?? "Pace",
|
|
72
|
-
data: a,
|
|
73
|
-
borderColor: this.theme.neutral,
|
|
74
|
-
backgroundColor: this.theme.neutral,
|
|
75
|
-
borderDash: [2, 4],
|
|
76
|
-
tension: 0,
|
|
77
|
-
pointRadius: 0,
|
|
78
|
-
pointHoverRadius: 0,
|
|
79
|
-
fill: !1
|
|
80
|
-
}), { labels: this.data.labels, datasets: e };
|
|
81
|
-
}
|
|
82
|
-
toChartJsOptions() {
|
|
83
|
-
const t = this.theme, e = this.yFormat;
|
|
84
|
-
return {
|
|
85
|
-
responsive: !0,
|
|
86
|
-
maintainAspectRatio: !1,
|
|
87
|
-
animation: u() ? !1 : { duration: 400 },
|
|
88
|
-
interaction: { mode: "index", intersect: !1 },
|
|
89
|
-
plugins: {
|
|
90
|
-
legend: {
|
|
91
|
-
display: this.data.datasets.length > 1 || !!this.showPaceLine,
|
|
92
|
-
labels: { color: t.labelColor }
|
|
93
|
-
},
|
|
94
|
-
tooltip: {
|
|
95
|
-
backgroundColor: t.tooltipBg,
|
|
96
|
-
titleColor: t.tooltipFg,
|
|
97
|
-
bodyColor: t.tooltipFg,
|
|
98
|
-
borderColor: t.tooltipBorder,
|
|
99
|
-
borderWidth: 1,
|
|
100
|
-
callbacks: {
|
|
101
|
-
label: (a) => `${a.dataset.label}: ${e(Number(a.parsed.y))}`
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
},
|
|
105
|
-
scales: {
|
|
106
|
-
x: {
|
|
107
|
-
ticks: { color: t.tickColor },
|
|
108
|
-
grid: { color: t.gridlineColor },
|
|
109
|
-
border: { color: t.axisColor }
|
|
110
|
-
},
|
|
111
|
-
y: {
|
|
112
|
-
ticks: { color: t.tickColor, callback: (a) => e(Number(a)) },
|
|
113
|
-
grid: { color: t.gridlineColor },
|
|
114
|
-
border: { color: t.axisColor }
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
};
|
|
118
|
-
}
|
|
119
|
-
render() {
|
|
120
|
-
const t = this.componentClassNames("ed-r-line-chart", {});
|
|
121
|
-
return l`
|
|
122
|
-
<div class="${t}">
|
|
123
|
-
<div class="ed-r-line-chart__canvas" role="img" aria-label=${this.chartLabel}>
|
|
124
|
-
<canvas class="ed-r-line-chart__canvas-el"></canvas>
|
|
125
|
-
</div>
|
|
126
|
-
<slot></slot>
|
|
127
|
-
${this.dataTable ? this.renderTable() : null}
|
|
128
|
-
</div>
|
|
129
|
-
`;
|
|
130
|
-
}
|
|
131
|
-
renderTable() {
|
|
132
|
-
const { labels: t, datasets: e } = this.data, a = this.paceValues(), r = this.showPaceLine?.label ?? "Pace";
|
|
133
|
-
return l`
|
|
134
|
-
<details class="ed-r-line-chart__details">
|
|
135
|
-
<summary class="ed-r-line-chart__summary">View data table</summary>
|
|
136
|
-
<table class="ed-r-line-chart__table">
|
|
137
|
-
<caption class="ed-r-line-chart__caption">${this.chartLabel}</caption>
|
|
138
|
-
<thead class="ed-r-line-chart__thead">
|
|
139
|
-
<tr class="ed-r-line-chart__row">
|
|
140
|
-
<th scope="col" class="ed-r-line-chart__th">Point</th>
|
|
141
|
-
${e.map((s) => l`<th scope="col" class="ed-r-line-chart__th">${s.label}</th>`)}
|
|
142
|
-
${a ? l`<th scope="col" class="ed-r-line-chart__th">${r}</th>` : null}
|
|
143
|
-
</tr>
|
|
144
|
-
</thead>
|
|
145
|
-
<tbody class="ed-r-line-chart__tbody">
|
|
146
|
-
${t.map((s, o) => l`
|
|
147
|
-
<tr class="ed-r-line-chart__row">
|
|
148
|
-
<th scope="row" class="ed-r-line-chart__th">${s}</th>
|
|
149
|
-
${e.map((b) => l`<td class="ed-r-line-chart__td">${this.yFormat(b.values[o])}</td>`)}
|
|
150
|
-
${a ? l`<td class="ed-r-line-chart__td">${this.yFormat(a[o])}</td>` : null}
|
|
151
|
-
</tr>
|
|
152
|
-
`)}
|
|
153
|
-
</tbody>
|
|
154
|
-
</table>
|
|
155
|
-
</details>
|
|
156
|
-
`;
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
n([
|
|
160
|
-
h({ attribute: !1 })
|
|
161
|
-
], i.prototype, "data");
|
|
162
|
-
n([
|
|
163
|
-
h({ attribute: !1 })
|
|
164
|
-
], i.prototype, "showPaceLine");
|
|
165
|
-
n([
|
|
166
|
-
h({ attribute: "chart-label" })
|
|
167
|
-
], i.prototype, "chartLabel");
|
|
168
|
-
n([
|
|
169
|
-
h({ type: Boolean, attribute: "data-table" })
|
|
170
|
-
], i.prototype, "dataTable");
|
|
171
|
-
n([
|
|
172
|
-
h({ attribute: !1 })
|
|
173
|
-
], i.prototype, "yFormat");
|
|
174
|
-
n([
|
|
175
|
-
$("canvas")
|
|
176
|
-
], i.prototype, "canvas");
|
|
177
|
-
customElements.get("ed-r-line-chart") === void 0 && customElements.define("ed-r-line-chart", i);
|
|
178
|
-
export {
|
|
179
|
-
i as EdRLineChart
|
|
180
|
-
};
|