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

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,170 @@
1
+ import { defineComponent as C, useSlots as N, useTemplateRef as O, ref as D, computed as T, createElementBlock as m, openBlock as n, normalizeClass as L, createVNode as g, createCommentVNode as c, createElementVNode as w, unref as i, withCtx as E, createBlock as u, Fragment as M, renderList as S, renderSlot as v } from "vue";
2
+ import { Orientation as l, StackedBar as j, GroupedBar as z } from "@unovis/ts";
3
+ import { getFirstPropertyValue as H } from "../../utils.js";
4
+ import { useStackedGrouped as W } from "./stackedGroupedUtils.js";
5
+ import { VisXYContainer as X, VisTooltip as Y, VisStackedBar as B, VisGroupedBar as $, VisAxis as A, VisBulletLegend as R } from "@unovis/vue";
6
+ import q from "../Tooltip.js";
7
+ import { LegendPosition as U } from "../../types.js";
8
+ const I = {
9
+ ref: "slotWrapper",
10
+ class: "hidden"
11
+ }, ae = /* @__PURE__ */ C({
12
+ __name: "BarChart",
13
+ props: {
14
+ data: {},
15
+ stacked: { type: Boolean },
16
+ height: {},
17
+ xLabel: {},
18
+ yLabel: {},
19
+ padding: { default: () => ({
20
+ top: 5,
21
+ right: 5,
22
+ bottom: 5,
23
+ left: 5
24
+ }) },
25
+ categories: {},
26
+ xFormatter: {},
27
+ yFormatter: {},
28
+ yNumTicks: { default: (t) => t.data.length > 24 ? 24 / 4 : t.data.length - 1 },
29
+ minMaxTicksOnly: { type: Boolean },
30
+ xNumTicks: { default: (t) => t.data.length > 24 ? 24 / 4 : t.data.length - 1 },
31
+ xExplicitTicks: {},
32
+ yAxis: {},
33
+ groupPadding: {},
34
+ barPadding: {},
35
+ radius: {},
36
+ hideLegend: { type: Boolean },
37
+ hideTooltip: { type: Boolean, default: !1 },
38
+ orientation: { default: l.Vertical },
39
+ legendPosition: {},
40
+ xDomainLine: { type: Boolean },
41
+ yDomainLine: { type: Boolean },
42
+ xTickLine: { type: Boolean },
43
+ yTickLine: { type: Boolean },
44
+ xGridLine: { type: Boolean },
45
+ yGridLine: { type: Boolean, default: !0 },
46
+ hideXAxis: { type: Boolean },
47
+ hideYAxis: { type: Boolean },
48
+ stackAndGrouped: { type: Boolean },
49
+ xAxis: {}
50
+ },
51
+ emits: ["click"],
52
+ setup(t, { emit: V }) {
53
+ const x = V, a = t, P = N(), y = O("slotWrapper"), r = D();
54
+ if (!a.yAxis || a.yAxis.length === 0)
55
+ throw new Error("yAxis is required");
56
+ const k = T(() => a.yAxis.map((e) => (d) => d[e])), f = (e, d) => {
57
+ var o;
58
+ return (o = Object.values(a.categories)[d]) == null ? void 0 : o.color;
59
+ }, s = W({
60
+ data: a.data,
61
+ categories: a.categories,
62
+ stackAndGrouped: a.stackAndGrouped,
63
+ xAxis: a.xAxis
64
+ }), h = T(
65
+ () => a.legendPosition === U.Top
66
+ );
67
+ function b(e) {
68
+ return r.value = e, G();
69
+ }
70
+ function G(e) {
71
+ return typeof window > "u" ? "" : y.value ? y.value.innerHTML : "";
72
+ }
73
+ return (e, d) => (n(), m("div", {
74
+ class: L(["flex flex-col space-y-4", { "flex-col-reverse": h.value }]),
75
+ onClick: d[0] || (d[0] = (o) => x("click", o, r.value))
76
+ }, [
77
+ g(i(X), {
78
+ padding: e.padding,
79
+ height: e.height
80
+ }, {
81
+ default: E(() => [
82
+ g(i(Y), {
83
+ triggers: {
84
+ [i(z).selectors.bar]: b,
85
+ [i(j).selectors.bar]: b
86
+ }
87
+ }, null, 8, ["triggers"]),
88
+ e.stackAndGrouped ? (n(!0), m(M, { key: 0 }, S(i(s).states, (o) => (n(), u(i(B), {
89
+ key: o,
90
+ data: i(s).chartData,
91
+ x: (p, F) => F + i(s).positions[o],
92
+ y: i(s).bars[o],
93
+ color: i(s).colorFunctions[o],
94
+ "rounded-corners": e.radius ?? 0,
95
+ "group-padding": e.groupPadding ?? 0,
96
+ "bar-padding": e.barPadding ?? 0.2,
97
+ orientation: e.orientation ?? i(l).Vertical
98
+ }, null, 8, ["data", "x", "y", "color", "rounded-corners", "group-padding", "bar-padding", "orientation"]))), 128)) : e.stacked ? (n(), u(i(B), {
99
+ key: 2,
100
+ data: e.data,
101
+ x: (o, p) => p,
102
+ y: k.value,
103
+ color: f,
104
+ "rounded-corners": e.radius ?? 0,
105
+ "group-padding": e.groupPadding ?? 0,
106
+ "bar-padding": e.barPadding ?? 0.2,
107
+ orientation: e.orientation ?? i(l).Vertical
108
+ }, null, 8, ["data", "x", "y", "rounded-corners", "group-padding", "bar-padding", "orientation"])) : (n(), u(i($), {
109
+ key: 1,
110
+ data: e.data,
111
+ x: (o, p) => p,
112
+ y: k.value,
113
+ color: f,
114
+ "rounded-corners": e.radius ?? 0,
115
+ "group-padding": e.groupPadding ?? 0,
116
+ "bar-padding": e.barPadding ?? 0.2,
117
+ orientation: e.orientation ?? i(l).Vertical
118
+ }, null, 8, ["data", "x", "y", "rounded-corners", "group-padding", "bar-padding", "orientation"])),
119
+ e.hideXAxis ? c("", !0) : (n(), u(i(A), {
120
+ key: 3,
121
+ type: "x",
122
+ "tick-format": e.xFormatter,
123
+ label: e.xLabel,
124
+ "grid-line": e.xGridLine,
125
+ "domain-line": !!e.xDomainLine,
126
+ "tick-line": e.xTickLine,
127
+ "num-ticks": e.xNumTicks,
128
+ "tick-values": e.xExplicitTicks,
129
+ minMaxTicksOnly: e.minMaxTicksOnly
130
+ }, null, 8, ["tick-format", "label", "grid-line", "domain-line", "tick-line", "num-ticks", "tick-values", "minMaxTicksOnly"])),
131
+ e.hideYAxis ? c("", !0) : (n(), u(i(A), {
132
+ key: 4,
133
+ type: "y",
134
+ label: e.yLabel,
135
+ "grid-line": e.orientation !== i(l).Horizontal && e.yGridLine,
136
+ "domain-line": !!e.yDomainLine,
137
+ "tick-format": e.yFormatter,
138
+ "num-ticks": e.yNumTicks,
139
+ "tick-line": e.yTickLine
140
+ }, null, 8, ["label", "grid-line", "domain-line", "tick-format", "num-ticks", "tick-line"]))
141
+ ]),
142
+ _: 1
143
+ }, 8, ["padding", "height"]),
144
+ e.hideLegend ? c("", !0) : (n(), m("div", {
145
+ key: 0,
146
+ class: L(["flex items center justify-end", { "pb-4": h.value }])
147
+ }, [
148
+ g(i(R), {
149
+ items: Object.values(a.categories)
150
+ }, null, 8, ["items"])
151
+ ], 2)),
152
+ w("div", I, [
153
+ i(P).tooltip ? v(e.$slots, "tooltip", {
154
+ key: 0,
155
+ values: r.value
156
+ }) : r.value ? v(e.$slots, "fallback", { key: 1 }, () => [
157
+ g(q, {
158
+ data: r.value,
159
+ categories: a.categories,
160
+ toolTipTitle: i(H)(r.value) ?? "",
161
+ yFormatter: a.orientation === i(l).Horizontal ? a.xFormatter : a.yFormatter
162
+ }, null, 8, ["data", "categories", "toolTipTitle", "yFormatter"])
163
+ ]) : c("", !0)
164
+ ], 512)
165
+ ], 2));
166
+ }
167
+ });
168
+ export {
169
+ ae as default
170
+ };
@@ -0,0 +1,4 @@
1
+ import f from "./BarChart.js";
2
+ export {
3
+ f as default
4
+ };
@@ -0,0 +1,67 @@
1
+ import { computed as u } from "vue";
2
+ import { flattenData as i } from "../../utils.js";
3
+ function b(t) {
4
+ return u(() => {
5
+ const o = f(t.categories), e = l(t.categories, o), r = p(e, t.categories), c = d(e), n = m(r), s = h(o);
6
+ console.log(t, "config");
7
+ const a = t.stackAndGrouped ? i(t.data, t.xAxis) : t.data;
8
+ return {
9
+ states: o,
10
+ groupedByState: e,
11
+ colors: r,
12
+ bars: c,
13
+ colorFunctions: n,
14
+ positions: s,
15
+ chartData: a
16
+ };
17
+ });
18
+ }
19
+ function f(t) {
20
+ const o = /* @__PURE__ */ new Set();
21
+ return Object.keys(t).forEach((r) => {
22
+ const c = r.match(/([A-Z][a-z]+)$/);
23
+ c && o.add(c[1]);
24
+ }), Array.from(o);
25
+ }
26
+ function l(t, o) {
27
+ const e = {};
28
+ return o.forEach((r) => {
29
+ e[r] = Object.keys(t).filter(
30
+ (c) => c.endsWith(r)
31
+ );
32
+ }), e;
33
+ }
34
+ function p(t, o) {
35
+ const e = {};
36
+ return Object.entries(t).forEach(([r, c]) => {
37
+ e[r] = c.map((n) => {
38
+ var s;
39
+ return ((s = o[n]) == null ? void 0 : s.color) ?? "#ccc";
40
+ });
41
+ }), e;
42
+ }
43
+ function d(t) {
44
+ const o = {};
45
+ return Object.entries(t).forEach(([e, r]) => {
46
+ o[e] = r.map((c) => {
47
+ const n = c.replace(e, "").toLowerCase();
48
+ return (s) => s[n + e];
49
+ });
50
+ }), o;
51
+ }
52
+ function m(t) {
53
+ const o = {};
54
+ return Object.entries(t).forEach(([e, r]) => {
55
+ o[e] = (c, n) => r[n] ?? "#ccc";
56
+ }), o;
57
+ }
58
+ function h(t) {
59
+ const o = t.length, e = 0.4, r = {};
60
+ return t.forEach((c, n) => {
61
+ const s = (n - (o - 1) / 2) * e;
62
+ r[c] = s;
63
+ }), r;
64
+ }
65
+ export {
66
+ b as useStackedGrouped
67
+ };
@@ -0,0 +1,48 @@
1
+ import { defineComponent as b, computed as v, createElementBlock as r, openBlock as l, createElementVNode as o, toDisplayString as i, Fragment as y, renderList as h, normalizeStyle as n } from "vue";
2
+ const f = {
3
+ class: "capitalize border-b mb-1 pb-1",
4
+ style: {
5
+ color: "var(--tooltip-value-color)",
6
+ borderColor: "rgba(255, 255, 255, 0.05)"
7
+ }
8
+ }, F = /* @__PURE__ */ b({
9
+ __name: "Tooltip",
10
+ props: {
11
+ data: {},
12
+ categories: {},
13
+ toolTipTitle: {},
14
+ yFormatter: { type: Function }
15
+ },
16
+ setup(p) {
17
+ const a = p, d = ["_index", "_stacked", "_ending"], m = v(() => Object.entries(a.data ?? []).filter(
18
+ ([e, g]) => !d.includes(e) && Object.keys(a.categories).includes(e)
19
+ ));
20
+ return (e, g) => (l(), r("div", null, [
21
+ o("div", f, i(e.toolTipTitle), 1),
22
+ (l(!0), r(y, null, h(m.value, ([t, s], u) => {
23
+ var c;
24
+ return l(), r("div", {
25
+ key: t,
26
+ style: { display: "flex", "align-items": "center", "margin-bottom": "4px" }
27
+ }, [
28
+ o("span", {
29
+ style: n([{ width: "8px", height: "8px", "border-radius": "4px", "margin-right": "8px" }, {
30
+ backgroundColor: (c = e.categories[t]) != null && c.color ? e.categories[t].color : `var(--vis-color${u})`
31
+ }])
32
+ }, null, 4),
33
+ o("div", null, [
34
+ o("span", {
35
+ style: n([{ "font-weight": "600", "margin-right": "8px" }, { color: "var(--tooltip-label-color)" }])
36
+ }, i(e.categories[t].name) + ":", 1),
37
+ o("span", {
38
+ style: n([{ "font-weight": "400" }, { color: "var(--tooltip-value-color)" }])
39
+ }, i(e.yFormatter ? e.yFormatter(s) : s), 1)
40
+ ])
41
+ ]);
42
+ }), 128))
43
+ ]));
44
+ }
45
+ });
46
+ export {
47
+ F as default
48
+ };
@@ -0,0 +1,4 @@
1
+ import f from "./Tooltip.js";
2
+ export {
3
+ f as default
4
+ };
package/dist/index.d.ts CHANGED
@@ -1,7 +1,2 @@
1
- import { default as AreaChart } from './components/AreaChart/AreaChart.vue';
2
- import { default as AreaStackedChart } from './components/AreaStackedChart/AreaStackedChart.vue';
3
- import { default as LineChart } from './components/LineChart/LineChart.vue';
4
- import { default as BarChart } from './components/BarChart/BarChart.vue';
5
- import { default as DonutChart } from './components/DonutChart/DonutChart.vue';
6
- import { LegendPosition } from './types';
7
- export { AreaChart, AreaStackedChart, LineChart, BarChart, DonutChart, LegendPosition };
1
+ export { default as BarChart } from './components/BarChart/BarChart.vue';
2
+ export { LegendPosition } from './types';
package/dist/index.js ADDED
@@ -0,0 +1,6 @@
1
+ import { default as e } from "./components/BarChart/BarChart.js";
2
+ import { LegendPosition as a } from "./types.js";
3
+ export {
4
+ e as BarChart,
5
+ a as LegendPosition
6
+ };
package/dist/types.js ADDED
@@ -0,0 +1,4 @@
1
+ var o = /* @__PURE__ */ ((t) => (t.Top = "top", t.Bottom = "bottom", t))(o || {});
2
+ export {
3
+ o as LegendPosition
4
+ };
package/dist/utils.js ADDED
@@ -0,0 +1,24 @@
1
+ function u(t) {
2
+ if (t && Object.keys(t).length > 0) {
3
+ const c = Object.keys(t)[0];
4
+ return t[c];
5
+ }
6
+ }
7
+ function o(t) {
8
+ return t.charAt(0).toUpperCase() + t.slice(1);
9
+ }
10
+ const a = (t, c) => {
11
+ const s = Object.keys(t[0]).filter((e) => e !== c), i = Object.keys(t[0][s[0]]);
12
+ return t.map((e) => ({
13
+ month: e.month,
14
+ ...s.flatMap(
15
+ (r) => i.map((n) => ({
16
+ [`${r}${o(n)}`]: e[r][n]
17
+ }))
18
+ ).reduce((r, n) => ({ ...r, ...n }), {})
19
+ }));
20
+ };
21
+ export {
22
+ a as flattenData,
23
+ u as getFirstPropertyValue
24
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vue-chrts",
3
- "version": "0.2.0-test.7",
3
+ "version": "0.2.0-test.9",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"
@@ -20,6 +20,8 @@
20
20
  "release": "commit-and-tag-version"
21
21
  },
22
22
  "peerDependencies": {
23
+ "@unovis/ts": "^1.5.2",
24
+ "@unovis/vue": "^1.5.2",
23
25
  "vue": "^3.5.13"
24
26
  },
25
27
  "devDependencies": {
@@ -1,21 +0,0 @@
1
- import { AreaChartProps } from './types';
2
- declare const _default: <T>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
3
- props: __VLS_PrettifyLocal<Pick<Partial<{}> & Omit<{
4
- readonly onClick?: ((event: MouseEvent, values?: T | undefined) => any) | undefined;
5
- } & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps, never>, "onClick"> & AreaChartProps<T> & Partial<{}>> & import('vue').PublicProps;
6
- expose(exposed: import('vue').ShallowUnwrapRef<{}>): void;
7
- attrs: any;
8
- slots: {
9
- tooltip?(_: {
10
- values: T | undefined;
11
- }): any;
12
- fallback?(_: {}): any;
13
- };
14
- emit: (e: "click", event: MouseEvent, values?: T) => void;
15
- }>) => import('vue').VNode & {
16
- __ctx?: Awaited<typeof __VLS_setup>;
17
- };
18
- export default _default;
19
- type __VLS_PrettifyLocal<T> = {
20
- [K in keyof T]: T[K];
21
- } & {};
@@ -1,14 +0,0 @@
1
- import { AreaStackedChartProps } from './types';
2
- declare const _default: <T>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
3
- props: __VLS_PrettifyLocal<Pick<Partial<{}> & Omit<{} & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps, never>, never> & AreaStackedChartProps<T> & Partial<{}>> & import('vue').PublicProps;
4
- expose(exposed: import('vue').ShallowUnwrapRef<{}>): void;
5
- attrs: any;
6
- slots: {};
7
- emit: {};
8
- }>) => import('vue').VNode & {
9
- __ctx?: Awaited<typeof __VLS_setup>;
10
- };
11
- export default _default;
12
- type __VLS_PrettifyLocal<T> = {
13
- [K in keyof T]: T[K];
14
- } & {};
@@ -1,22 +0,0 @@
1
- import { DonutChartProps } from './types';
2
- declare const _default: <T extends {}>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
3
- props: __VLS_PrettifyLocal<Pick<Partial<{}> & Omit<{
4
- readonly onClick?: ((event: MouseEvent, values?: any) => any) | undefined;
5
- } & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps, never>, "onClick"> & DonutChartProps & Partial<{}>> & import('vue').PublicProps;
6
- expose(exposed: import('vue').ShallowUnwrapRef<{}>): void;
7
- attrs: any;
8
- slots: {
9
- default?(_: {}): any;
10
- tooltip?(_: {
11
- values: any;
12
- }): any;
13
- fallback?(_: {}): any;
14
- };
15
- emit: (e: "click", event: MouseEvent, values?: any) => void;
16
- }>) => import('vue').VNode & {
17
- __ctx?: Awaited<typeof __VLS_setup>;
18
- };
19
- export default _default;
20
- type __VLS_PrettifyLocal<T> = {
21
- [K in keyof T]: T[K];
22
- } & {};
@@ -1,21 +0,0 @@
1
- import { LineChartProps } from './types';
2
- declare const _default: <T>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
3
- props: __VLS_PrettifyLocal<Pick<Partial<{}> & Omit<{
4
- readonly onClick?: ((event: MouseEvent, values?: T | undefined) => any) | undefined;
5
- } & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps, never>, "onClick"> & LineChartProps<T> & Partial<{}>> & import('vue').PublicProps;
6
- expose(exposed: import('vue').ShallowUnwrapRef<{}>): void;
7
- attrs: any;
8
- slots: {
9
- tooltip?(_: {
10
- values: T | undefined;
11
- }): any;
12
- fallback?(_: {}): any;
13
- };
14
- emit: (e: "click", event: MouseEvent, values?: T) => void;
15
- }>) => import('vue').VNode & {
16
- __ctx?: Awaited<typeof __VLS_setup>;
17
- };
18
- export default _default;
19
- type __VLS_PrettifyLocal<T> = {
20
- [K in keyof T]: T[K];
21
- } & {};
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
- };