|
| 1 | +<template> |
| 2 | + <div class="px-4 py-4 bg-blue-50 dark:bg-gray-900 dark:shadow-none min-h-screen"> |
| 3 | + <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4"> |
| 4 | + <!-- Total Apartments Chart --> |
| 5 | + <div class="max-w-md w-full bg-white rounded-lg shadow dark:bg-gray-800 p-4 md:p-5"> |
| 6 | + <div> |
| 7 | + <h5 class="leading-none text-3xl font-bold text-gray-900 dark:text-white pb-2">{{ data.totalAparts }}</h5> |
| 8 | + <p class="text-base font-normal text-gray-500 dark:text-gray-400"> |
| 9 | + {{ $t('Apartment last 7 days | Apartments last 7 days', data.totalAparts) }} |
| 10 | + </p> |
| 11 | + </div> |
| 12 | + <BarChart |
| 13 | + :data="apartsCountsByDaysChart" |
| 14 | + :series="[{ name: $t('Added apartments'), fieldName: 'count', color: COLORS[0] }]" |
| 15 | + :options="{ chart: { height: 130 }, yaxis: { stepSize: 1, labels: { show: false } }, grid: { show: false } }" |
| 16 | + /> |
| 17 | + </div> |
| 18 | + |
| 19 | + <!-- Top Countries Pie --> |
| 20 | + <div class="max-w-md w-full bg-white rounded-lg shadow dark:bg-gray-800 p-4 md:p-5"> |
| 21 | + <p class="text-base font-normal text-gray-500 dark:text-gray-400">{{ $t('Top countries') }}</p> |
| 22 | + <PieChart |
| 23 | + :data="topCountries" |
| 24 | + :options="{ |
| 25 | + chart: { type: 'pie' }, |
| 26 | + legend: { show: false }, |
| 27 | + dataLabels: { |
| 28 | + enabled: true, |
| 29 | + formatter: (value, o) => o.w.config.labels[o.seriesIndex] |
| 30 | + } |
| 31 | + }" |
| 32 | + /> |
| 33 | + </div> |
| 34 | + |
| 35 | + <!-- Listed vs Unlisted Count --> |
| 36 | + <div class="w-full bg-white rounded-lg shadow dark:bg-gray-800 p-4 md:p-5 lg:row-span-2 xl:col-span-2"> |
| 37 | + <div class="grid grid-cols-2 py-3"> |
| 38 | + <dl> |
| 39 | + <dt class="text-base font-normal text-gray-500 dark:text-gray-400 pb-1">{{ $t('Listed price') }}</dt> |
| 40 | + <dd class="leading-none text-xl font-bold dark:text-green-400" :style="{ color: COLORS[0] }"> |
| 41 | + {{ formatCurrency(data.totalListedPrice) }} |
| 42 | + </dd> |
| 43 | + </dl> |
| 44 | + <dl> |
| 45 | + <dt class="text-base font-normal text-gray-500 dark:text-gray-400 pb-1">{{ $t('Unlisted price') }}</dt> |
| 46 | + <dd class="leading-none text-xl font-bold dark:text-red-500" :style="{ color: COLORS[1] }"> |
| 47 | + {{ formatCurrency(data.totalUnlistedPrice) }} |
| 48 | + </dd> |
| 49 | + </dl> |
| 50 | + </div> |
| 51 | + |
| 52 | + <BarChart |
| 53 | + :data="listedVsUnlistedCountByDays" |
| 54 | + :series="[ |
| 55 | + { name: $t('Listed Count'), fieldName: 'listed', color: COLORS[0] }, |
| 56 | + { name: $t('Unlisted Count'), fieldName: 'unlisted', color: COLORS[1] } |
| 57 | + ]" |
| 58 | + :options="{ |
| 59 | + chart: { height: 500 }, |
| 60 | + xaxis: { labels: { show: true }, stepSize: 1 }, |
| 61 | + yaxis: { labels: { show: true } }, |
| 62 | + grid: { show: true }, |
| 63 | + plotOptions: { bar: { horizontal: true } } |
| 64 | + }" |
| 65 | + /> |
| 66 | + </div> |
| 67 | + |
| 68 | + <!-- Apartments by Rooms Pie --> |
| 69 | + <div class="max-w-md w-full bg-white rounded-lg shadow dark:bg-gray-800 p-4 md:p-5"> |
| 70 | + <p class="text-base font-normal text-gray-500 dark:text-gray-400">{{ $t('Apartment by rooms') }}</p> |
| 71 | + <PieChart |
| 72 | + :data="apartsCountsByRooms" |
| 73 | + :options="{ |
| 74 | + chart: { type: 'donut' }, |
| 75 | + plotOptions: { |
| 76 | + pie: { |
| 77 | + donut: { |
| 78 | + labels: { |
| 79 | + total: { |
| 80 | + show: true, |
| 81 | + label: $t('Total square'), |
| 82 | + formatter: () => `${data.totalSquareMeters.toFixed(0)} m²` |
| 83 | + } |
| 84 | + } |
| 85 | + } |
| 86 | + } |
| 87 | + } |
| 88 | + }" |
| 89 | + /> |
| 90 | + </div> |
| 91 | + |
| 92 | + </div> |
| 93 | + </div> |
| 94 | +</template> |
| 95 | + |
| 96 | +<script setup lang="ts"> |
| 97 | +import { ref, computed } from 'vue'; |
| 98 | +import dayjs from 'dayjs'; |
| 99 | +import { useI18n } from 'vue-i18n'; |
| 100 | +import { AreaChart, BarChart, PieChart } from '@/afcl'; |
| 101 | +
|
| 102 | +const { t } = useI18n(); |
| 103 | +const COLORS = ['#4E79A7', '#F28E2B', '#E15759', '#76B7B2', '#59A14F']; |
| 104 | +
|
| 105 | +const data = { |
| 106 | + totalAparts: 32, |
| 107 | + totalListedPrice: 4560000, |
| 108 | + totalUnlistedPrice: 1230000, |
| 109 | + totalSquareMeters: 2345, |
| 110 | + apartsByDays: [ |
| 111 | + { day: '2025-07-17', count: 3 }, |
| 112 | + { day: '2025-07-16', count: 6 }, |
| 113 | + { day: '2025-07-15', count: 8 }, |
| 114 | + { day: '2025-07-14', count: 5 }, |
| 115 | + { day: '2025-07-13', count: 4 }, |
| 116 | + { day: '2025-07-12', count: 3 }, |
| 117 | + { day: '2025-07-11', count: 3 } |
| 118 | + ], |
| 119 | + topCountries: [ |
| 120 | + { country: 'US', count: 12 }, |
| 121 | + { country: 'FR', count: 7 }, |
| 122 | + { country: 'DE', count: 5 }, |
| 123 | + { country: 'UA', count: 8 } |
| 124 | + ], |
| 125 | + apartsCountsByRooms: [ |
| 126 | + { number_of_rooms: 1, count: 6 }, |
| 127 | + { number_of_rooms: 2, count: 10 }, |
| 128 | + { number_of_rooms: 3, count: 9 }, |
| 129 | + { number_of_rooms: 4, count: 7 } |
| 130 | + ], |
| 131 | + listedVsUnlistedByDays: [ |
| 132 | + { day: '2025-07-17', listed: 3, unlisted: 1 }, |
| 133 | + { day: '2025-07-16', listed: 5, unlisted: 2 }, |
| 134 | + { day: '2025-07-15', listed: 4, unlisted: 3 } |
| 135 | + ], |
| 136 | + listedVsUnlistedPriceByDays: [ |
| 137 | + { day: '2025-07-17', listedPrice: 1000000, unlistedPrice: 400000 }, |
| 138 | + { day: '2025-07-16', listedPrice: 900000, unlistedPrice: 350000 }, |
| 139 | + { day: '2025-07-15', listedPrice: 800000, unlistedPrice: 300000 } |
| 140 | + ] |
| 141 | +}; |
| 142 | +
|
| 143 | +const formatCurrency = (value: number) => |
| 144 | + new Intl.NumberFormat('en-US', { style: 'currency', currency: 'USD', maximumFractionDigits: 0 }).format(value); |
| 145 | +
|
| 146 | +const apartsCountsByDaysChart = computed(() => |
| 147 | + data.apartsByDays.slice().reverse().map(item => ({ |
| 148 | + x: dayjs(item.day).format('DD MMM'), |
| 149 | + count: item.count |
| 150 | + })) |
| 151 | +); |
| 152 | +
|
| 153 | +const listedVsUnlistedPriceByDays = computed(() => |
| 154 | + data.listedVsUnlistedPriceByDays.map(item => ({ |
| 155 | + x: dayjs(item.day).format('DD MMM'), |
| 156 | + listedPrice: item.listedPrice.toFixed(2), |
| 157 | + unlistedPrice: item.unlistedPrice.toFixed(2) |
| 158 | + })) |
| 159 | +); |
| 160 | +
|
| 161 | +const listedVsUnlistedCountByDays = computed(() => |
| 162 | + data.listedVsUnlistedByDays.map(item => ({ |
| 163 | + x: dayjs(item.day).format('DD MMM'), |
| 164 | + listed: item.listed, |
| 165 | + unlisted: item.unlisted |
| 166 | + })) |
| 167 | +); |
| 168 | +
|
| 169 | +const apartsCountsByRooms = computed(() => |
| 170 | + data.apartsCountsByRooms.map((item, i) => ({ |
| 171 | + label: t(`{number_of_rooms} rooms`, { number_of_rooms: item.number_of_rooms }), |
| 172 | + amount: item.count, |
| 173 | + color: COLORS[i] |
| 174 | + })) |
| 175 | +); |
| 176 | +
|
| 177 | +const topCountries = computed(() => |
| 178 | + data.topCountries.map((item, i) => ({ |
| 179 | + label: item.country, |
| 180 | + amount: item.count, |
| 181 | + color: COLORS[i] |
| 182 | + })) |
| 183 | +); |
| 184 | +</script> |
0 commit comments