overview-components 1.0.68 → 1.0.70

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.
@@ -0,0 +1,392 @@
1
+ import { customElement as w } from "../node_modules/@lit/reactive-element/decorators/custom-element.js";
2
+ import { property as b } from "../node_modules/@lit/reactive-element/decorators/property.js";
3
+ import { LitElement as v, html as y, css as x } from "lit";
4
+ import { Chart as p, registerables as D } from "chart.js";
5
+ var k = Object.defineProperty, S = Object.getOwnPropertyDescriptor, u = (a, r, n, e) => {
6
+ for (var t = e > 1 ? void 0 : e ? S(r, n) : r, s = a.length - 1, o; s >= 0; s--)
7
+ (o = a[s]) && (t = (e ? o(r, n, t) : o(t)) || t);
8
+ return e && t && k(r, n, t), t;
9
+ };
10
+ p.register(...D);
11
+ let c = class extends v {
12
+ constructor() {
13
+ super(...arguments), this.type = "bar", this.data = { labels: [], datasets: [], title: "" }, this.isLoading = !1, this.chart = null;
14
+ }
15
+ updated(a) {
16
+ (a.has("type") || a.has("data")) && this.renderChart();
17
+ }
18
+ generateColors(a) {
19
+ return Array.from(
20
+ { length: a },
21
+ () => `rgba(${Math.floor(Math.random() * 255)}, ${Math.floor(Math.random() * 255)}, ${Math.floor(Math.random() * 255)}, 0.6)`
22
+ );
23
+ }
24
+ renderChart() {
25
+ var r;
26
+ const a = (r = this.shadowRoot) == null ? void 0 : r.querySelector("canvas");
27
+ a && (this.type === "bar" || this.type === "line" ? this.renderBarAndLineChart(a) : this.type === "bubble" ? this.renderBubbleChart(a) : this.type === "pie" || this.type === "doughnut" ? this.renderPieAndDoughnutChart(a) : this.type === "gantt" && this.renderGanttChart(a));
28
+ }
29
+ renderGanttChart(a) {
30
+ var f;
31
+ this.chart && this.chart.destroy();
32
+ const r = this.generateColors(((f = this.data.datasets[0]) == null ? void 0 : f.data.length) || 0), n = this.data.datasets.map((l, i) => ({
33
+ label: l.label || `Dataset ${i + 1}`,
34
+ data: l.data.map((d) => {
35
+ const h = new Date(d.x[0]), m = new Date(d.x[1]);
36
+ return {
37
+ x: [
38
+ isNaN(h.getTime()) ? Date.now() : h.getTime(),
39
+ isNaN(m.getTime()) ? Date.now() : m.getTime()
40
+ ],
41
+ y: d.y
42
+ };
43
+ }),
44
+ backgroundColor: r,
45
+ borderColor: r,
46
+ borderWidth: 1,
47
+ barThickness: 16,
48
+ borderRadius: 4,
49
+ borderSkipped: !1
50
+ })), e = this.data.datasets.flatMap(
51
+ (l) => l.data.flatMap((i) => {
52
+ var d, h;
53
+ return [
54
+ new Date((d = i == null ? void 0 : i.x) == null ? void 0 : d[0]).getTime(),
55
+ new Date((h = i == null ? void 0 : i.x) == null ? void 0 : h[1]).getTime()
56
+ ];
57
+ })
58
+ ), t = Math.min(...e), s = Math.max(...e), C = (s - t) / 20;
59
+ this.chart = new p(a, {
60
+ type: "bar",
61
+ data: {
62
+ datasets: n
63
+ },
64
+ options: {
65
+ indexAxis: "y",
66
+ responsive: !0,
67
+ maintainAspectRatio: !1,
68
+ scales: {
69
+ x: {
70
+ type: "linear",
71
+ ticks: {
72
+ stepSize: C,
73
+ // 30 dní v milisekundách
74
+ autoSkip: !1,
75
+ callback: (l) => new Date(l).toLocaleDateString("sk-SK", {
76
+ day: "2-digit",
77
+ month: "2-digit",
78
+ year: "numeric"
79
+ })
80
+ },
81
+ min: t,
82
+ max: s
83
+ },
84
+ y: {
85
+ type: "category"
86
+ }
87
+ },
88
+ plugins: {
89
+ tooltip: {
90
+ callbacks: {
91
+ label: function(l) {
92
+ const i = new Date(l.raw.x[0]).toLocaleDateString(
93
+ "sk-SK",
94
+ {
95
+ day: "2-digit",
96
+ month: "2-digit",
97
+ year: "numeric"
98
+ }
99
+ ), d = new Date(l.raw.x[1]).toLocaleDateString("sk-SK", {
100
+ day: "2-digit",
101
+ month: "2-digit",
102
+ year: "numeric"
103
+ });
104
+ return `  Začiatok: ${i}, Koniec: ${d}`;
105
+ }
106
+ },
107
+ bodyFont: {
108
+ size: 13,
109
+ weight: 400
110
+ },
111
+ displayColors: !0,
112
+ usePointStyle: !0,
113
+ backgroundColor: "black",
114
+ cornerRadius: 8
115
+ },
116
+ legend: {
117
+ display: !1
118
+ },
119
+ title: {
120
+ display: !0,
121
+ text: this.data.title,
122
+ // Text, ktorý sa zobrazí nad grafom
123
+ font: {
124
+ size: 17,
125
+ weight: 500
126
+ },
127
+ color: "var(--text-primary, #111827)",
128
+ padding: {
129
+ top: 10,
130
+ bottom: 20
131
+ }
132
+ }
133
+ },
134
+ onHover: (l, i) => {
135
+ var h;
136
+ const d = (h = l.native) == null ? void 0 : h.target;
137
+ d.style.cursor = i.length ? "pointer" : "default";
138
+ }
139
+ }
140
+ });
141
+ }
142
+ renderPieAndDoughnutChart(a) {
143
+ var e;
144
+ this.chart && this.chart.destroy();
145
+ const r = this.generateColors(((e = this.data.datasets[0]) == null ? void 0 : e.data.length) || 0), n = this.data.datasets.map((t) => ({
146
+ ...t,
147
+ backgroundColor: r,
148
+ borderColor: r,
149
+ borderWidth: 2,
150
+ pointBorderWidth: 2
151
+ }));
152
+ this.chart = new p(a, {
153
+ type: this.type,
154
+ data: {
155
+ labels: this.data.labels,
156
+ datasets: n
157
+ },
158
+ options: {
159
+ responsive: !0,
160
+ maintainAspectRatio: !1,
161
+ plugins: {
162
+ legend: {
163
+ position: "top",
164
+ labels: {
165
+ usePointStyle: !0,
166
+ pointStyle: "circle",
167
+ font: {
168
+ size: 13,
169
+ weight: 500
170
+ }
171
+ }
172
+ },
173
+ tooltip: {
174
+ callbacks: {
175
+ title: () => "",
176
+ label: (t) => (t.raw, `  ${t.label}: ${t.raw}`)
177
+ },
178
+ bodyFont: {
179
+ size: 13,
180
+ weight: 400
181
+ },
182
+ displayColors: !0,
183
+ usePointStyle: !0,
184
+ // Použitie kruhového symbolu
185
+ xAlign: "center",
186
+ yAlign: "bottom",
187
+ padding: 16,
188
+ backgroundColor: "black",
189
+ cornerRadius: 8
190
+ },
191
+ title: {
192
+ display: !0,
193
+ text: this.data.title,
194
+ // Text, ktorý sa zobrazí nad grafom
195
+ font: {
196
+ size: 17,
197
+ weight: 500
198
+ },
199
+ color: "var(--text-primary, #111827)",
200
+ padding: {
201
+ top: 10,
202
+ bottom: 20
203
+ }
204
+ }
205
+ },
206
+ ...this.type === "doughnut" && {
207
+ cutout: "70%"
208
+ },
209
+ onHover: (t, s) => {
210
+ var g;
211
+ const o = (g = t.native) == null ? void 0 : g.target;
212
+ s.length ? o.style.cursor = "pointer" : o.style.cursor = "default";
213
+ }
214
+ }
215
+ });
216
+ }
217
+ renderBubbleChart(a) {
218
+ this.chart && this.chart.destroy();
219
+ const r = this.generateColors(this.data.datasets.length), n = this.data.datasets.map((e, t) => ({
220
+ ...e,
221
+ backgroundColor: r[t],
222
+ borderColor: r[t],
223
+ borderWidth: 1,
224
+ hoverRadius: 10,
225
+ pointBorderWidth: 2
226
+ }));
227
+ this.chart = new p(a, {
228
+ type: "bubble",
229
+ data: { datasets: n },
230
+ options: {
231
+ responsive: !0,
232
+ scales: {
233
+ x: { beginAtZero: !0 },
234
+ y: { beginAtZero: !0 }
235
+ },
236
+ plugins: {
237
+ legend: {
238
+ position: "top",
239
+ labels: {
240
+ usePointStyle: !0,
241
+ // Použitie kruhového symbolu
242
+ pointStyle: "circle"
243
+ // Špecifický tvar pre symbol v legende
244
+ }
245
+ },
246
+ tooltip: {
247
+ callbacks: {
248
+ label: (e) => {
249
+ const t = e.raw;
250
+ return `  x: ${t.x}, y: ${t.y}, r: ${t.r}`;
251
+ }
252
+ },
253
+ bodyFont: {
254
+ size: 13,
255
+ weight: 400
256
+ },
257
+ displayColors: !0,
258
+ usePointStyle: !0,
259
+ // Použitie kruhového symbolu
260
+ xAlign: "center",
261
+ yAlign: "bottom",
262
+ padding: 16,
263
+ backgroundColor: "black",
264
+ cornerRadius: 8
265
+ },
266
+ title: {
267
+ display: !0,
268
+ text: this.data.title,
269
+ // Text, ktorý sa zobrazí nad grafom
270
+ font: {
271
+ size: 17,
272
+ weight: 500
273
+ },
274
+ color: "var(--text-primary, #111827)",
275
+ padding: {
276
+ top: 10,
277
+ bottom: 20
278
+ }
279
+ }
280
+ },
281
+ onHover: (e, t) => {
282
+ var o;
283
+ const s = (o = e.native) == null ? void 0 : o.target;
284
+ t.length ? s.style.cursor = "pointer" : s.style.cursor = "default";
285
+ }
286
+ }
287
+ });
288
+ }
289
+ renderBarAndLineChart(a) {
290
+ this.chart && this.chart.destroy();
291
+ const r = this.generateColors(this.data.datasets.length), n = this.data.datasets.map((e, t) => ({
292
+ ...e,
293
+ backgroundColor: r[t],
294
+ borderColor: r[t],
295
+ borderWidth: 2,
296
+ ...this.type === "bar" ? { borderRadius: 4 } : {},
297
+ ...this.type === "line" ? {
298
+ pointStyle: "circle",
299
+ pointRadius: 3,
300
+ pointBorderWidth: 2,
301
+ pointBorderColor: r[t]
302
+ } : {}
303
+ }));
304
+ this.chart = new p(a, {
305
+ type: this.type,
306
+ data: {
307
+ labels: this.data.labels,
308
+ datasets: n
309
+ },
310
+ options: {
311
+ responsive: !0,
312
+ maintainAspectRatio: !1,
313
+ plugins: {
314
+ legend: {
315
+ position: "top",
316
+ labels: {
317
+ usePointStyle: !0,
318
+ // Použitie kruhového symbolu
319
+ pointStyle: "circle"
320
+ // Špecifický tvar pre symbol v legende
321
+ }
322
+ },
323
+ tooltip: {
324
+ callbacks: {
325
+ title: () => "",
326
+ label: (e) => (e.raw, `  ${e.label}: ${e.raw}`)
327
+ },
328
+ bodyFont: {
329
+ size: 13,
330
+ weight: 400
331
+ },
332
+ displayColors: !0,
333
+ usePointStyle: !0,
334
+ // Použitie kruhového symbolu
335
+ xAlign: "center",
336
+ yAlign: "bottom",
337
+ padding: 16,
338
+ backgroundColor: "black",
339
+ cornerRadius: 8
340
+ },
341
+ title: {
342
+ display: !0,
343
+ text: this.data.title,
344
+ // Text, ktorý sa zobrazí nad grafom
345
+ font: {
346
+ size: 17,
347
+ weight: 500
348
+ },
349
+ color: "var(--text-primary, #111827)",
350
+ padding: {
351
+ top: 10,
352
+ bottom: 20
353
+ }
354
+ }
355
+ },
356
+ onHover: (e, t) => {
357
+ var o;
358
+ const s = (o = e.native) == null ? void 0 : o.target;
359
+ t.length ? s.style.cursor = "pointer" : s.style.cursor = "default";
360
+ }
361
+ }
362
+ });
363
+ }
364
+ render() {
365
+ return y`${this.isLoading ? y`<lit-loader></lit-loader>` : y`<canvas></canvas>`}`;
366
+ }
367
+ };
368
+ c.styles = [
369
+ x`
370
+ canvas {
371
+ width: 100%;
372
+ height: 100%;
373
+ font-family: 'Inter', sans-serif;
374
+ margin: 0 auto;
375
+ }
376
+ `
377
+ ];
378
+ u([
379
+ b({ type: String })
380
+ ], c.prototype, "type", 2);
381
+ u([
382
+ b({ type: Array })
383
+ ], c.prototype, "data", 2);
384
+ u([
385
+ b({ type: Boolean })
386
+ ], c.prototype, "isLoading", 2);
387
+ c = u([
388
+ w("lit-chart")
389
+ ], c);
390
+ export {
391
+ c as LitChart
392
+ };