diff --git a/db.csv b/db.csv index 5a1751d..637c045 100644 --- a/db.csv +++ b/db.csv @@ -150,3 +150,22 @@ ECSW,1636870263236,3 ECSW,1636870280400,3 ECSW,1636870298164,3 ECSW,1636870316252,3 +ECSW,1636872887382,2 +ECSW,1636872907445,3 +ECSW,1636872925228,3 +ECSW,1636872943180,3 +ECSW,1636872971435,4 +ECSW,1636872989172,4 +ECSW,1636873007195,4 +ECSW,1636873024462,3 +ECSW,1636873043241,4 +ECSW,1636873065227,4 +ECSW,1636873083327,4 +ECSW,1636873101359,4 +ECSW,1636873119248,4 +ECSW,1636873139178,4 +ECSW,1636873156488,4 +ECSW,1636873174467,4 +ECSW,1636873194206,3 +ECSW,1636873221180,3 +ECSW,1636873239096,3 diff --git a/public/index.js b/public/index.js index 2907204..618d2aa 100644 --- a/public/index.js +++ b/public/index.js @@ -68,17 +68,17 @@ fetch('/db.csv').then(res => res.text()).then(text => { return { loc, time: new Date(+time), count: parseInt(count) } }) - const ecss = data.filter(d => d.loc === 'ecss') + const ecsw = data.filter(d => d.loc === 'ECSW') - console.log(ecss) + console.log(ecsw) - const avg = ecss.reduce((acc, v) => acc + v.count, 0) / ecss.length - const current = ecss[ecss.length - 1].count + const avg = ecsw.reduce((acc, v) => acc + v.count, 0) / ecsw.length + const current = ecsw[ecsw.length - 1].count const delta = current - avg - const color = delta > 0 ? '#ff0000' : '#00ff00' - buildings.ECSW.poly.setStyle({ - color: `#${color}` - }) + const busy = delta > 0 + const color = busy ? '#ff0000' : '#00ff00' + buildings.ECSW.poly.setStyle({ color }) + console.log({avg, current, delta, color}) }) async function displayCard(id) {