Corona Map

Corona Map flow will display a map (node-red-contrib-web-worldmap required) of the current confirmed/death cases of the Corona virus. It retrieves the yesterday's statistics from the John Hopkins institute (from github).

[{"id":"24daaad2.d47eb6","type":"http request","z":"8866261d.bd07b","name":"","method":"GET","ret":"txt","paytoqs":false,"url":"","tls":"","persist":false,"proxy":"","authType":"","x":351,"y":96,"wires":[["2b765b5b.0da1bc"]],"l":false},{"id":"2b765b5b.0da1bc","type":"csv","z":"8866261d.bd07b","name":"","sep":",","hdrin":true,"hdrout":"","multi":"one","ret":"\\n","temp":"","skip":"0","strings":true,"x":399,"y":96,"wires":[["7b44fd8a.80af5c"]],"l":false},{"id":"efcec485.eb1188","type":"function","z":"8866261d.bd07b","name":"","func":"function getFormattedDate(date) {\n    let year = date.getFullYear();\n    let month = (1 + date.getMonth()).toString().padStart(2, '0');\n    let day = date.getDate().toString().padStart(2, '0');\n  \n    return month + '-' + day + '-' + year;\n}\n\nvar date = new Date();\ndate.setDate(date.getDate() - 1);\nyesterday = getFormattedDate(date)\n\nurl = \"https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_daily_reports/\"+yesterday+\".csv\"\n\nreturn {url:url}","outputs":1,"noerr":0,"x":303,"y":96,"wires":[["24daaad2.d47eb6"]],"l":false},{"id":"51ef295f.87ad38","type":"status","z":"8866261d.bd07b","name":"","scope":["2a64e533.86ced2"],"x":156,"y":96,"wires":[["3ff21e5c.68351a"]]},{"id":"3ff21e5c.68351a","type":"switch","z":"8866261d.bd07b","name":"","property":"status.text","propertyType":"msg","rules":[{"t":"eq","v":"connected 0","vt":"str"},{"t":"cont","v":"connected","vt":"str"}],"checkall":"false","repair":false,"outputs":2,"x":255,"y":96,"wires":[[],["efcec485.eb1188"]],"l":false},{"id":"7b44fd8a.80af5c","type":"function","z":"8866261d.bd07b","name":"","func":"Number.prototype.between = function(a, b) {\n  var min = Math.min(a, b),\n    max = Math.max(a, b);\n\n  return this > min && this < max;\n};\n\n//////////\n\nm = msg.payload\n\nconfirmed = m.Confirmed;\ndeaths = msg.payload.Deaths\ncountry = m[\"Country_Region\"]\n\nif(m.hasOwnProperty(\"Province_State\")){\n    province = \"(\"+m[\"Province_State\"]+\")\"\n} else{\n    province = \"\"\n}\nlon = m.Long_\nlat = m.Lat\n\n\nif(confirmed>1000){\n    c = \"#D9100D\"    \n}\nif(confirmed.between(750,1000)){\n  c = \"#D9340D\"  \n} \nif(confirmed.between(500,750)){\n  c = \"#D9590D\"  \n} \nif(confirmed.between(250,500)){\n  c = \"#D97D0D\"  \n} \nif(confirmed.between(100,250)){\n  c = \"#D9A20D\"  \n} \nif(confirmed.between(50,100)){\n  c = \"#D9B40D\"  \n} \nif(confirmed.between(1,50)){\n  c = \"#D3D408\"  \n} \nif(confirmed === 0){\n  return\n} \n    \n\ntooltip = `Country: ${country} ${province}<br/>Confirmed: ${confirmed}<br/>Deaths: ${deaths}<br/>`\nlabel = country +\" \"+province\nreturn {payload:{name:label,lon:lon,lat:lat,popup:tooltip,\"icon\":\"fa-circle\",iconColor:c}}","outputs":1,"noerr":0,"x":447,"y":96,"wires":[["2a64e533.86ced2"]],"l":false},{"id":"2a64e533.86ced2","type":"worldmap","z":"8866261d.bd07b","name":"","lat":"50.76","lon":"2.56","zoom":"3","layer":"Esri Dark Grey","cluster":"0","maxage":"","usermenu":"show","layers":"show","panit":"false","panlock":"false","zoomlock":"false","hiderightclick":"false","coords":"none","showgrid":"false","path":"/corona","x":530,"y":96,"wires":[]}]

Flow Info

Created 5 years, 6 months ago
Updated 5 years, 5 months ago
Rating: not yet rated

Owner

Actions

Rate:

Node Types

Core
  • csv (x1)
  • function (x2)
  • http request (x1)
  • status (x1)
  • switch (x1)
Other
  • worldmap (x1)

Tags

  • worldmap
  • corona
  • dashboard
Copy this flow JSON to your clipboard and then import into Node-RED using the Import From > Clipboard (Ctrl-I) menu option