Skip to content

Commit 8422ff5

Browse files
committed
fix: reverse date
1 parent 9750f0e commit 8422ff5

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

live-demo/app/custom/Dashboard.vue

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -188,17 +188,13 @@ const apartsCountsByDaysChart = computed(() => {
188188
});
189189
190190
const listedVsUnlistedPriceByDays = computed(() => {
191-
const arr = data.value?.listedVsUnlistedPriceByDays;
192-
193-
if (!Array.isArray(arr)) return [];
194-
195-
const reversed = arr.slice().reverse();
196-
197-
return reversed.map(item => ({
198-
x: dayjs(item.day).format('DD MMM'),
199-
listedPrice: item.listedPrice.toFixed(2),
200-
unlistedPrice: item.unlistedPrice.toFixed(2),
201-
}));
191+
return data.value.listedVsUnlistedPriceByDays?.map(
192+
(item) => ({
193+
x: dayjs(item.day).format('DD MMM'),
194+
listedPrice: item.listedPrice.toFixed(2),
195+
unlistedPrice: item.unlistedPrice.toFixed(2),
196+
})
197+
);
202198
});
203199
204200
const listedVsUnlistedCountByDays = computed(() => {

live-demo/app/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ if (import.meta.url === `file://${process.argv[1]}`) {
157157
LIMIT ?;
158158
`
159159
).all(days);
160+
apartsByDays.reverse();
160161

161162
const totalAparts = apartsByDays.reduce((acc: number, { count }: { count:number }) => acc + count, 0);
162163

@@ -174,6 +175,7 @@ if (import.meta.url === `file://${process.argv[1]}`) {
174175
LIMIT ?;
175176
`
176177
).all(days);
178+
listedVsUnlistedByDays.reverse();
177179

178180
const apartsCountsByRooms = await db.prepare(
179181
`SELECT
@@ -214,6 +216,7 @@ if (import.meta.url === `file://${process.argv[1]}`) {
214216
LIMIT ?;
215217
`
216218
).all(days);
219+
listedVsUnlistedPriceByDays.reverse();
217220

218221
const totalListedPrice = Math.round(listedVsUnlistedByDays.reduce((
219222
acc: number, { listedPrice }: { listedPrice:number }

0 commit comments

Comments
 (0)