From f50abec60ff38b8620dc44f43dcc80f67dcc8b8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Z=C3=ADpek?= Date: Tue, 4 Jun 2024 08:22:44 +0200 Subject: [PATCH] More hourse --- server/src/app/routes/dow.ts | 54 +++++++++++++++++++++--------------- 1 file changed, 31 insertions(+), 23 deletions(-) diff --git a/server/src/app/routes/dow.ts b/server/src/app/routes/dow.ts index 3926e3d..66fd734 100644 --- a/server/src/app/routes/dow.ts +++ b/server/src/app/routes/dow.ts @@ -202,7 +202,7 @@ export const dowRoutes = router((router, ctx) => { //#endregion CALENDAR - const next12Hours = Object.entries(weather.hours).slice(1, 13) + const next12Hours = Object.entries(weather.hours).slice(1, 22) const minTemp = Math.min(...next12Hours.map(([, h]) => h.temperature as number)) - 5 @@ -247,17 +247,19 @@ export const dowRoutes = router((router, ctx) => { }) for (const [offset, hour] of next12Hours) { + const offsetInt = +offset + const x = Math.floor( tempX + tempGraphP + - (+offset - 1) * (tempGraphW / next12Hours.length), + (offsetInt - 1) * (tempGraphW / next12Hours.length), ) const y = tempY const temperature = hour.temperature as number const ratio = (temperature - minTemp) / tempRange const height = Math.floor(50 * ratio) - const t = now.plus({ hours: +offset }).hour + const t = now.plus({ hours: offsetInt }).hour widgets.push({ x: x + 7, @@ -279,15 +281,17 @@ export const dowRoutes = router((router, ctx) => { }) } - widgets.push({ - x: x + 10, - y: y + 60, - c: t.toString().padStart(2, '0'), - t: TYPES.TEXT, - va: ALIGN.START, - ha: ALIGN.CENTER, - f: 3, - }) + if ((offsetInt - 1) % 2 === 0) { + widgets.push({ + x: x + 10, + y: y + 60, + c: t.toString().padStart(2, '0'), + t: TYPES.TEXT, + va: ALIGN.START, + ha: ALIGN.CENTER, + f: 3, + }) + } } const minPre = Math.min( @@ -335,15 +339,17 @@ export const dowRoutes = router((router, ctx) => { }) for (const [offset, hour] of next12Hours) { + const offsetInt = +offset + const x = Math.floor( - preX + preGraphP + (+offset - 1) * (preGraphW / next12Hours.length), + preX + preGraphP + (offsetInt - 1) * (preGraphW / next12Hours.length), ) const y = preY const pre = hour.precipitationAmount as number const ratio = (pre - minPre) / preRange const height = Math.floor(50 * ratio) - const t = now.plus({ hours: +offset }).hour + const t = now.plus({ hours: offsetInt }).hour widgets.push({ x: x + 7, @@ -365,15 +371,17 @@ export const dowRoutes = router((router, ctx) => { }) } - widgets.push({ - x: x + 10, - y: y + 60, - c: t.toString().padStart(2, '0'), - t: TYPES.TEXT, - va: ALIGN.START, - ha: ALIGN.CENTER, - f: 3, - }) + if ((offsetInt - 1) % 2 === 0) { + widgets.push({ + x: x + 10, + y: y + 60, + c: t.toString().padStart(2, '0'), + t: TYPES.TEXT, + va: ALIGN.START, + ha: ALIGN.CENTER, + f: 3, + }) + } } res.json(widgets)