Author Topic: Building web app with chartjs showing reain per hour  (Read 1171 times)

0 Members and 1 Guest are viewing this topic.

Offline JanBakke

  • Member
  • *
  • Posts: 2
Building web app with chartjs showing reain per hour
« on: August 31, 2024, 01:29:27 AM »
Hi forum  [tup]
I have struggling finding a way to show bars (chartjs) for hourly rainfall.
I'm retrieve the daily report from ecowitt API into my database.
This is the answer I've got from ecowitt support, does it make senses?

"Hourly rainfall is reset at each hour on the hour. The rainfall for one hour is calculated by subtracting the accumulated annual rainfall at the previous hour from the accumulated annual rainfall at the current hour."

Anyone who can tell me how to build my Mariadb query based on this?
I quess I have to build a php script storing the hourly rainfall (current anual rainfall for one hour ago- current rainfall) running once per hour from a cron script, or having a wait loop to get the difference and store it in an array for chartjs.
« Last Edit: August 31, 2024, 01:47:04 AM by JanBakke »

Offline JanBakke

  • Member
  • *
  • Posts: 2
Re: Building web app with chartjs showing reain per hour
« Reply #1 on: August 31, 2024, 01:53:03 AM »
This is the query i'm using now (the last part is to filter out at 0 o clock records)
SELECT `datetime`, HOUR(`datetime`) AS hour, `rain_hourly` FROM `ecowitt_day` WHERE `datetime` LIKE '%00:0%' AND `datetime` NOT LIKE '% 00:0%';

 

anything