@orchidui/dashboard 1.23.1-8 → 1.23.2

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,148 @@
1
+ import { computed as s, ref as w, watch as F, createElementBlock as S, openBlock as k } from "vue";
2
+ import { useChart as B } from "./Dashboard/composables/useChart.js";
3
+ import { d as l } from "./dayjs.min-CTPVfFeV.js";
4
+ const O = {
5
+ __name: "OcOverviewMonthlyBarChart",
6
+ props: {
7
+ variant: {
8
+ type: String,
9
+ validator: (d) => ["primary", "purple"].includes(d)
10
+ },
11
+ showTooltip: Boolean,
12
+ showLegend: Boolean,
13
+ showGrid: Boolean,
14
+ chartData: Array,
15
+ labelData: Array,
16
+ yAxisFormatter: Function,
17
+ xAxisFormatter: Function,
18
+ tooltipFormatter: Function,
19
+ tooltipValueFormatter: Function
20
+ },
21
+ setup(d) {
22
+ const a = d, i = s(() => a.labelData.length === 30), x = s(() => Math.max(...a.chartData));
23
+ s(() => a.chartData.indexOf(x.value));
24
+ const y = (t, e = "SGD") => (typeof t == "number" ? t : Number(t)).toLocaleString("en-US", {
25
+ minimumFractionDigits: 2,
26
+ maximumFractionDigits: 2
27
+ }), g = (t, e = !1) => e ? l(t).format("DD MMM").toUpperCase() : l(t).format("ddd DD/MM").toUpperCase(), D = (t) => {
28
+ const e = [...a.chartData].sort((r, c) => c - r);
29
+ return t === e[0] ? "#4C8AFD" : t === e[1] ? "#80ACFE" : "#CCDEFE";
30
+ }, b = s(() => ({
31
+ xAxis: {
32
+ data: a.labelData.map((t) => g(t, i.value)),
33
+ splitLine: { show: !1 },
34
+ axisLine: { show: !1 },
35
+ axisTick: { show: !1 },
36
+ axisLabel: {
37
+ color: "#9295A5",
38
+ fontSize: 10,
39
+ margin: 4,
40
+ width: 70,
41
+ interval: i.value ? 3 : 0
42
+ }
43
+ },
44
+ tooltip: {
45
+ trigger: "axis",
46
+ borderWidth: 0,
47
+ padding: 0,
48
+ axisPointer: {
49
+ type: "line",
50
+ lineStyle: { color: "#2465DE" }
51
+ },
52
+ formatter: (t) => {
53
+ const e = a.labelData.find(
54
+ (u) => l(u).format("DD MMM") === t[0].name
55
+ ), r = l(e).format("DD MMM YYYY"), c = t[0].value;
56
+ return `
57
+ <div class="py-3 px-4">
58
+ <div class="flex items-center gap-2">
59
+ <span class="text-xs font-medium text-oc-text-300">${r}</span>
60
+ </div>
61
+ <div class="flex items-center gap-2">
62
+ <span class="font-semibold text-oc-text font-reddit-mono">SGD ${y(c)}</span>
63
+ </div>
64
+ </div>
65
+ `;
66
+ }
67
+ },
68
+ legend: {},
69
+ yAxis: {
70
+ axisLabel: {
71
+ align: "center",
72
+ fontSize: 10,
73
+ color: "#9295A5",
74
+ margin: 20,
75
+ formatter: (t) => t && `${(t / 1e3).toFixed(1)}K`
76
+ },
77
+ splitLine: { show: !1 }
78
+ },
79
+ series: [{
80
+ id: "myBar",
81
+ data: a.chartData,
82
+ type: "bar",
83
+ barCategoryGap: 4,
84
+ itemStyle: {
85
+ borderRadius: i.value ? [100, 100, 0, 0] : [4, 4, 0, 0],
86
+ color: ({ value: t }) => D(t)
87
+ },
88
+ clip: !0
89
+ }]
90
+ })), f = s(() => a.labelData.map((t, e) => l(t).day() === 6 && e + 1 < a.labelData.length ? [e, e + 1] : null).filter(Boolean)), v = {
91
+ silent: !0,
92
+ itemStyle: {
93
+ color: {
94
+ type: "linear",
95
+ x: 0,
96
+ y: 0,
97
+ x2: 0,
98
+ y2: 1,
99
+ colorStops: [
100
+ { offset: 0, color: "rgba(53, 109, 255, 0.08)" },
101
+ { offset: 1, color: "rgba(36, 93, 239, 0.01)" }
102
+ ],
103
+ global: !1
104
+ },
105
+ borderColor: "rgba(53, 109, 255, 0.15)",
106
+ borderWidth: 1
107
+ }
108
+ }, h = w(), { chart: n } = B(h, b), C = (t, e, r = !1) => {
109
+ const u = t.getModel().getSeriesByType("bar").map((m) => m.getData())[0], A = u.count(), o = [];
110
+ return e.forEach((m) => {
111
+ if (m < A) {
112
+ const p = u.getItemLayout(m);
113
+ o.push([
114
+ { x: p.x - 2 },
115
+ { x: p.x + p.width + 2 }
116
+ ]);
117
+ }
118
+ }), r && o.length > 0 ? [[
119
+ { x: o[0][0].x },
120
+ { x: o[o.length - 1][1].x }
121
+ ]] : o;
122
+ }, M = () => {
123
+ if (!n.value || f.value.length === 0) return;
124
+ const t = f.value.map(
125
+ (r) => C(n.value, r, !0).flat()
126
+ ), e = {
127
+ series: {
128
+ id: "myBar",
129
+ markArea: {
130
+ ...v,
131
+ data: t
132
+ }
133
+ }
134
+ };
135
+ n.value.setOption(e);
136
+ };
137
+ return F([n, i], () => {
138
+ n.value && M();
139
+ }), (t, e) => (k(), S("div", {
140
+ ref_key: "barChart",
141
+ ref: h,
142
+ class: "w-full"
143
+ }, null, 512));
144
+ }
145
+ };
146
+ export {
147
+ O as default
148
+ };
@@ -0,0 +1,94 @@
1
+ import { ref as d, computed as x, watch as y, nextTick as C, createElementBlock as i, openBlock as c, createElementVNode as a, createCommentVNode as k, toDisplayString as h, Fragment as w, renderList as F, normalizeStyle as L } from "vue";
2
+ import { useChart as S } from "./Dashboard/composables/useChart.js";
3
+ import "./dayjs.min-CTPVfFeV.js";
4
+ const V = { class: "flex flex-col items-center justify-center" }, T = { class: "relative w-[210px] h-[210px]" }, I = { class: "absolute inset-0 flex flex-col items-center justify-center pointer-events-none" }, O = { class: "text-center" }, j = { class: "text-oc-text-400" }, A = { class: "text-lg font-semibold font-reddit-mono" }, E = {
5
+ key: 0,
6
+ class: "mt-4 flex flex-wrap gap-3 justify-center"
7
+ }, N = ["onClick"], z = { class: "text-sm" }, R = {
8
+ __name: "OcOverviewPieChart",
9
+ props: {
10
+ chartData: Array
11
+ },
12
+ setup(r) {
13
+ const n = r, o = d(""), s = d(0), _ = (e, t = "SGD") => (typeof e == "number" ? e : Number(e)).toLocaleString("en-US", {
14
+ minimumFractionDigits: 2,
15
+ maximumFractionDigits: 2
16
+ }), m = x(() => !n.chartData || n.chartData.length === 0 ? 0 : n.chartData.reduce((e, t) => e + (t.value || 0), 0)), v = () => {
17
+ o.value = "Total", s.value = m.value;
18
+ }, g = x(() => ({
19
+ series: [{
20
+ id: "overviewPieChart",
21
+ data: n.chartData || [],
22
+ type: "pie",
23
+ radius: ["80%", "100%"],
24
+ avoidLabelOverlap: !1,
25
+ itemStyle: {
26
+ borderRadius: 6,
27
+ borderColor: "#fff",
28
+ borderWidth: 2
29
+ },
30
+ label: {
31
+ show: !1
32
+ // Hide default labels
33
+ },
34
+ labelLine: {
35
+ show: !1
36
+ },
37
+ emphasis: {
38
+ disabled: !0,
39
+ label: {
40
+ show: !1
41
+ }
42
+ }
43
+ }]
44
+ })), f = d(), { chart: l } = S(f, g), D = (e) => {
45
+ const t = ["#356DFF", "#AEC5FF", "#86FFCC"];
46
+ return t[e % t.length];
47
+ }, b = (e) => {
48
+ o.value = e.name, s.value = e.value, l.value && l.value.dispatchAction({
49
+ type: "highlight",
50
+ seriesIndex: 0,
51
+ dataIndex: n.chartData.findIndex((t) => t.name === e.name)
52
+ });
53
+ };
54
+ return y(l, async (e) => {
55
+ e && (await C(), v(), e.on("mouseover", "series", (t) => {
56
+ t.componentType === "series" && t.seriesType === "pie" && (o.value = t.name || "Unknown", s.value = t.value || 0);
57
+ }), e.on("mouseout", "series", () => {
58
+ o.value = "Total", s.value = m.value;
59
+ }));
60
+ }), y(() => n.chartData, () => {
61
+ l.value && v();
62
+ }, { deep: !0 }), (e, t) => (c(), i("div", V, [
63
+ a("div", T, [
64
+ a("div", {
65
+ ref_key: "pieChart",
66
+ ref: f,
67
+ class: "w-[210px] h-[210px]"
68
+ }, null, 512),
69
+ a("div", I, [
70
+ a("div", O, [
71
+ a("div", j, h(o.value), 1),
72
+ a("div", A, "SGD " + h(_(s.value)), 1)
73
+ ])
74
+ ])
75
+ ]),
76
+ r.chartData && r.chartData.length > 0 ? (c(), i("div", E, [
77
+ (c(!0), i(w, null, F(r.chartData, (u, p) => (c(), i("div", {
78
+ key: p,
79
+ class: "flex items-center gap-2 cursor-pointer hover:opacity-80 transition-opacity",
80
+ onClick: (B) => b(u)
81
+ }, [
82
+ a("div", {
83
+ class: "w-3 h-3 rounded-full",
84
+ style: L({ backgroundColor: D(p) })
85
+ }, null, 4),
86
+ a("span", z, h(u.name), 1)
87
+ ], 8, N))), 128))
88
+ ])) : k("", !0)
89
+ ]));
90
+ }
91
+ };
92
+ export {
93
+ R as default
94
+ };