@aceshooting/lyra-ui 0.1.1 → 0.1.3
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/README.md +77 -6
- package/custom-elements.json +12015 -0
- package/dist/components/chart/bar-chart.d.ts +14 -0
- package/dist/components/chart/bar-chart.js +14 -0
- package/dist/components/chart/box-plot.d.ts +46 -0
- package/dist/components/chart/box-plot.js +145 -0
- package/dist/components/chart/box-plot.styles.d.ts +1 -0
- package/dist/components/chart/box-plot.styles.js +22 -0
- package/dist/components/chart/bubble-chart.d.ts +19 -0
- package/dist/components/chart/bubble-chart.js +18 -0
- package/dist/components/chart/chart-loader.d.ts +8 -0
- package/dist/components/chart/chart-loader.js +26 -0
- package/dist/components/chart/chart.d.ts +91 -0
- package/dist/components/chart/chart.js +275 -0
- package/dist/components/chart/chart.styles.d.ts +1 -0
- package/dist/components/chart/chart.styles.js +33 -0
- package/dist/components/chart/doughnut-chart.d.ts +15 -0
- package/dist/components/chart/doughnut-chart.js +14 -0
- package/dist/components/chart/histogram-bin.d.ts +6 -0
- package/dist/components/chart/histogram-bin.js +19 -0
- package/dist/components/chart/histogram.d.ts +20 -0
- package/dist/components/chart/histogram.js +70 -0
- package/dist/components/chart/histogram.styles.d.ts +1 -0
- package/dist/components/chart/histogram.styles.js +1 -0
- package/dist/components/chart/line-chart.d.ts +14 -0
- package/dist/components/chart/line-chart.js +14 -0
- package/dist/components/chart/pie-chart.d.ts +16 -0
- package/dist/components/chart/pie-chart.js +15 -0
- package/dist/components/chart/polar-area-chart.d.ts +15 -0
- package/dist/components/chart/polar-area-chart.js +14 -0
- package/dist/components/chart/radar-chart.d.ts +15 -0
- package/dist/components/chart/radar-chart.js +14 -0
- package/dist/components/chart/scatter-chart.d.ts +15 -0
- package/dist/components/chart/scatter-chart.js +15 -0
- package/dist/components/combobox/combobox.d.ts +16 -0
- package/dist/components/combobox/combobox.js +113 -6
- package/dist/components/combobox/combobox.styles.js +68 -7
- package/dist/components/combobox/option.d.ts +2 -2
- package/dist/components/combobox/option.js +11 -7
- package/dist/components/date-picker/date-input.d.ts +12 -1
- package/dist/components/date-picker/date-input.js +68 -6
- package/dist/components/date-picker/date-input.styles.js +58 -6
- package/dist/components/date-picker/date-picker.js +5 -2
- package/dist/components/date-picker/date-picker.styles.js +9 -2
- package/dist/components/empty/empty.d.ts +1 -0
- package/dist/components/empty/empty.js +14 -2
- package/dist/components/export-button/csv.d.ts +10 -0
- package/dist/components/export-button/csv.js +28 -0
- package/dist/components/export-button/export-button.d.ts +41 -0
- package/dist/components/export-button/export-button.js +151 -0
- package/dist/components/export-button/export-button.styles.d.ts +1 -0
- package/dist/components/export-button/export-button.styles.js +79 -0
- package/dist/components/file-input/accept.d.ts +14 -0
- package/dist/components/file-input/accept.js +30 -0
- package/dist/components/file-input/file-input.d.ts +47 -0
- package/dist/components/file-input/file-input.js +182 -0
- package/dist/components/file-input/file-input.styles.d.ts +1 -0
- package/dist/components/file-input/file-input.styles.js +44 -0
- package/dist/components/flag/flag.d.ts +4 -0
- package/dist/components/flag/flag.js +24 -1
- package/dist/components/flag/flag.styles.js +1 -1
- package/dist/components/gauge/gauge.d.ts +29 -0
- package/dist/components/gauge/gauge.js +133 -0
- package/dist/components/gauge/gauge.styles.d.ts +1 -0
- package/dist/components/gauge/gauge.styles.js +60 -0
- package/dist/components/graph/graph.d.ts +68 -0
- package/dist/components/graph/graph.js +276 -0
- package/dist/components/graph/graph.styles.d.ts +1 -0
- package/dist/components/graph/graph.styles.js +34 -0
- package/dist/components/heatmap/heatmap-scale.d.ts +8 -0
- package/dist/components/heatmap/heatmap-scale.js +17 -0
- package/dist/components/heatmap/heatmap.d.ts +66 -0
- package/dist/components/heatmap/heatmap.js +252 -0
- package/dist/components/heatmap/heatmap.styles.d.ts +1 -0
- package/dist/components/heatmap/heatmap.styles.js +39 -0
- package/dist/components/map/map-loader.d.ts +8 -0
- package/dist/components/map/map-loader.js +17 -0
- package/dist/components/map/map.d.ts +49 -0
- package/dist/components/map/map.js +189 -0
- package/dist/components/map/map.styles.d.ts +1 -0
- package/dist/components/map/map.styles.js +48 -0
- package/dist/components/playback/playback.d.ts +51 -0
- package/dist/components/playback/playback.js +146 -0
- package/dist/components/playback/playback.styles.d.ts +1 -0
- package/dist/components/playback/playback.styles.js +40 -0
- package/dist/components/split/split.d.ts +41 -0
- package/dist/components/split/split.js +171 -0
- package/dist/components/split/split.styles.d.ts +1 -0
- package/dist/components/split/split.styles.js +51 -0
- package/dist/components/stat/stat.d.ts +9 -0
- package/dist/components/stat/stat.js +52 -7
- package/dist/components/stat/stat.styles.js +15 -5
- package/dist/components/table/table.d.ts +18 -6
- package/dist/components/table/table.js +76 -24
- package/dist/components/table/table.styles.js +32 -0
- package/dist/components/time-range/time-range.d.ts +40 -0
- package/dist/components/time-range/time-range.js +219 -0
- package/dist/components/time-range/time-range.styles.d.ts +1 -0
- package/dist/components/time-range/time-range.styles.js +78 -0
- package/dist/components/toast/toast-item.js +10 -2
- package/dist/components/toast/toast-item.styles.js +13 -4
- package/dist/components/toast/toast.styles.js +0 -1
- package/dist/components/tree/tree-node.d.ts +50 -0
- package/dist/components/tree/tree-node.js +196 -0
- package/dist/components/tree/tree.d.ts +65 -0
- package/dist/components/tree/tree.js +227 -0
- package/dist/components/tree/tree.styles.d.ts +1 -0
- package/dist/components/tree/tree.styles.js +13 -0
- package/dist/internal/form-associated.js +49 -1
- package/dist/internal/icons.d.ts +11 -0
- package/dist/internal/icons.js +64 -0
- package/dist/internal/tokens.styles.js +41 -1
- package/dist/lyra.d.ts +67 -0
- package/dist/lyra.js +55 -0
- package/llms-full.txt +1425 -0
- package/llms.txt +47 -0
- package/package.json +53 -4
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { html, nothing } from 'lit';
|
|
8
|
+
import { property, query, state } from 'lit/decorators.js';
|
|
9
|
+
import { LyraElement } from '../../internal/lyra-element.js';
|
|
10
|
+
import { defineElement } from '../../internal/prefix.js';
|
|
11
|
+
import { loadChartJs } from './chart-loader.js';
|
|
12
|
+
import { styles } from './chart.styles.js';
|
|
13
|
+
import '../skeleton/skeleton.js';
|
|
14
|
+
/**
|
|
15
|
+
* Recursively merges `override` onto `base`, matching JSON-merge semantics:
|
|
16
|
+
* plain objects are merged key-by-key at every depth; arrays, functions, and
|
|
17
|
+
* any other value type are replaced wholesale by `override`'s value. Used to
|
|
18
|
+
* deep-merge the raw `config` passthrough over the `Series`-generated config
|
|
19
|
+
* in `buildConfig()` so a nested key (e.g. `config.options.scales.y`) only
|
|
20
|
+
* overrides the keys it sets, rather than clobbering the whole generated
|
|
21
|
+
* sibling object (e.g. the rest of the generated `y` axis config).
|
|
22
|
+
*/
|
|
23
|
+
function isPlainObject(value) {
|
|
24
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
25
|
+
}
|
|
26
|
+
function deepMerge(base, override) {
|
|
27
|
+
if (!isPlainObject(base) || !isPlainObject(override)) {
|
|
28
|
+
return (override === undefined ? base : override);
|
|
29
|
+
}
|
|
30
|
+
const result = { ...base };
|
|
31
|
+
for (const key of Object.keys(override)) {
|
|
32
|
+
result[key] = deepMerge(base[key], override[key]);
|
|
33
|
+
}
|
|
34
|
+
return result;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* `<lyra-chart>` — the core Chart.js wrapper every other `lyra-*-chart` tag
|
|
38
|
+
* subclasses. Requires the optional peer deps `chart.js` + `chartjs-plugin-zoom`.
|
|
39
|
+
*
|
|
40
|
+
* **API mirror note (Task 0):** the real `wa-chart` docs page
|
|
41
|
+
* (https://webawesome.com/docs/components/chart/) documents a `config:
|
|
42
|
+
* ChartJS['config']` property alongside its simplified attributes — "a
|
|
43
|
+
* flexible wrapper around Chart.js" supporting *both* simplified attributes
|
|
44
|
+
* and full Chart.js configuration passthrough, not a `data`/`options` prop
|
|
45
|
+
* pair. `lyra-chart` mirrors that dual surface: the `Series`-based
|
|
46
|
+
* `datasets`/`labels`/`type`/`legend`/`xLabel`/`yLabel`/`zoom` attributes
|
|
47
|
+
* below are the simplified surface (compatible with WA's `type`, `xLabel`,
|
|
48
|
+
* `yLabel`, `withoutLegend`-equivalent `legend`, etc.), and the additional
|
|
49
|
+
* `config` property is the raw-passthrough escape hatch — a
|
|
50
|
+
* `Partial<ChartConfiguration>` deep-merged over the generated config in
|
|
51
|
+
* `buildConfig()`, mirroring WA's `config` property without discarding the
|
|
52
|
+
* `Series` shape the rest of this component family (subclasses, box-plot,
|
|
53
|
+
* histogram) is built on.
|
|
54
|
+
*
|
|
55
|
+
* @customElement lyra-chart
|
|
56
|
+
* @event lyra-zoom - `detail: { zoomed }`.
|
|
57
|
+
* @csspart base, canvas, reset-zoom-button
|
|
58
|
+
*/
|
|
59
|
+
export class LyraChart extends LyraElement {
|
|
60
|
+
constructor() {
|
|
61
|
+
super(...arguments);
|
|
62
|
+
this.type = 'line';
|
|
63
|
+
this.labels = [];
|
|
64
|
+
this.datasets = [];
|
|
65
|
+
this.legend = false;
|
|
66
|
+
this.area = false;
|
|
67
|
+
this.zoom = false;
|
|
68
|
+
this.height = '280px';
|
|
69
|
+
this.xLabel = '';
|
|
70
|
+
this.yLabel = '';
|
|
71
|
+
this.y2Label = '';
|
|
72
|
+
this.beginAtZero = true;
|
|
73
|
+
/** True until the lazy-loaded `chart.js` peer dependency has settled (success or failure). */
|
|
74
|
+
this.loading = true;
|
|
75
|
+
this.zoomed = false;
|
|
76
|
+
this.onThemeChange = () => this.draw();
|
|
77
|
+
}
|
|
78
|
+
static { this.styles = [LyraElement.styles, styles]; }
|
|
79
|
+
connectedCallback() {
|
|
80
|
+
super.connectedCallback();
|
|
81
|
+
window.addEventListener('lyra-theme', this.onThemeChange);
|
|
82
|
+
void loadChartJs().then((mod) => {
|
|
83
|
+
this.loading = false;
|
|
84
|
+
if (!mod)
|
|
85
|
+
return;
|
|
86
|
+
this.chartJsModule = mod;
|
|
87
|
+
this.draw();
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
disconnectedCallback() {
|
|
91
|
+
super.disconnectedCallback();
|
|
92
|
+
window.removeEventListener('lyra-theme', this.onThemeChange);
|
|
93
|
+
this.chart?.destroy();
|
|
94
|
+
this.chart = undefined;
|
|
95
|
+
}
|
|
96
|
+
updated(changed) {
|
|
97
|
+
if (this.loading)
|
|
98
|
+
this.setAttribute('aria-busy', 'true');
|
|
99
|
+
else
|
|
100
|
+
this.removeAttribute('aria-busy');
|
|
101
|
+
// `--lyra-chart-height` is read by `:host`'s `block-size` in
|
|
102
|
+
// `chart.styles.ts`. Custom properties only cascade downward (host ->
|
|
103
|
+
// shadow tree), never upward from a shadow-tree descendant back to the
|
|
104
|
+
// host, so this must be set on the host element itself, not on the
|
|
105
|
+
// `[part="base"]` div inside the shadow root.
|
|
106
|
+
if (changed.has('height')) {
|
|
107
|
+
this.style.setProperty('--lyra-chart-height', this.height);
|
|
108
|
+
}
|
|
109
|
+
const onlyZoomChanged = changed.size === 1 && changed.has('zoomed');
|
|
110
|
+
if (!onlyZoomChanged)
|
|
111
|
+
this.draw();
|
|
112
|
+
}
|
|
113
|
+
seriesToDataset(s) {
|
|
114
|
+
const colors = Array.isArray(s.color) ? s.color : s.color ? [s.color] : undefined;
|
|
115
|
+
return {
|
|
116
|
+
label: s.label,
|
|
117
|
+
data: s.points ?? s.data ?? [],
|
|
118
|
+
type: s.type ?? this.type,
|
|
119
|
+
fill: s.fill ?? this.area,
|
|
120
|
+
borderWidth: s.width ?? 2,
|
|
121
|
+
borderDash: s.dash ? [4, 4] : undefined,
|
|
122
|
+
backgroundColor: colors,
|
|
123
|
+
borderColor: colors?.[0],
|
|
124
|
+
pointBackgroundColor: s.pointColors,
|
|
125
|
+
pointRadius: s.pointRadius,
|
|
126
|
+
yAxisID: s.axis === 'y2' ? 'y2' : 'y',
|
|
127
|
+
tooltip: s.noTooltip ? { enabled: false } : undefined,
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
buildConfig() {
|
|
131
|
+
const hasY2 = this.datasets.some((s) => s.axis === 'y2');
|
|
132
|
+
const generated = {
|
|
133
|
+
type: this.type,
|
|
134
|
+
data: {
|
|
135
|
+
labels: this.labels,
|
|
136
|
+
datasets: this.datasets.map((s) => this.seriesToDataset(s)),
|
|
137
|
+
},
|
|
138
|
+
options: {
|
|
139
|
+
responsive: true,
|
|
140
|
+
maintainAspectRatio: false,
|
|
141
|
+
interaction: { intersect: false, mode: this.type === 'scatter' ? 'nearest' : 'index' },
|
|
142
|
+
plugins: {
|
|
143
|
+
legend: { display: this.legend },
|
|
144
|
+
zoom: this.zoom
|
|
145
|
+
? {
|
|
146
|
+
pan: { enabled: false },
|
|
147
|
+
zoom: {
|
|
148
|
+
wheel: { enabled: true },
|
|
149
|
+
drag: { enabled: true },
|
|
150
|
+
pinch: { enabled: true },
|
|
151
|
+
mode: 'x',
|
|
152
|
+
onZoomComplete: () => {
|
|
153
|
+
this.zoomed = true;
|
|
154
|
+
this.emit('lyra-zoom', { zoomed: true });
|
|
155
|
+
},
|
|
156
|
+
},
|
|
157
|
+
limits: { x: { min: 'original', max: 'original' } },
|
|
158
|
+
}
|
|
159
|
+
: undefined,
|
|
160
|
+
},
|
|
161
|
+
scales: {
|
|
162
|
+
x: {
|
|
163
|
+
type: this.type === 'scatter' ? 'linear' : 'category',
|
|
164
|
+
title: { display: !!this.xLabel, text: this.xLabel },
|
|
165
|
+
},
|
|
166
|
+
y: { beginAtZero: this.beginAtZero, title: { display: !!this.yLabel, text: this.yLabel } },
|
|
167
|
+
...(hasY2
|
|
168
|
+
? {
|
|
169
|
+
y2: {
|
|
170
|
+
position: 'right',
|
|
171
|
+
grid: { drawOnChartArea: false },
|
|
172
|
+
title: { display: !!this.y2Label, text: this.y2Label },
|
|
173
|
+
},
|
|
174
|
+
}
|
|
175
|
+
: {}),
|
|
176
|
+
},
|
|
177
|
+
},
|
|
178
|
+
};
|
|
179
|
+
if (!this.config)
|
|
180
|
+
return generated;
|
|
181
|
+
// Raw Chart.js passthrough (mirrors `wa-chart`'s `config` property) —
|
|
182
|
+
// deep-merge `config` over the `Series`-derived config at every nesting
|
|
183
|
+
// level (see `deepMerge` above), letting consumers override or extend a
|
|
184
|
+
// single nested key (e.g. `config.options.scales.y.min`) without
|
|
185
|
+
// clobbering the rest of the generated sibling object.
|
|
186
|
+
return deepMerge(generated, this.config);
|
|
187
|
+
}
|
|
188
|
+
draw() {
|
|
189
|
+
if (!this.chartJsModule || !this.canvasEl)
|
|
190
|
+
return;
|
|
191
|
+
const config = this.buildConfig();
|
|
192
|
+
const effectiveType = config.type;
|
|
193
|
+
if (this.chart && this.builtType === effectiveType) {
|
|
194
|
+
this.chart.data = config.data;
|
|
195
|
+
this.chart.options = config.options ?? {};
|
|
196
|
+
this.chart.update('none');
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
this.chart?.destroy();
|
|
200
|
+
this.chart = new this.chartJsModule.Chart(this.canvasEl, config);
|
|
201
|
+
this.builtType = effectiveType;
|
|
202
|
+
}
|
|
203
|
+
/** Reset any active zoom/pan back to the original view. */
|
|
204
|
+
resetZoom() {
|
|
205
|
+
this.chart?.resetZoom?.();
|
|
206
|
+
this.zoomed = false;
|
|
207
|
+
this.emit('lyra-zoom', { zoomed: false });
|
|
208
|
+
}
|
|
209
|
+
render() {
|
|
210
|
+
if (this.loading) {
|
|
211
|
+
return html `
|
|
212
|
+
<div part="base">
|
|
213
|
+
<lyra-skeleton variant="rect"></lyra-skeleton>
|
|
214
|
+
</div>
|
|
215
|
+
`;
|
|
216
|
+
}
|
|
217
|
+
const label = this.datasets.map((d) => d.label).join(', ') || 'Chart';
|
|
218
|
+
return html `
|
|
219
|
+
<div part="base">
|
|
220
|
+
<canvas part="canvas" role="img" aria-label=${label}></canvas>
|
|
221
|
+
${this.zoom && this.zoomed
|
|
222
|
+
? html `<button part="reset-zoom-button" type="button" @click=${() => this.resetZoom()}>
|
|
223
|
+
Reset zoom
|
|
224
|
+
</button>`
|
|
225
|
+
: nothing}
|
|
226
|
+
</div>
|
|
227
|
+
`;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
__decorate([
|
|
231
|
+
property()
|
|
232
|
+
], LyraChart.prototype, "type", void 0);
|
|
233
|
+
__decorate([
|
|
234
|
+
property({ attribute: false })
|
|
235
|
+
], LyraChart.prototype, "labels", void 0);
|
|
236
|
+
__decorate([
|
|
237
|
+
property({ attribute: false })
|
|
238
|
+
], LyraChart.prototype, "datasets", void 0);
|
|
239
|
+
__decorate([
|
|
240
|
+
property({ type: Boolean })
|
|
241
|
+
], LyraChart.prototype, "legend", void 0);
|
|
242
|
+
__decorate([
|
|
243
|
+
property({ type: Boolean })
|
|
244
|
+
], LyraChart.prototype, "area", void 0);
|
|
245
|
+
__decorate([
|
|
246
|
+
property({ type: Boolean })
|
|
247
|
+
], LyraChart.prototype, "zoom", void 0);
|
|
248
|
+
__decorate([
|
|
249
|
+
property()
|
|
250
|
+
], LyraChart.prototype, "height", void 0);
|
|
251
|
+
__decorate([
|
|
252
|
+
property({ attribute: 'x-label' })
|
|
253
|
+
], LyraChart.prototype, "xLabel", void 0);
|
|
254
|
+
__decorate([
|
|
255
|
+
property({ attribute: 'y-label' })
|
|
256
|
+
], LyraChart.prototype, "yLabel", void 0);
|
|
257
|
+
__decorate([
|
|
258
|
+
property({ attribute: 'y2-label' })
|
|
259
|
+
], LyraChart.prototype, "y2Label", void 0);
|
|
260
|
+
__decorate([
|
|
261
|
+
property({ type: Boolean, attribute: 'begin-at-zero' })
|
|
262
|
+
], LyraChart.prototype, "beginAtZero", void 0);
|
|
263
|
+
__decorate([
|
|
264
|
+
property({ attribute: false })
|
|
265
|
+
], LyraChart.prototype, "config", void 0);
|
|
266
|
+
__decorate([
|
|
267
|
+
state()
|
|
268
|
+
], LyraChart.prototype, "loading", void 0);
|
|
269
|
+
__decorate([
|
|
270
|
+
state()
|
|
271
|
+
], LyraChart.prototype, "zoomed", void 0);
|
|
272
|
+
__decorate([
|
|
273
|
+
query('canvas')
|
|
274
|
+
], LyraChart.prototype, "canvasEl", void 0);
|
|
275
|
+
defineElement('chart', LyraChart);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const styles: import("lit").CSSResult;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { css } from 'lit';
|
|
2
|
+
export const styles = css `
|
|
3
|
+
:host {
|
|
4
|
+
display: block;
|
|
5
|
+
position: relative;
|
|
6
|
+
block-size: var(--lyra-chart-height, 280px);
|
|
7
|
+
}
|
|
8
|
+
[part='base'] {
|
|
9
|
+
position: relative;
|
|
10
|
+
inline-size: 100%;
|
|
11
|
+
block-size: 100%;
|
|
12
|
+
}
|
|
13
|
+
lyra-skeleton {
|
|
14
|
+
--lyra-skeleton-w: 100%;
|
|
15
|
+
--lyra-skeleton-h: 100%;
|
|
16
|
+
}
|
|
17
|
+
canvas {
|
|
18
|
+
inline-size: 100% !important;
|
|
19
|
+
block-size: 100% !important;
|
|
20
|
+
}
|
|
21
|
+
[part='reset-zoom-button'] {
|
|
22
|
+
position: absolute;
|
|
23
|
+
inset-block-start: var(--lyra-space-xs);
|
|
24
|
+
inset-inline-end: var(--lyra-space-xs);
|
|
25
|
+
font-size: 0.75rem;
|
|
26
|
+
padding: 0.15rem 0.5rem;
|
|
27
|
+
border: 1px solid var(--lyra-color-border);
|
|
28
|
+
border-radius: var(--lyra-radius);
|
|
29
|
+
background: var(--lyra-color-surface);
|
|
30
|
+
color: var(--lyra-color-text);
|
|
31
|
+
cursor: pointer;
|
|
32
|
+
}
|
|
33
|
+
`;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { LyraChart } from './chart.js';
|
|
2
|
+
import type { LyraChartType } from './chart.js';
|
|
3
|
+
/**
|
|
4
|
+
* `<lyra-doughnut-chart>` — `<lyra-chart>` with `type` locked to `"doughnut"`.
|
|
5
|
+
*
|
|
6
|
+
* @customElement lyra-doughnut-chart
|
|
7
|
+
*/
|
|
8
|
+
export declare class LyraDoughnutChart extends LyraChart {
|
|
9
|
+
type: LyraChartType;
|
|
10
|
+
}
|
|
11
|
+
declare global {
|
|
12
|
+
interface HTMLElementTagNameMap {
|
|
13
|
+
'lyra-doughnut-chart': LyraDoughnutChart;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { LyraChart } from './chart.js';
|
|
2
|
+
import { defineElement } from '../../internal/prefix.js';
|
|
3
|
+
/**
|
|
4
|
+
* `<lyra-doughnut-chart>` — `<lyra-chart>` with `type` locked to `"doughnut"`.
|
|
5
|
+
*
|
|
6
|
+
* @customElement lyra-doughnut-chart
|
|
7
|
+
*/
|
|
8
|
+
export class LyraDoughnutChart extends LyraChart {
|
|
9
|
+
constructor() {
|
|
10
|
+
super(...arguments);
|
|
11
|
+
this.type = 'doughnut';
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
defineElement('doughnut-chart', LyraDoughnutChart);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/** Splits `values` into `binCount` equal-width buckets and counts membership. */
|
|
2
|
+
export function binValues(values, binCount) {
|
|
3
|
+
if (values.length === 0 || binCount <= 0)
|
|
4
|
+
return [];
|
|
5
|
+
const lo = Math.min(...values);
|
|
6
|
+
const hi = Math.max(...values);
|
|
7
|
+
const span = hi - lo || 1;
|
|
8
|
+
const width = span / binCount;
|
|
9
|
+
const buckets = Array.from({ length: binCount }, (_, i) => {
|
|
10
|
+
const bLo = lo + i * width;
|
|
11
|
+
const bHi = lo + (i + 1) * width;
|
|
12
|
+
return { label: `${bLo.toFixed(1)}–${bHi.toFixed(1)}`, count: 0 };
|
|
13
|
+
});
|
|
14
|
+
for (const v of values) {
|
|
15
|
+
const index = v === hi ? binCount - 1 : Math.floor((v - lo) / width);
|
|
16
|
+
buckets[Math.min(binCount - 1, Math.max(0, index))].count++;
|
|
17
|
+
}
|
|
18
|
+
return buckets;
|
|
19
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { LyraChart } from './chart.js';
|
|
2
|
+
/**
|
|
3
|
+
* `<lyra-histogram>` — bins `values` into `bins` equal-width buckets and
|
|
4
|
+
* renders them as a bar chart. No Chart.js histogram controller exists in
|
|
5
|
+
* any surveyed seed; this composes `binValues()` with the plain `bar` type.
|
|
6
|
+
*
|
|
7
|
+
* @customElement lyra-histogram
|
|
8
|
+
*/
|
|
9
|
+
export declare class LyraHistogram extends LyraChart {
|
|
10
|
+
static styles: import("lit").CSSResultGroup[];
|
|
11
|
+
type: 'bar';
|
|
12
|
+
bins: number;
|
|
13
|
+
values: number[];
|
|
14
|
+
label: string;
|
|
15
|
+
}
|
|
16
|
+
declare global {
|
|
17
|
+
interface HTMLElementTagNameMap {
|
|
18
|
+
'lyra-histogram': LyraHistogram;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { property } from 'lit/decorators.js';
|
|
8
|
+
import { LyraChart } from './chart.js';
|
|
9
|
+
import { LyraElement } from '../../internal/lyra-element.js';
|
|
10
|
+
import { defineElement } from '../../internal/prefix.js';
|
|
11
|
+
import { binValues } from './histogram-bin.js';
|
|
12
|
+
import { styles } from './histogram.styles.js';
|
|
13
|
+
/**
|
|
14
|
+
* `<lyra-histogram>` — bins `values` into `bins` equal-width buckets and
|
|
15
|
+
* renders them as a bar chart. No Chart.js histogram controller exists in
|
|
16
|
+
* any surveyed seed; this composes `binValues()` with the plain `bar` type.
|
|
17
|
+
*
|
|
18
|
+
* @customElement lyra-histogram
|
|
19
|
+
*/
|
|
20
|
+
export class LyraHistogram extends LyraChart {
|
|
21
|
+
constructor() {
|
|
22
|
+
super(...arguments);
|
|
23
|
+
this.type = 'bar';
|
|
24
|
+
this.bins = 10;
|
|
25
|
+
this.values = [];
|
|
26
|
+
this.label = 'Frequency';
|
|
27
|
+
}
|
|
28
|
+
// Explicit rather than relying on `LyraChart`'s inherited `static styles` —
|
|
29
|
+
// `histogram.styles.ts` re-exports the same `chart.styles.ts` sheet, so
|
|
30
|
+
// this is behaviorally identical, but it keeps the per-component styles
|
|
31
|
+
// file meaningful instead of dead weight.
|
|
32
|
+
static { this.styles = [LyraElement.styles, styles]; }
|
|
33
|
+
}
|
|
34
|
+
__decorate([
|
|
35
|
+
property({ type: Number })
|
|
36
|
+
], LyraHistogram.prototype, "bins", void 0);
|
|
37
|
+
__decorate([
|
|
38
|
+
property({ attribute: false })
|
|
39
|
+
], LyraHistogram.prototype, "values", void 0);
|
|
40
|
+
__decorate([
|
|
41
|
+
property()
|
|
42
|
+
], LyraHistogram.prototype, "label", void 0);
|
|
43
|
+
// `labels`/`datasets` are computed from `values`/`bins` rather than settable
|
|
44
|
+
// props. `LyraChart` declares both as plain (decorator-managed) class
|
|
45
|
+
// fields, and TypeScript forbids a subclass from re-declaring a base field
|
|
46
|
+
// as a getter/setter pair via ordinary class syntax (TS2611) — so the
|
|
47
|
+
// accessor pair is installed directly on the prototype instead, which is
|
|
48
|
+
// runtime-equivalent (same shadowing semantics as a class-syntax override)
|
|
49
|
+
// without tripping that check.
|
|
50
|
+
Object.defineProperty(LyraHistogram.prototype, 'labels', {
|
|
51
|
+
configurable: true,
|
|
52
|
+
enumerable: true,
|
|
53
|
+
get() {
|
|
54
|
+
return binValues(this.values, this.bins).map((b) => b.label);
|
|
55
|
+
},
|
|
56
|
+
set(_v) {
|
|
57
|
+
/* derived from `values`/`bins`; direct writes are ignored */
|
|
58
|
+
},
|
|
59
|
+
});
|
|
60
|
+
Object.defineProperty(LyraHistogram.prototype, 'datasets', {
|
|
61
|
+
configurable: true,
|
|
62
|
+
enumerable: true,
|
|
63
|
+
get() {
|
|
64
|
+
return [{ label: this.label, data: binValues(this.values, this.bins).map((b) => b.count) }];
|
|
65
|
+
},
|
|
66
|
+
set(_v) {
|
|
67
|
+
/* derived from `values`/`bins`; direct writes are ignored */
|
|
68
|
+
},
|
|
69
|
+
});
|
|
70
|
+
defineElement('histogram', LyraHistogram);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { styles } from './chart.styles.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { styles } from './chart.styles.js';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { LyraChart } from './chart.js';
|
|
2
|
+
/**
|
|
3
|
+
* `<lyra-line-chart>` — `<lyra-chart>` with `type` locked to `"line"`.
|
|
4
|
+
*
|
|
5
|
+
* @customElement lyra-line-chart
|
|
6
|
+
*/
|
|
7
|
+
export declare class LyraLineChart extends LyraChart {
|
|
8
|
+
type: 'line';
|
|
9
|
+
}
|
|
10
|
+
declare global {
|
|
11
|
+
interface HTMLElementTagNameMap {
|
|
12
|
+
'lyra-line-chart': LyraLineChart;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { LyraChart } from './chart.js';
|
|
2
|
+
import { defineElement } from '../../internal/prefix.js';
|
|
3
|
+
/**
|
|
4
|
+
* `<lyra-line-chart>` — `<lyra-chart>` with `type` locked to `"line"`.
|
|
5
|
+
*
|
|
6
|
+
* @customElement lyra-line-chart
|
|
7
|
+
*/
|
|
8
|
+
export class LyraLineChart extends LyraChart {
|
|
9
|
+
constructor() {
|
|
10
|
+
super(...arguments);
|
|
11
|
+
this.type = 'line';
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
defineElement('line-chart', LyraLineChart);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { LyraChart } from './chart.js';
|
|
2
|
+
import type { LyraChartType } from './chart.js';
|
|
3
|
+
/**
|
|
4
|
+
* `<lyra-pie-chart>` — `<lyra-chart>` with `type` locked to `"pie"`. Single-series:
|
|
5
|
+
* one `Series` with `data: number[]` and `color: string[]` as the slice palette.
|
|
6
|
+
*
|
|
7
|
+
* @customElement lyra-pie-chart
|
|
8
|
+
*/
|
|
9
|
+
export declare class LyraPieChart extends LyraChart {
|
|
10
|
+
type: LyraChartType;
|
|
11
|
+
}
|
|
12
|
+
declare global {
|
|
13
|
+
interface HTMLElementTagNameMap {
|
|
14
|
+
'lyra-pie-chart': LyraPieChart;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { LyraChart } from './chart.js';
|
|
2
|
+
import { defineElement } from '../../internal/prefix.js';
|
|
3
|
+
/**
|
|
4
|
+
* `<lyra-pie-chart>` — `<lyra-chart>` with `type` locked to `"pie"`. Single-series:
|
|
5
|
+
* one `Series` with `data: number[]` and `color: string[]` as the slice palette.
|
|
6
|
+
*
|
|
7
|
+
* @customElement lyra-pie-chart
|
|
8
|
+
*/
|
|
9
|
+
export class LyraPieChart extends LyraChart {
|
|
10
|
+
constructor() {
|
|
11
|
+
super(...arguments);
|
|
12
|
+
this.type = 'pie';
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
defineElement('pie-chart', LyraPieChart);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { LyraChart } from './chart.js';
|
|
2
|
+
import type { LyraChartType } from './chart.js';
|
|
3
|
+
/**
|
|
4
|
+
* `<lyra-polar-area-chart>` — `<lyra-chart>` with `type` locked to `"polarArea"`.
|
|
5
|
+
*
|
|
6
|
+
* @customElement lyra-polar-area-chart
|
|
7
|
+
*/
|
|
8
|
+
export declare class LyraPolarAreaChart extends LyraChart {
|
|
9
|
+
type: LyraChartType;
|
|
10
|
+
}
|
|
11
|
+
declare global {
|
|
12
|
+
interface HTMLElementTagNameMap {
|
|
13
|
+
'lyra-polar-area-chart': LyraPolarAreaChart;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { LyraChart } from './chart.js';
|
|
2
|
+
import { defineElement } from '../../internal/prefix.js';
|
|
3
|
+
/**
|
|
4
|
+
* `<lyra-polar-area-chart>` — `<lyra-chart>` with `type` locked to `"polarArea"`.
|
|
5
|
+
*
|
|
6
|
+
* @customElement lyra-polar-area-chart
|
|
7
|
+
*/
|
|
8
|
+
export class LyraPolarAreaChart extends LyraChart {
|
|
9
|
+
constructor() {
|
|
10
|
+
super(...arguments);
|
|
11
|
+
this.type = 'polarArea';
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
defineElement('polar-area-chart', LyraPolarAreaChart);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { LyraChart } from './chart.js';
|
|
2
|
+
import type { LyraChartType } from './chart.js';
|
|
3
|
+
/**
|
|
4
|
+
* `<lyra-radar-chart>` — `<lyra-chart>` with `type` locked to `"radar"`.
|
|
5
|
+
*
|
|
6
|
+
* @customElement lyra-radar-chart
|
|
7
|
+
*/
|
|
8
|
+
export declare class LyraRadarChart extends LyraChart {
|
|
9
|
+
type: LyraChartType;
|
|
10
|
+
}
|
|
11
|
+
declare global {
|
|
12
|
+
interface HTMLElementTagNameMap {
|
|
13
|
+
'lyra-radar-chart': LyraRadarChart;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { LyraChart } from './chart.js';
|
|
2
|
+
import { defineElement } from '../../internal/prefix.js';
|
|
3
|
+
/**
|
|
4
|
+
* `<lyra-radar-chart>` — `<lyra-chart>` with `type` locked to `"radar"`.
|
|
5
|
+
*
|
|
6
|
+
* @customElement lyra-radar-chart
|
|
7
|
+
*/
|
|
8
|
+
export class LyraRadarChart extends LyraChart {
|
|
9
|
+
constructor() {
|
|
10
|
+
super(...arguments);
|
|
11
|
+
this.type = 'radar';
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
defineElement('radar-chart', LyraRadarChart);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { LyraChart } from './chart.js';
|
|
2
|
+
/**
|
|
3
|
+
* `<lyra-scatter-chart>` — `<lyra-chart>` with `type` locked to `"scatter"`. Feed
|
|
4
|
+
* points via `Series.points`.
|
|
5
|
+
*
|
|
6
|
+
* @customElement lyra-scatter-chart
|
|
7
|
+
*/
|
|
8
|
+
export declare class LyraScatterChart extends LyraChart {
|
|
9
|
+
type: 'scatter';
|
|
10
|
+
}
|
|
11
|
+
declare global {
|
|
12
|
+
interface HTMLElementTagNameMap {
|
|
13
|
+
'lyra-scatter-chart': LyraScatterChart;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { LyraChart } from './chart.js';
|
|
2
|
+
import { defineElement } from '../../internal/prefix.js';
|
|
3
|
+
/**
|
|
4
|
+
* `<lyra-scatter-chart>` — `<lyra-chart>` with `type` locked to `"scatter"`. Feed
|
|
5
|
+
* points via `Series.points`.
|
|
6
|
+
*
|
|
7
|
+
* @customElement lyra-scatter-chart
|
|
8
|
+
*/
|
|
9
|
+
export class LyraScatterChart extends LyraChart {
|
|
10
|
+
constructor() {
|
|
11
|
+
super(...arguments);
|
|
12
|
+
this.type = 'scatter';
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
defineElement('scatter-chart', LyraScatterChart);
|