adminforth 1.5.9-next.4 → 1.5.9-next.5
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.
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div ref="chart"></div>
|
|
2
|
+
<div class="-mb-2" ref="chart"></div>
|
|
3
3
|
</template>
|
|
4
4
|
|
|
5
5
|
<script setup lang="ts">
|
|
@@ -132,21 +132,23 @@ const options = computed(() => {
|
|
|
132
132
|
return options;
|
|
133
133
|
});
|
|
134
134
|
|
|
135
|
-
let apexChart: ApexCharts =
|
|
135
|
+
let apexChart: ApexCharts | null = null;
|
|
136
136
|
|
|
137
|
-
watch(() => options.value, (value) => {
|
|
137
|
+
watch(() => [options.value, chart.value], (value) => {
|
|
138
|
+
if (!value || !chart.value) {
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
138
141
|
if (apexChart) {
|
|
139
|
-
apexChart.
|
|
142
|
+
apexChart.updateOptions(options.value);
|
|
140
143
|
} else {
|
|
141
|
-
|
|
142
|
-
apexChart.
|
|
143
|
-
apexChart.value.render();
|
|
144
|
+
apexChart = new ApexCharts(chart.value, options.value);
|
|
145
|
+
apexChart.render();
|
|
144
146
|
}
|
|
145
147
|
});
|
|
146
148
|
|
|
147
149
|
onUnmounted(() => {
|
|
148
|
-
if (apexChart
|
|
149
|
-
apexChart.
|
|
150
|
+
if (apexChart) {
|
|
151
|
+
apexChart.destroy();
|
|
150
152
|
}
|
|
151
153
|
});
|
|
152
154
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div ref="chart"></div>
|
|
2
|
+
<div class="-mb-2" ref="chart"></div>
|
|
3
3
|
</template>
|
|
4
4
|
|
|
5
5
|
<script setup lang="ts">
|
|
6
6
|
import ApexCharts, { type ApexOptions } from 'apexcharts';
|
|
7
|
-
import { ref, type Ref, watch, computed } from 'vue';
|
|
7
|
+
import { ref, type Ref, watch, computed, onUnmounted } from 'vue';
|
|
8
8
|
|
|
9
9
|
const chart: Ref<HTMLDivElement | null> = ref(null);
|
|
10
10
|
|
|
@@ -43,7 +43,7 @@ const optionsBase = {
|
|
|
43
43
|
horizontal: false,
|
|
44
44
|
columnWidth: "80%",
|
|
45
45
|
borderRadiusApplication: "end",
|
|
46
|
-
borderRadius:
|
|
46
|
+
borderRadius: 5,
|
|
47
47
|
dataLabels: {
|
|
48
48
|
position: "top",
|
|
49
49
|
},
|
|
@@ -144,16 +144,23 @@ const options = computed(() => {
|
|
|
144
144
|
return options;
|
|
145
145
|
});
|
|
146
146
|
|
|
147
|
-
let apexChart: ApexCharts;
|
|
147
|
+
let apexChart: ApexCharts | null = null;
|
|
148
148
|
|
|
149
|
-
watch(() => options.value, (value) => {
|
|
149
|
+
watch(() => [options.value, chart.value], (value) => {
|
|
150
|
+
if (!value || !chart.value) {
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
150
153
|
if (apexChart) {
|
|
151
|
-
apexChart.updateOptions(value);
|
|
154
|
+
apexChart.updateOptions(options.value);
|
|
152
155
|
} else {
|
|
153
|
-
|
|
154
|
-
apexChart = new ApexCharts(chart.value, value);
|
|
156
|
+
apexChart = new ApexCharts(chart.value, options.value);
|
|
155
157
|
apexChart.render();
|
|
156
158
|
}
|
|
157
159
|
});
|
|
158
160
|
|
|
161
|
+
onUnmounted(() => {
|
|
162
|
+
if (apexChart) {
|
|
163
|
+
apexChart.destroy();
|
|
164
|
+
}
|
|
165
|
+
});
|
|
159
166
|
</script>
|
|
@@ -1,131 +1,141 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div ref="chart"></div>
|
|
2
|
+
<div class="-mb-2" ref="chart"></div>
|
|
3
3
|
</template>
|
|
4
4
|
|
|
5
5
|
<script setup lang="ts">
|
|
6
6
|
import ApexCharts, { type ApexOptions } from 'apexcharts';
|
|
7
|
-
import { ref, type Ref, watch, computed } from 'vue';
|
|
7
|
+
import { ref, type Ref, watch, computed, onUnmounted } from 'vue';
|
|
8
8
|
|
|
9
9
|
const chart: Ref<HTMLDivElement | null> = ref(null);
|
|
10
10
|
|
|
11
11
|
const props = defineProps<{
|
|
12
12
|
data: {
|
|
13
|
-
|
|
13
|
+
label: string,
|
|
14
|
+
amount: number,
|
|
15
|
+
color?: string,
|
|
14
16
|
[key: string]: any,
|
|
15
17
|
}[],
|
|
16
|
-
|
|
17
|
-
name: string,
|
|
18
|
-
fieldName: string,
|
|
19
|
-
color: string,
|
|
20
|
-
}[],
|
|
21
|
-
options: ApexOptions,
|
|
18
|
+
options?: ApexOptions,
|
|
22
19
|
}>();
|
|
23
20
|
|
|
21
|
+
const SUGGESTED_COLORS = [
|
|
22
|
+
"#4E79A7", "#F28E2B", "#E15759", "#76B7B2", "#59A14F", "#EDC949", "#B07AA1", "#FF9DA6", "#9C755F", "#BAB0AC",
|
|
23
|
+
"#2B8A86", "#CC4D58", "#F7941D", "#F9C232", "#729B33", "#497288", "#16578D", "#5F4D99", "#F9F871", "#F9F871",
|
|
24
|
+
];
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
// [ "#2B8A86", "#CC4D58", "#F7941D", "#F9C232", "#729B33", "#497288", "#16578D", "#5F4D99",]
|
|
28
|
+
// ["#4E79A7", "#F28E2B", "#E15759", "#76B7B2", "#59A14F"], // Professional Cool Tones
|
|
29
|
+
// ["#1F77B4", "#FF7F0E", "#2CA02C", "#D62728", "#9467BD"], // Balanced Vibrant Colors
|
|
30
|
+
// ["#6A4C93", "#1982C4", "#8AC926", "#FF595E", "#FFCA3A"], // Bold and Distinct
|
|
31
|
+
// ["#0077B6", "#0096C7", "#00B4D8", "#90E0EF", "#CAF0F8"], // Ocean Blues
|
|
32
|
+
// ["#3A0CA3", "#7209B7", "#F72585", "#4361EE", "#4CC9F0"], // Vivid Purples and Blues
|
|
33
|
+
// ["#FF9F1C", "#FFBF69", "#CBF3F0", "#2EC4B6", "#011627"], // Warm and Cool Mix
|
|
34
|
+
// ["#8338EC", "#3A86FF", "#FB5607", "#FF006E", "#FFBE0B"], // Fun and Playful
|
|
35
|
+
// ["#F94144", "#F3722C", "#F8961E", "#F9844A", "#F9C74F"], // Warm Gradient
|
|
24
36
|
|
|
25
37
|
|
|
26
38
|
const optionsBase = {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
39
|
+
series: [],
|
|
40
|
+
colors: [],
|
|
41
|
+
labels: [],
|
|
42
|
+
chart: {
|
|
43
|
+
height: 400,
|
|
44
|
+
width: "100%",
|
|
45
|
+
type: "donut",
|
|
30
46
|
},
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
toolbar: {
|
|
35
|
-
show: false,
|
|
36
|
-
}
|
|
37
|
-
},
|
|
38
|
-
fill: {
|
|
39
|
-
opacity: 1,
|
|
40
|
-
},
|
|
41
|
-
plotOptions: {
|
|
42
|
-
bar: {
|
|
43
|
-
horizontal: false,
|
|
44
|
-
columnWidth: "80%",
|
|
45
|
-
borderRadiusApplication: "end",
|
|
46
|
-
borderRadius: 8,
|
|
47
|
-
dataLabels: {
|
|
48
|
-
position: "top",
|
|
49
|
-
},
|
|
47
|
+
stroke: {
|
|
48
|
+
colors: ["transparent"],
|
|
49
|
+
lineCap: "",
|
|
50
50
|
},
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
51
|
+
plotOptions: {
|
|
52
|
+
pie: {
|
|
53
|
+
donut: {
|
|
54
|
+
labels: {
|
|
55
|
+
show: true,
|
|
56
|
+
name: {
|
|
57
|
+
show: true,
|
|
58
|
+
fontFamily: "Inter, sans-serif",
|
|
59
|
+
offsetY: 20,
|
|
60
|
+
},
|
|
61
|
+
total: {
|
|
62
|
+
showAlways: true,
|
|
63
|
+
show: false,
|
|
64
|
+
fontFamily: "Inter, sans-serif",
|
|
65
|
+
label: "",
|
|
66
|
+
formatter: function (w) {
|
|
67
|
+
const sum = w.globals.seriesTotals.reduce((a, b) => {
|
|
68
|
+
return a + b
|
|
69
|
+
}, 0)
|
|
70
|
+
return sum
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
value: {
|
|
74
|
+
show: true,
|
|
75
|
+
fontFamily: "Inter, sans-serif",
|
|
76
|
+
offsetY: -20,
|
|
77
|
+
formatter: function (value) {
|
|
78
|
+
return value + "k"
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
size: "80%",
|
|
83
|
+
},
|
|
84
|
+
},
|
|
64
85
|
},
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
cssClass: 'text-xs font-normal fill-gray-500 dark:fill-gray-400'
|
|
86
|
+
grid: {
|
|
87
|
+
padding: {
|
|
88
|
+
top: 3,
|
|
89
|
+
left: 3,
|
|
90
|
+
right: 3,
|
|
91
|
+
bottom: 3,
|
|
72
92
|
},
|
|
73
|
-
formatter: function (value) {
|
|
74
|
-
return value
|
|
75
|
-
}
|
|
76
93
|
},
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
show: false,
|
|
94
|
+
dataLabels: {
|
|
95
|
+
enabled: false,
|
|
80
96
|
},
|
|
81
|
-
|
|
82
|
-
|
|
97
|
+
legend: {
|
|
98
|
+
position: "bottom",
|
|
99
|
+
fontFamily: "Inter, sans-serif",
|
|
83
100
|
},
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
+
yaxis: {
|
|
102
|
+
labels: {
|
|
103
|
+
formatter: function (value) {
|
|
104
|
+
return value;
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
xaxis: {
|
|
109
|
+
labels: {
|
|
110
|
+
formatter: function (value) {
|
|
111
|
+
return value;
|
|
112
|
+
},
|
|
113
|
+
},
|
|
114
|
+
axisTicks: {
|
|
115
|
+
show: false,
|
|
116
|
+
},
|
|
117
|
+
axisBorder: {
|
|
118
|
+
show: false,
|
|
119
|
+
},
|
|
101
120
|
},
|
|
102
|
-
},
|
|
103
121
|
};
|
|
104
122
|
|
|
105
123
|
const options = computed(() => {
|
|
106
|
-
|
|
107
|
-
props.series.forEach((s) => {
|
|
108
|
-
if (props.data[0][s.fieldName] === undefined) {
|
|
109
|
-
throw new Error(`Field ${s.fieldName} not found even in first data point ${JSON.stringify(props.data[0])}, something is wrong`);
|
|
110
|
-
}
|
|
111
|
-
});
|
|
112
|
-
}
|
|
124
|
+
|
|
113
125
|
const options = {
|
|
114
126
|
...optionsBase,
|
|
115
127
|
|
|
116
128
|
// shade and gradient take from first series
|
|
117
|
-
series: props.
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
})),
|
|
121
|
-
xaxis: {
|
|
122
|
-
...optionsBase.xaxis,
|
|
123
|
-
categories: props.data?.map((item) => item.x) ?? [],
|
|
124
|
-
},
|
|
129
|
+
series: props.data?.map((item) => item.amount) ?? [],
|
|
130
|
+
colors: props.data?.map((item, index) => item.color ?? SUGGESTED_COLORS[index]) ?? [],
|
|
131
|
+
labels: props.data?.map((item) => item.label) ?? [],
|
|
125
132
|
};
|
|
126
133
|
|
|
127
134
|
// for each of ...props.options merge on lowest level. so if { chart: {height : 2} }, it should not replace chart level, only height level
|
|
128
135
|
function mergeOptions(options: any, newOptions: any) {
|
|
136
|
+
if (!newOptions) {
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
129
139
|
for (const key in newOptions) {
|
|
130
140
|
if (typeof newOptions[key] === 'object') {
|
|
131
141
|
if (!options[key]) {
|
|
@@ -142,16 +152,23 @@ const options = computed(() => {
|
|
|
142
152
|
return options;
|
|
143
153
|
});
|
|
144
154
|
|
|
145
|
-
let apexChart: ApexCharts;
|
|
155
|
+
let apexChart: ApexCharts | null = null;
|
|
146
156
|
|
|
147
|
-
watch(() => options.value, (value) => {
|
|
157
|
+
watch(() => [options.value, chart.value], (value) => {
|
|
158
|
+
if (!value || !chart.value) {
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
148
161
|
if (apexChart) {
|
|
149
|
-
apexChart.updateOptions(value);
|
|
162
|
+
apexChart.updateOptions(options.value);
|
|
150
163
|
} else {
|
|
151
|
-
|
|
152
|
-
apexChart = new ApexCharts(chart.value, value);
|
|
164
|
+
apexChart = new ApexCharts(chart.value, options.value);
|
|
153
165
|
apexChart.render();
|
|
154
166
|
}
|
|
155
167
|
});
|
|
156
168
|
|
|
169
|
+
onUnmounted(() => {
|
|
170
|
+
if (apexChart) {
|
|
171
|
+
apexChart.destroy();
|
|
172
|
+
}
|
|
173
|
+
});
|
|
157
174
|
</script>
|
|
@@ -11,4 +11,5 @@ export { default as Checkbox } from './Checkbox.vue';
|
|
|
11
11
|
export { default as Dropzone } from './Dropzone.vue';
|
|
12
12
|
export { default as AreaChart } from './AreaChart.vue';
|
|
13
13
|
export { default as BarChart } from './BarChart.vue';
|
|
14
|
+
export { default as PieChart } from './PieChart.vue';
|
|
14
15
|
|
|
@@ -10,7 +10,6 @@ export const useToastStore = defineStore('toast', () => {
|
|
|
10
10
|
const route = useRoute();
|
|
11
11
|
|
|
12
12
|
watch(route, () => {
|
|
13
|
-
console.log('route changed 121');
|
|
14
13
|
// on route change clear all toasts older then 5 seconds
|
|
15
14
|
const now = +new Date();
|
|
16
15
|
toasts.value = toasts.value.filter((t) => now - t.createdAt < 5000);
|