diff --git a/resources/js/pages/admin/Analysis.vue b/resources/js/pages/admin/Analysis.vue index 281d76a..daac1cb 100644 --- a/resources/js/pages/admin/Analysis.vue +++ b/resources/js/pages/admin/Analysis.vue @@ -14,7 +14,7 @@ import { VisTooltip, VisXYContainer, } from '@unovis/vue'; -import { computed, ref, watch } from 'vue'; +import { computed, onBeforeUnmount, onMounted, ref, watch } from 'vue'; import StatCard from '@/components/card/StatCard.vue'; import { Button } from '@/components/ui/button'; import { @@ -367,6 +367,21 @@ const peakHour = computed(() => { ); }); +const windowWidth = ref(typeof window !== 'undefined' ? window.innerWidth : 1024); + +onMounted(() => { + const onResize = () => { windowWidth.value = window.innerWidth; }; + window.addEventListener('resize', onResize); + onBeforeUnmount(() => window.removeEventListener('resize', onResize)); +}); + +const busyHourTickValues = computed(() => { + const all = props.busyHours.map((_, i) => i); + if (windowWidth.value < 640) return all.filter((_, i) => i % 4 === 0); + if (windowWidth.value < 1024) return all.filter((_, i) => i % 2 === 0); + return all; +}); + // Top 5 Chart configs type SupplierData = { name: string; amount: number }; type CustomerData = { name: string; amount: number }; @@ -710,7 +725,7 @@ watch([startDate, endDate], () => {
Pendapatan
-
+
@@ -765,7 +780,7 @@ watch([startDate, endDate], () => {
Pengeluaran
-
+
@@ -843,7 +858,7 @@ watch([startDate, endDate], () => { :color="busyHoursChartConfig.orders.color" :bar-padding="0.1" :rounded-corners="4" /> + " :tick-values="busyHourTickValues" /> @@ -906,7 +921,7 @@ watch([startDate, endDate], () => {
-
+
Top 5 Supplier @@ -914,7 +929,7 @@ watch([startDate, endDate], () => { + class="aspect-auto h-[250px] w-full"> { + class="aspect-auto h-[250px] w-full"> { + class="aspect-auto h-[250px] w-full">