vue-chrts 0.2.0-test.7 → 0.2.0-test.8

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/dist/index.js.js DELETED
@@ -1,753 +0,0 @@
1
- import { defineComponent as x, computed as $, createElementBlock as v, openBlock as c, createElementVNode as T, toDisplayString as N, Fragment as O, renderList as U, normalizeStyle as P, useSlots as X, useTemplateRef as R, ref as Y, normalizeClass as w, createVNode as y, createCommentVNode as h, unref as n, withCtx as j, createBlock as b, mergeProps as S, renderSlot as C, createApp as ae } from "vue";
2
- import { Position as M, CurveType as H, Orientation as F, StackedBar as re, GroupedBar as le, Donut as se } from "@unovis/ts";
3
- import { VisXYContainer as W, VisTooltip as I, VisArea as te, VisLine as ie, VisAxis as D, VisCrosshair as z, VisBulletLegend as V, VisStackedBar as Q, VisGroupedBar as de, VisSingleContainer as ce, VisDonut as ue } from "@unovis/vue";
4
- function J(t) {
5
- if (t && Object.keys(t).length > 0) {
6
- const a = Object.keys(t)[0];
7
- return t[a];
8
- }
9
- }
10
- const pe = (t, a, o, i, l) => {
11
- switch (t) {
12
- case "circle":
13
- return `<circle cx="${a / 2}" cy="${a / 2}" r="${(a - o) / 2}" stroke-width="${o}" stroke="${l}" fill="${i}" />`;
14
- case "square":
15
- return `<rect x="${o / 2}" y="${o / 2}" width="${a - o}" height="${a - o}" stroke-width="${o}" stroke="${l}" fill="${i}" />`;
16
- case "triangle":
17
- return `<polygon points="${a / 2},${o / 2} ${a - o / 2},${a - o / 2} ${o / 2},${a - o / 2}" stroke-width="${o}" stroke="${l}" fill="${i}" />`;
18
- case "diamond":
19
- return `<polygon points="${a / 2},${o / 2} ${a - o / 2},${a / 2} ${a / 2},${a - o / 2} ${o / 2},${a / 2}" stroke-width="${o}" stroke="${l}" fill="${i}" />`;
20
- default:
21
- return "";
22
- }
23
- };
24
- function ne(t) {
25
- return Object.entries(t).map(([a, o]) => {
26
- const i = o.type || "circle", l = o.size || 10, d = o.strokeWidth || 2, s = o.color || "#000", u = o.strokeColor || o.color || "#000";
27
- return `<marker id="circle-marker-${a}" viewBox="0 0 ${l} ${l}" refX="${l / 2}" refY="${l / 2}" markerWidth="${l / 2}" markerHeight="${l / 2}">
28
- ${pe(i, l, d, s, u)}
29
- </marker>`;
30
- }).join(`
31
- `);
32
- }
33
- function me(t) {
34
- return t.charAt(0).toUpperCase() + t.slice(1);
35
- }
36
- const ye = (t, a) => {
37
- const o = Object.keys(t[0]).filter((l) => l !== a), i = Object.keys(t[0][o[0]]);
38
- return t.map((l) => ({
39
- month: l.month,
40
- ...o.flatMap(
41
- (d) => i.map((s) => ({
42
- [`${d}${me(s)}`]: l[d][s]
43
- }))
44
- ).reduce((d, s) => ({ ...d, ...s }), {})
45
- }));
46
- }, ge = {
47
- class: "capitalize border-b mb-1 pb-1",
48
- style: {
49
- color: "var(--tooltip-value-color)",
50
- borderColor: "rgba(255, 255, 255, 0.05)"
51
- }
52
- }, K = /* @__PURE__ */ x({
53
- __name: "Tooltip",
54
- props: {
55
- data: {},
56
- categories: {},
57
- toolTipTitle: {},
58
- yFormatter: { type: Function }
59
- },
60
- setup(t) {
61
- const a = t, o = ["_index", "_stacked", "_ending"], i = $(() => Object.entries(a.data ?? []).filter(
62
- ([l, d]) => !o.includes(l) && Object.keys(a.categories).includes(l)
63
- ));
64
- return (l, d) => (c(), v("div", null, [
65
- T("div", ge, N(l.toolTipTitle), 1),
66
- (c(!0), v(O, null, U(i.value, ([s, u], L) => {
67
- var f;
68
- return c(), v("div", {
69
- key: s,
70
- style: { display: "flex", "align-items": "center", "margin-bottom": "4px" }
71
- }, [
72
- T("span", {
73
- style: P([{ width: "8px", height: "8px", "border-radius": "4px", "margin-right": "8px" }, {
74
- backgroundColor: (f = l.categories[s]) != null && f.color ? l.categories[s].color : `var(--vis-color${L})`
75
- }])
76
- }, null, 4),
77
- T("div", null, [
78
- T("span", {
79
- style: P([{ "font-weight": "600", "margin-right": "8px" }, { color: "var(--tooltip-label-color)" }])
80
- }, N(l.categories[s].name) + ":", 1),
81
- T("span", {
82
- style: P([{ "font-weight": "400" }, { color: "var(--tooltip-value-color)" }])
83
- }, N(l.yFormatter ? l.yFormatter(u) : u), 1)
84
- ])
85
- ]);
86
- }), 128))
87
- ]));
88
- }
89
- });
90
- var q = /* @__PURE__ */ ((t) => (t.Top = "top", t.Bottom = "bottom", t))(q || {});
91
- const fe = {
92
- ref: "slotWrapper",
93
- class: "hidden"
94
- }, E = 24, _ = 4, he = 0.5, ee = "#3b82f6", Ee = /* @__PURE__ */ x({
95
- __name: "AreaChart",
96
- props: {
97
- data: {},
98
- height: {},
99
- xLabel: {},
100
- yLabel: {},
101
- padding: { default: () => ({ top: 5, right: 5, bottom: 5, left: 5 }) },
102
- categories: {},
103
- markerConfig: {},
104
- xFormatter: {},
105
- yFormatter: {},
106
- curveType: {},
107
- lineWidth: { default: 2 },
108
- lineDashArray: {},
109
- xNumTicks: { default: (t) => t.data.length > E ? E / _ : t.data.length - 1 },
110
- xExplicitTicks: {},
111
- minMaxTicksOnly: { type: Boolean },
112
- yNumTicks: { default: (t) => t.data.length > E ? E / _ : t.data.length - 1 },
113
- hideLegend: { type: Boolean },
114
- hideTooltip: { type: Boolean },
115
- legendPosition: {},
116
- xDomainLine: { type: Boolean },
117
- yDomainLine: { type: Boolean },
118
- xTickLine: { type: Boolean },
119
- yTickLine: { type: Boolean },
120
- xGridLine: { type: Boolean },
121
- yGridLine: { type: Boolean },
122
- hideXAxis: { type: Boolean },
123
- hideYAxis: { type: Boolean },
124
- crosshairConfig: { default: () => ({
125
- color: "#666"
126
- }) }
127
- },
128
- emits: ["click"],
129
- setup(t, { emit: a }) {
130
- const o = a, i = t, l = X(), d = R("slotWrapper"), s = Y(), u = $(
131
- () => Object.values(i.categories).map((r) => r.color)
132
- ), L = $(() => i.markerConfig ? ne(i.markerConfig) : ""), f = $(() => i.legendPosition === q.Top), B = $(() => {
133
- const r = (p, k) => `
134
- <linearGradient id="gradient${p}-${k}" gradientTransform="rotate(90)">
135
- <stop offset="0%" stop-color="${k}" stop-opacity="1" />
136
- <stop offset="100%" stop-color="${k}" stop-opacity="0" />
137
- </linearGradient>
138
- `, m = (p, k) => `
139
- <linearGradient id="gradient${p}-${k}" gradientTransform="rotate(90)">
140
- <stop offset="0%" style="stop-color:var(--vis-color0);stop-opacity:1" />
141
- <stop offset="100%" style="stop-color:var(--vis-color0);stop-opacity:0" />
142
- </linearGradient>
143
- `;
144
- return u.value.map(
145
- (p, k) => p != null && p.includes("#") ? r(k, p) : m(k, p ?? ee)
146
- ).join("");
147
- });
148
- function g(r) {
149
- var m;
150
- return {
151
- y: (p) => Number(p[r]),
152
- color: ((m = i.categories[r]) == null ? void 0 : m.color) ?? ee
153
- };
154
- }
155
- function A(r) {
156
- return typeof window > "u" ? "" : d.value ? d.value.innerHTML : "";
157
- }
158
- function e(r) {
159
- return s.value = r, A();
160
- }
161
- return (r, m) => (c(), v("div", {
162
- class: w(["flex flex-col", { "flex-col-reverse": f.value, markers: !!i.markerConfig }]),
163
- onClick: m[0] || (m[0] = (p) => o("click", p, s.value))
164
- }, [
165
- y(n(W), {
166
- data: r.data,
167
- height: r.height,
168
- padding: r.padding,
169
- "svg-defs": B.value + L.value
170
- }, {
171
- default: j(() => [
172
- r.hideTooltip ? h("", !0) : (c(), b(n(I), {
173
- key: 0,
174
- "horizontal-placement": n(M).Right,
175
- "vertical-placement": n(M).Top
176
- }, null, 8, ["horizontal-placement", "vertical-placement"])),
177
- (c(!0), v(O, null, U(Object.keys(i.categories), (p, k) => (c(), v(O, { key: p }, [
178
- y(n(te), S({
179
- x: (G, Z) => Z
180
- }, { ref_for: !0 }, g(p), {
181
- color: `url(#gradient${k}-${u.value[k]})`,
182
- opacity: he,
183
- "curve-type": r.curveType ?? n(H).MonotoneX
184
- }), null, 16, ["x", "color", "curve-type"]),
185
- y(n(ie), {
186
- x: (G, Z) => Z,
187
- y: (G) => G[p],
188
- color: u.value[k],
189
- "curve-type": r.curveType ?? n(H).MonotoneX,
190
- "line-width": r.lineWidth,
191
- lineDashArray: r.lineDashArray
192
- }, null, 8, ["x", "y", "color", "curve-type", "line-width", "lineDashArray"])
193
- ], 64))), 128)),
194
- r.hideXAxis ? h("", !0) : (c(), b(n(D), {
195
- key: 1,
196
- type: "x",
197
- label: r.xLabel,
198
- "label-margin": 8,
199
- "num-ticks": r.xNumTicks,
200
- "tick-format": r.xFormatter,
201
- "tick-values": r.xExplicitTicks,
202
- "grid-line": r.xGridLine,
203
- "domain-line": r.xDomainLine,
204
- "tick-line": r.xTickLine,
205
- "min-max-ticks-only": r.minMaxTicksOnly
206
- }, null, 8, ["label", "num-ticks", "tick-format", "tick-values", "grid-line", "domain-line", "tick-line", "min-max-ticks-only"])),
207
- r.hideYAxis ? h("", !0) : (c(), b(n(D), {
208
- key: 2,
209
- type: "y",
210
- label: r.yLabel,
211
- "num-ticks": r.yNumTicks,
212
- "tick-format": r.yFormatter,
213
- "grid-line": r.yGridLine,
214
- "domain-line": r.yDomainLine,
215
- "tick-line": r.yTickLine
216
- }, null, 8, ["label", "num-ticks", "tick-format", "grid-line", "domain-line", "tick-line"])),
217
- r.hideTooltip ? h("", !0) : (c(), b(n(z), S({ key: 3 }, r.crosshairConfig, { template: e }), null, 16))
218
- ]),
219
- _: 1
220
- }, 8, ["data", "height", "padding", "svg-defs"]),
221
- r.hideLegend ? h("", !0) : (c(), v("div", {
222
- key: 0,
223
- class: w(["flex items-center justify-end", { "pb-4": f.value, "pt-4": !f.value }])
224
- }, [
225
- y(n(V), {
226
- items: Object.values(r.categories)
227
- }, null, 8, ["items"])
228
- ], 2)),
229
- T("div", fe, [
230
- n(l).tooltip ? C(r.$slots, "tooltip", {
231
- key: 0,
232
- values: s.value
233
- }) : s.value ? C(r.$slots, "fallback", { key: 1 }, () => [
234
- y(K, {
235
- data: s.value,
236
- categories: r.categories,
237
- toolTipTitle: n(J)(s.value) ?? "",
238
- yFormatter: i.yFormatter
239
- }, null, 8, ["data", "categories", "toolTipTitle", "yFormatter"])
240
- ]) : h("", !0)
241
- ], 512)
242
- ], 2));
243
- }
244
- }), ke = { class: "flex flex-col space-y-4" }, ve = { class: "flex items center justify-end" }, Ne = /* @__PURE__ */ x({
245
- __name: "AreaStackedChart",
246
- props: {
247
- data: {},
248
- height: {},
249
- categories: {},
250
- hideTooltip: { type: Boolean },
251
- xLabel: {},
252
- yLabel: {},
253
- padding: {},
254
- hideLegend: { type: Boolean },
255
- xGridLine: { type: Boolean },
256
- xDomainLine: { type: Boolean },
257
- yGridLine: { type: Boolean },
258
- yDomainLine: { type: Boolean },
259
- xTickLine: { type: Boolean },
260
- yTickLine: { type: Boolean },
261
- crosshairConfig: {}
262
- },
263
- setup(t) {
264
- const a = t, o = $(() => (d, s) => {
265
- if (typeof window > "u" || typeof document > "u")
266
- return "";
267
- try {
268
- const u = ae(K, {
269
- data: d,
270
- categories: a.categories
271
- }), L = document.createElement("div");
272
- u.mount(L);
273
- const f = L.innerHTML;
274
- return u.unmount(), f;
275
- } catch {
276
- return "";
277
- }
278
- }), i = (d) => Number.parseInt(d.time), l = [(d) => d.firstTime, (d) => d.returning];
279
- return (d, s) => (c(), v("div", ke, [
280
- y(n(W), {
281
- data: d.data,
282
- padding: d.padding,
283
- height: d.height
284
- }, {
285
- default: j(() => [
286
- y(n(te), {
287
- x: i,
288
- y: l,
289
- color: Object.values(a.categories).map((u) => u.color),
290
- "curve-type": n(H).Linear
291
- }, null, 8, ["color", "curve-type"]),
292
- y(n(D), {
293
- type: "x",
294
- label: "Time",
295
- "num-ticks": 12
296
- }),
297
- y(n(D), {
298
- type: "y",
299
- label: "Number of visitors",
300
- "num-ticks": 3
301
- }),
302
- d.hideTooltip ? h("", !0) : (c(), b(n(z), S({ key: 0 }, d.crosshairConfig, { template: o.value }), null, 16, ["template"]))
303
- ]),
304
- _: 1
305
- }, 8, ["data", "padding", "height"]),
306
- T("div", ve, [
307
- y(n(V), {
308
- items: Object.values(d.categories)
309
- }, null, 8, ["items"])
310
- ])
311
- ]));
312
- }
313
- }), Te = {
314
- ref: "slotWrapper",
315
- class: "hidden"
316
- }, Pe = /* @__PURE__ */ x({
317
- __name: "LineChart",
318
- props: {
319
- data: {},
320
- height: {},
321
- xLabel: {},
322
- yLabel: {},
323
- padding: { default: () => ({
324
- top: 5,
325
- right: 5,
326
- bottom: 5,
327
- left: 5
328
- }) },
329
- categories: {},
330
- markerConfig: {},
331
- xFormatter: {},
332
- yFormatter: {},
333
- curveType: {},
334
- lineWidth: { default: 2 },
335
- lineDashArray: {},
336
- xNumTicks: { default: (t) => t.data.length > 24 ? 24 / 4 : t.data.length - 1 },
337
- xExplicitTicks: {},
338
- minMaxTicksOnly: { type: Boolean },
339
- yNumTicks: { default: (t) => t.data.length > 24 ? 24 / 4 : t.data.length - 1 },
340
- hideTooltip: { type: Boolean },
341
- hideLegend: { type: Boolean },
342
- legendPosition: {},
343
- xGridLine: { type: Boolean },
344
- xDomainLine: { type: Boolean },
345
- yGridLine: { type: Boolean },
346
- yDomainLine: { type: Boolean },
347
- xTickLine: { type: Boolean },
348
- yTickLine: { type: Boolean },
349
- hideXAxis: { type: Boolean },
350
- hideYAxis: { type: Boolean },
351
- crosshairConfig: { default: () => ({
352
- color: "#666"
353
- }) }
354
- },
355
- emits: ["click"],
356
- setup(t, { emit: a }) {
357
- const o = a, i = t, l = $(() => i.markerConfig ? ne(i.markerConfig) : ""), d = X(), s = R("slotWrapper"), u = Y();
358
- function L(e) {
359
- return typeof window > "u" ? "" : s.value ? s.value.innerHTML : "";
360
- }
361
- function f(e) {
362
- return u.value = e, L();
363
- }
364
- const B = $(
365
- () => i.legendPosition === q.Top
366
- ), g = Object.values(i.categories).map(
367
- (e, r) => `var(--vis-color${r})`
368
- ), A = (e) => Object.values(i.categories)[e].color ?? g[e];
369
- return (e, r) => (c(), v("div", {
370
- class: w(["flex flex-col space-y-4", {
371
- "flex-col-reverse": B.value,
372
- markers: !!i.markerConfig
373
- }]),
374
- onClick: r[0] || (r[0] = (m) => o("click", m, u.value))
375
- }, [
376
- y(n(W), {
377
- data: e.data,
378
- padding: e.padding,
379
- height: e.height,
380
- svgDefs: l.value
381
- }, {
382
- default: j(() => [
383
- y(n(I), {
384
- "horizontal-placement": n(M).Right,
385
- "vertical-placement": n(M).Top
386
- }, null, 8, ["horizontal-placement", "vertical-placement"]),
387
- (c(!0), v(O, null, U(Object.keys(i.categories), (m, p) => (c(), b(n(ie), {
388
- key: p,
389
- x: (k, G) => G,
390
- y: (k) => k[m],
391
- color: A(p),
392
- "curve-type": e.curveType ?? n(H).MonotoneX,
393
- "line-width": e.lineWidth,
394
- lineDashArray: e.lineDashArray
395
- }, null, 8, ["x", "y", "color", "curve-type", "line-width", "lineDashArray"]))), 128)),
396
- e.hideXAxis ? h("", !0) : (c(), b(n(D), {
397
- key: 0,
398
- type: "x",
399
- "tick-format": e.xFormatter,
400
- label: e.xLabel,
401
- "label-margin": 8,
402
- "domain-line": e.xDomainLine,
403
- "grid-line": e.xGridLine,
404
- "tick-line": e.xTickLine,
405
- "num-ticks": e.xNumTicks,
406
- "tick-values": e.xExplicitTicks,
407
- "min-max-ticks-only": e.minMaxTicksOnly
408
- }, null, 8, ["tick-format", "label", "domain-line", "grid-line", "tick-line", "num-ticks", "tick-values", "min-max-ticks-only"])),
409
- e.hideYAxis ? h("", !0) : (c(), b(n(D), {
410
- key: 1,
411
- type: "y",
412
- "tick-format": e.yFormatter,
413
- label: e.yLabel,
414
- "num-ticks": e.yNumTicks,
415
- "domain-line": e.yDomainLine,
416
- "grid-line": e.yGridLine,
417
- "tick-line": e.yTickLine
418
- }, null, 8, ["tick-format", "label", "num-ticks", "domain-line", "grid-line", "tick-line"])),
419
- e.hideTooltip ? h("", !0) : (c(), b(n(z), S({ key: 2 }, e.crosshairConfig, { template: f }), null, 16))
420
- ]),
421
- _: 1
422
- }, 8, ["data", "padding", "height", "svgDefs"]),
423
- e.hideLegend ? h("", !0) : (c(), v("div", {
424
- key: 0,
425
- class: w(["flex items center justify-end", { "pb-4": B.value }])
426
- }, [
427
- y(n(V), {
428
- items: Object.values(e.categories)
429
- }, null, 8, ["items"])
430
- ], 2)),
431
- T("div", Te, [
432
- n(d).tooltip ? C(e.$slots, "tooltip", {
433
- key: 0,
434
- values: u.value
435
- }) : u.value ? C(e.$slots, "fallback", { key: 1 }, () => [
436
- y(K, {
437
- data: u.value,
438
- categories: e.categories,
439
- toolTipTitle: n(J)(u.value) ?? "",
440
- yFormatter: i.yFormatter
441
- }, null, 8, ["data", "categories", "toolTipTitle", "yFormatter"])
442
- ]) : h("", !0)
443
- ], 512)
444
- ], 2));
445
- }
446
- });
447
- function be(t) {
448
- return $(() => {
449
- const a = Le(t.categories), o = $e(t.categories, a), i = Be(o, t.categories), l = Ce(o), d = Ae(i), s = De(a);
450
- console.log(t, "config");
451
- const u = t.stackAndGrouped ? ye(t.data, t.xAxis) : t.data;
452
- return {
453
- states: a,
454
- groupedByState: o,
455
- colors: i,
456
- bars: l,
457
- colorFunctions: d,
458
- positions: s,
459
- chartData: u
460
- };
461
- });
462
- }
463
- function Le(t) {
464
- const a = /* @__PURE__ */ new Set();
465
- return Object.keys(t).forEach((i) => {
466
- const l = i.match(/([A-Z][a-z]+)$/);
467
- l && a.add(l[1]);
468
- }), Array.from(a);
469
- }
470
- function $e(t, a) {
471
- const o = {};
472
- return a.forEach((i) => {
473
- o[i] = Object.keys(t).filter(
474
- (l) => l.endsWith(i)
475
- );
476
- }), o;
477
- }
478
- function Be(t, a) {
479
- const o = {};
480
- return Object.entries(t).forEach(([i, l]) => {
481
- o[i] = l.map((d) => {
482
- var s;
483
- return ((s = a[d]) == null ? void 0 : s.color) ?? "#ccc";
484
- });
485
- }), o;
486
- }
487
- function Ce(t) {
488
- const a = {};
489
- return Object.entries(t).forEach(([o, i]) => {
490
- a[o] = i.map((l) => {
491
- const d = l.replace(o, "").toLowerCase();
492
- return (s) => s[d + o];
493
- });
494
- }), a;
495
- }
496
- function Ae(t) {
497
- const a = {};
498
- return Object.entries(t).forEach(([o, i]) => {
499
- a[o] = (l, d) => i[d] ?? "#ccc";
500
- }), a;
501
- }
502
- function De(t) {
503
- const a = t.length, o = 0.4, i = {};
504
- return t.forEach((l, d) => {
505
- const s = (d - (a - 1) / 2) * o;
506
- i[l] = s;
507
- }), i;
508
- }
509
- const Fe = {
510
- ref: "slotWrapper",
511
- class: "hidden"
512
- }, Se = /* @__PURE__ */ x({
513
- __name: "BarChart",
514
- props: {
515
- data: {},
516
- stacked: { type: Boolean },
517
- height: {},
518
- xLabel: {},
519
- yLabel: {},
520
- padding: { default: () => ({
521
- top: 5,
522
- right: 5,
523
- bottom: 5,
524
- left: 5
525
- }) },
526
- categories: {},
527
- xFormatter: {},
528
- yFormatter: {},
529
- yNumTicks: { default: (t) => t.data.length > 24 ? 24 / 4 : t.data.length - 1 },
530
- minMaxTicksOnly: { type: Boolean },
531
- xNumTicks: { default: (t) => t.data.length > 24 ? 24 / 4 : t.data.length - 1 },
532
- xExplicitTicks: {},
533
- yAxis: {},
534
- groupPadding: {},
535
- barPadding: {},
536
- radius: {},
537
- hideLegend: { type: Boolean },
538
- hideTooltip: { type: Boolean, default: !1 },
539
- orientation: { default: F.Vertical },
540
- legendPosition: {},
541
- xDomainLine: { type: Boolean },
542
- yDomainLine: { type: Boolean },
543
- xTickLine: { type: Boolean },
544
- yTickLine: { type: Boolean },
545
- xGridLine: { type: Boolean },
546
- yGridLine: { type: Boolean, default: !0 },
547
- hideXAxis: { type: Boolean },
548
- hideYAxis: { type: Boolean },
549
- stackAndGrouped: { type: Boolean },
550
- xAxis: {}
551
- },
552
- emits: ["click"],
553
- setup(t, { emit: a }) {
554
- const o = a, i = t, l = X(), d = R("slotWrapper"), s = Y();
555
- if (!i.yAxis || i.yAxis.length === 0)
556
- throw new Error("yAxis is required");
557
- const u = $(() => i.yAxis.map((e) => (r) => r[e])), L = (e, r) => {
558
- var m;
559
- return (m = Object.values(i.categories)[r]) == null ? void 0 : m.color;
560
- }, f = be({
561
- data: i.data,
562
- categories: i.categories,
563
- stackAndGrouped: i.stackAndGrouped,
564
- xAxis: i.xAxis
565
- }), B = $(
566
- () => i.legendPosition === q.Top
567
- );
568
- function g(e) {
569
- return s.value = e, A();
570
- }
571
- function A(e) {
572
- return typeof window > "u" ? "" : d.value ? d.value.innerHTML : "";
573
- }
574
- return (e, r) => (c(), v("div", {
575
- class: w(["flex flex-col space-y-4", { "flex-col-reverse": B.value }]),
576
- onClick: r[0] || (r[0] = (m) => o("click", m, s.value))
577
- }, [
578
- y(n(W), {
579
- padding: e.padding,
580
- height: e.height
581
- }, {
582
- default: j(() => [
583
- y(n(I), {
584
- triggers: {
585
- [n(le).selectors.bar]: g,
586
- [n(re).selectors.bar]: g
587
- }
588
- }, null, 8, ["triggers"]),
589
- e.stackAndGrouped ? (c(!0), v(O, { key: 0 }, U(n(f).states, (m) => (c(), b(n(Q), {
590
- key: m,
591
- data: n(f).chartData,
592
- x: (p, k) => k + n(f).positions[m],
593
- y: n(f).bars[m],
594
- color: n(f).colorFunctions[m],
595
- "rounded-corners": e.radius ?? 0,
596
- "group-padding": e.groupPadding ?? 0,
597
- "bar-padding": e.barPadding ?? 0.2,
598
- orientation: e.orientation ?? n(F).Vertical
599
- }, null, 8, ["data", "x", "y", "color", "rounded-corners", "group-padding", "bar-padding", "orientation"]))), 128)) : e.stacked ? (c(), b(n(Q), {
600
- key: 2,
601
- data: e.data,
602
- x: (m, p) => p,
603
- y: u.value,
604
- color: L,
605
- "rounded-corners": e.radius ?? 0,
606
- "group-padding": e.groupPadding ?? 0,
607
- "bar-padding": e.barPadding ?? 0.2,
608
- orientation: e.orientation ?? n(F).Vertical
609
- }, null, 8, ["data", "x", "y", "rounded-corners", "group-padding", "bar-padding", "orientation"])) : (c(), b(n(de), {
610
- key: 1,
611
- data: e.data,
612
- x: (m, p) => p,
613
- y: u.value,
614
- color: L,
615
- "rounded-corners": e.radius ?? 0,
616
- "group-padding": e.groupPadding ?? 0,
617
- "bar-padding": e.barPadding ?? 0.2,
618
- orientation: e.orientation ?? n(F).Vertical
619
- }, null, 8, ["data", "x", "y", "rounded-corners", "group-padding", "bar-padding", "orientation"])),
620
- e.hideXAxis ? h("", !0) : (c(), b(n(D), {
621
- key: 3,
622
- type: "x",
623
- "tick-format": e.xFormatter,
624
- label: e.xLabel,
625
- "grid-line": e.xGridLine,
626
- "domain-line": !!e.xDomainLine,
627
- "tick-line": e.xTickLine,
628
- "num-ticks": e.xNumTicks,
629
- "tick-values": e.xExplicitTicks,
630
- minMaxTicksOnly: e.minMaxTicksOnly
631
- }, null, 8, ["tick-format", "label", "grid-line", "domain-line", "tick-line", "num-ticks", "tick-values", "minMaxTicksOnly"])),
632
- e.hideYAxis ? h("", !0) : (c(), b(n(D), {
633
- key: 4,
634
- type: "y",
635
- label: e.yLabel,
636
- "grid-line": e.orientation !== n(F).Horizontal && e.yGridLine,
637
- "domain-line": !!e.yDomainLine,
638
- "tick-format": e.yFormatter,
639
- "num-ticks": e.yNumTicks,
640
- "tick-line": e.yTickLine
641
- }, null, 8, ["label", "grid-line", "domain-line", "tick-format", "num-ticks", "tick-line"]))
642
- ]),
643
- _: 1
644
- }, 8, ["padding", "height"]),
645
- e.hideLegend ? h("", !0) : (c(), v("div", {
646
- key: 0,
647
- class: w(["flex items center justify-end", { "pb-4": B.value }])
648
- }, [
649
- y(n(V), {
650
- items: Object.values(i.categories)
651
- }, null, 8, ["items"])
652
- ], 2)),
653
- T("div", Fe, [
654
- n(l).tooltip ? C(e.$slots, "tooltip", {
655
- key: 0,
656
- values: s.value
657
- }) : s.value ? C(e.$slots, "fallback", { key: 1 }, () => [
658
- y(K, {
659
- data: s.value,
660
- categories: i.categories,
661
- toolTipTitle: n(J)(s.value) ?? "",
662
- yFormatter: i.orientation === n(F).Horizontal ? i.xFormatter : i.yFormatter
663
- }, null, 8, ["data", "categories", "toolTipTitle", "yFormatter"])
664
- ]) : h("", !0)
665
- ], 512)
666
- ], 2));
667
- }
668
- });
669
- var oe = /* @__PURE__ */ ((t) => (t.Half = "half", t.Full = "full", t))(oe || {});
670
- const Oe = {
671
- ref: "slotWrapper",
672
- class: "hidden"
673
- }, we = { class: "flex items-center" }, xe = {
674
- key: 0,
675
- class: "flex items-center justify-center mt-4"
676
- }, Me = /* @__PURE__ */ x({
677
- __name: "DonutChart",
678
- props: {
679
- type: {},
680
- data: {},
681
- height: {},
682
- radius: {},
683
- hideLegend: { type: Boolean },
684
- labels: {},
685
- padAngle: {}
686
- },
687
- emits: ["click"],
688
- setup(t, { emit: a }) {
689
- const o = a, i = t, l = X(), d = R("slotWrapper"), s = Y(), u = (g) => g, L = i.type === oe.Half;
690
- function f(g) {
691
- return s.value = g, B();
692
- }
693
- function B(g) {
694
- return typeof window > "u" ? "" : d.value ? d.value.innerHTML : "";
695
- }
696
- return (g, A) => (c(), v(O, null, [
697
- T("div", {
698
- class: "flex items-center justify-center",
699
- onClick: A[0] || (A[0] = (e) => o("click", e, s.value))
700
- }, [
701
- y(n(ce), {
702
- data: g.data,
703
- height: g.height,
704
- margin: {}
705
- }, {
706
- default: j(() => [
707
- y(n(I), {
708
- "horizontal-shift": 20,
709
- "vertical-shift": 20,
710
- triggers: {
711
- [n(se).selectors.segment]: f
712
- }
713
- }, null, 8, ["triggers"]),
714
- y(n(ue), {
715
- value: u,
716
- "corner-radius": g.radius,
717
- color: i.labels.map((e) => e.color),
718
- "angle-range": L ? [-1.5707963267948966, 1.5707963267948966] : [],
719
- "pad-angle": i.padAngle || 0
720
- }, null, 8, ["corner-radius", "color", "angle-range", "pad-angle"])
721
- ]),
722
- _: 1
723
- }, 8, ["data", "height"]),
724
- C(g.$slots, "default"),
725
- T("div", Oe, [
726
- n(l).tooltip ? C(g.$slots, "tooltip", {
727
- key: 0,
728
- values: s.value
729
- }) : s.value ? C(g.$slots, "fallback", { key: 1 }, () => [
730
- T("div", we, [
731
- T("div", {
732
- class: "w-2 h-2 rounded-full mr-2",
733
- style: P(`background-color: ${i.labels[s.value.index].color} ;`)
734
- }, null, 4),
735
- T("div", null, N(s.value.data), 1)
736
- ])
737
- ]) : h("", !0)
738
- ], 512)
739
- ]),
740
- g.hideLegend ? h("", !0) : (c(), v("div", xe, [
741
- y(n(V), { items: g.labels }, null, 8, ["items"])
742
- ]))
743
- ], 64));
744
- }
745
- });
746
- export {
747
- Ee as AreaChart,
748
- Ne as AreaStackedChart,
749
- Se as BarChart,
750
- Me as DonutChart,
751
- q as LegendPosition,
752
- Pe as LineChart
753
- };