|
|
@@ -1,9 +1,206 @@
|
|
1
|
1
|
<script setup>
|
|
|
2
|
+import { Head } from '@inertiajs/inertia-vue3'
|
|
|
3
|
+import { orderBy } from 'lodash'
|
|
|
4
|
+import AppCardStatistic from '@/components/AppCardStatistic.vue'
|
|
2
|
5
|
import AppLayout from '@/layouts/AppLayout.vue'
|
|
|
6
|
+
|
|
|
7
|
+defineProps({
|
|
|
8
|
+ cardStatistics: Object,
|
|
|
9
|
+ barStatistics: Object,
|
|
|
10
|
+ barHorizontalStatistics: Object,
|
|
|
11
|
+})
|
|
|
12
|
+
|
|
|
13
|
+const colors = [
|
|
|
14
|
+ '#349dcf',
|
|
|
15
|
+ '#00b2da',
|
|
|
16
|
+ '#00c7dd',
|
|
|
17
|
+ '#1fdbdb',
|
|
|
18
|
+ '#57eed3',
|
|
|
19
|
+ '#88ffc9',
|
|
|
20
|
+ '#96ed9a',
|
|
|
21
|
+ '#a8d96c',
|
|
|
22
|
+ '#bbc242',
|
|
|
23
|
+ '#cda91d',
|
|
|
24
|
+]
|
|
|
25
|
+
|
|
|
26
|
+const barChart = (chartData) => {
|
|
|
27
|
+ const colors = ['#349dcf', '#a8d96c']
|
|
|
28
|
+
|
|
|
29
|
+ const data = {
|
|
|
30
|
+ datasets: [],
|
|
|
31
|
+ }
|
|
|
32
|
+
|
|
|
33
|
+ let id = 0
|
|
|
34
|
+ for (const key in chartData) {
|
|
|
35
|
+ data.datasets.push({
|
|
|
36
|
+ label: key,
|
|
|
37
|
+ backgroundColor: colors[id],
|
|
|
38
|
+ data: chartData[key],
|
|
|
39
|
+ })
|
|
|
40
|
+
|
|
|
41
|
+ id++
|
|
|
42
|
+ }
|
|
|
43
|
+
|
|
|
44
|
+ return data
|
|
|
45
|
+}
|
|
|
46
|
+
|
|
|
47
|
+const barChartOption = {
|
|
|
48
|
+ maintainAspectRatio: false,
|
|
|
49
|
+ datasetFill: false,
|
|
|
50
|
+}
|
|
|
51
|
+
|
|
|
52
|
+const barHorizontalChart = (chartData) => {
|
|
|
53
|
+ // const data = {
|
|
|
54
|
+ // datasets: [],
|
|
|
55
|
+ // }
|
|
|
56
|
+
|
|
|
57
|
+ // let id = 0
|
|
|
58
|
+ // for (const key in chartData) {
|
|
|
59
|
+ // data.datasets.push({
|
|
|
60
|
+ // label: key,
|
|
|
61
|
+ // backgroundColor: colors[id],
|
|
|
62
|
+ // data: chartData[key],
|
|
|
63
|
+ // })
|
|
|
64
|
+
|
|
|
65
|
+ // id++
|
|
|
66
|
+ // }
|
|
|
67
|
+
|
|
|
68
|
+ // return data
|
|
|
69
|
+
|
|
|
70
|
+ const labels = []
|
|
|
71
|
+ const data = []
|
|
|
72
|
+
|
|
|
73
|
+ for (const chartData of chartData) {
|
|
|
74
|
+ labels.push([chartData.phone, chartData.name])
|
|
|
75
|
+ data.push(chartData.amount)
|
|
|
76
|
+ }
|
|
|
77
|
+
|
|
|
78
|
+ return {
|
|
|
79
|
+ labels: labels,
|
|
|
80
|
+ datasets: [
|
|
|
81
|
+ {
|
|
|
82
|
+ data: data,
|
|
|
83
|
+ backgroundColor: colors,
|
|
|
84
|
+ },
|
|
|
85
|
+ ],
|
|
|
86
|
+ }
|
|
|
87
|
+}
|
|
|
88
|
+
|
|
|
89
|
+const barHorizontalChartOption = {
|
|
|
90
|
+ maintainAspectRatio: false,
|
|
|
91
|
+ datasetFill: false,
|
|
|
92
|
+ indexAxis: 'y',
|
|
|
93
|
+ plugins: {
|
|
|
94
|
+ legend: {
|
|
|
95
|
+ display: false,
|
|
|
96
|
+ },
|
|
|
97
|
+ },
|
|
|
98
|
+}
|
|
|
99
|
+
|
|
|
100
|
+const pieChart = (chartData) => {
|
|
|
101
|
+ const labels = []
|
|
|
102
|
+ const data = []
|
|
|
103
|
+
|
|
|
104
|
+ for (const key in chartData) {
|
|
|
105
|
+ labels.push(key)
|
|
|
106
|
+ data.push(chartData[key])
|
|
|
107
|
+ }
|
|
|
108
|
+
|
|
|
109
|
+ return {
|
|
|
110
|
+ labels: labels,
|
|
|
111
|
+ datasets: [
|
|
|
112
|
+ {
|
|
|
113
|
+ data: data,
|
|
|
114
|
+ backgroundColor: colors,
|
|
|
115
|
+ },
|
|
|
116
|
+ ],
|
|
|
117
|
+ }
|
|
|
118
|
+}
|
|
|
119
|
+
|
|
|
120
|
+const pieChartOption = {
|
|
|
121
|
+ maintainAspectRatio: false,
|
|
|
122
|
+ datasetFill: false,
|
|
|
123
|
+}
|
|
3
|
124
|
</script>
|
|
4
|
125
|
|
|
5
|
126
|
<template>
|
|
6
|
127
|
<AppLayout>
|
|
7
|
|
- <h1>Web App Parkirin</h1>
|
|
|
128
|
+ <Head title="Dashboard" />
|
|
|
129
|
+
|
|
|
130
|
+ <div class="grid">
|
|
|
131
|
+ <div class="col-12 flex flex-wrap justify-content-between card-statistic">
|
|
|
132
|
+ <div v-for="cardStatistic in cardStatistics" class="flex-grow-1">
|
|
|
133
|
+ <AppCardStatistic :data="cardStatistic" />
|
|
|
134
|
+ </div>
|
|
|
135
|
+ </div>
|
|
|
136
|
+
|
|
|
137
|
+ <div v-for="barStatistic in barStatistics" class="col-12 md:col-6">
|
|
|
138
|
+ <Card>
|
|
|
139
|
+ <template #title>
|
|
|
140
|
+ <div class="flex flex-column">
|
|
|
141
|
+ <span>{{ barStatistic.title }}</span>
|
|
|
142
|
+ <span v-if="barStatistic.description" class="text-base font-normal">{{ barStatistic.description }}</span>
|
|
|
143
|
+ </div>
|
|
|
144
|
+ </template>
|
|
|
145
|
+ <template #content>
|
|
|
146
|
+ <Chart
|
|
|
147
|
+ type="bar"
|
|
|
148
|
+ :width="600"
|
|
|
149
|
+ :height="300"
|
|
|
150
|
+ :data="barChart(barStatistic.data)"
|
|
|
151
|
+ :options="barChartOption"
|
|
|
152
|
+ />
|
|
|
153
|
+ </template>
|
|
|
154
|
+ </Card>
|
|
|
155
|
+ </div>
|
|
|
156
|
+
|
|
|
157
|
+ <div v-for="barHorizontalStatistic in barHorizontalStatistics" class="col-12 md:col-6">
|
|
|
158
|
+ <Card>
|
|
|
159
|
+ <template #title>
|
|
|
160
|
+ <div class="flex flex-column">
|
|
|
161
|
+ <span>{{ barHorizontalStatistic.title }}</span>
|
|
|
162
|
+ <span v-if="barHorizontalStatistic.description" class="text-base font-normal">{{
|
|
|
163
|
+ barHorizontalStatistic.description
|
|
|
164
|
+ }}</span>
|
|
|
165
|
+ </div>
|
|
|
166
|
+ </template>
|
|
|
167
|
+ <template #content>
|
|
|
168
|
+ <Chart
|
|
|
169
|
+ type="bar"
|
|
|
170
|
+ :width="600"
|
|
|
171
|
+ :height="300"
|
|
|
172
|
+ :data="barHorizontalChart(barHorizontalStatistic.data)"
|
|
|
173
|
+ :options="barHorizontalChartOption"
|
|
|
174
|
+ />
|
|
|
175
|
+ </template>
|
|
|
176
|
+ </Card>
|
|
|
177
|
+ </div>
|
|
|
178
|
+
|
|
|
179
|
+ <!-- <div v-for="pieStatistic in pieStatistics" class="col-12 md:col-6">
|
|
|
180
|
+ <Card>
|
|
|
181
|
+ <template #title>
|
|
|
182
|
+ <div class="flex flex-column">
|
|
|
183
|
+ <span>{{ pieStatistic.title }}</span>
|
|
|
184
|
+ <span v-if="pieStatistic.description" class="text-base font-normal">{{ pieStatistic.description }}</span>
|
|
|
185
|
+ </div>
|
|
|
186
|
+ </template>
|
|
|
187
|
+ <template #content>
|
|
|
188
|
+ <Chart
|
|
|
189
|
+ type="pie"
|
|
|
190
|
+ :width="600"
|
|
|
191
|
+ :height="300"
|
|
|
192
|
+ :data="pieChart(pieStatistic.data)"
|
|
|
193
|
+ :options="pieChartOption"
|
|
|
194
|
+ />
|
|
|
195
|
+ </template>
|
|
|
196
|
+ </Card>
|
|
|
197
|
+ </div> -->
|
|
|
198
|
+ </div>
|
|
8
|
199
|
</AppLayout>
|
|
9
|
200
|
</template>
|
|
|
201
|
+
|
|
|
202
|
+<style scoped>
|
|
|
203
|
+.card-statistic {
|
|
|
204
|
+ gap: 1rem;
|
|
|
205
|
+}
|
|
|
206
|
+</style>
|