[Flow] Corona country comparison with Hubei (China)

Comparison Charts (new section!!)

I will regularly post new country comparison charts as comment to this forum topic. Here below the list of charts I have posted so far.


The flow is too big to embed in this topic.
You can download it from here:

This flow uses the node-red-dashboard nodes (I have tested it with version 2.19.4)

Github Project link


This node-red flow is creating a dashboard showing the historical statistics of the corona deaths and corona confirmed cases for the selected country or province/state.

The statistics are retrieved from https://github.com/CSSEGISandData/COVID-19

It also puts in the same charts the statistics for the province Hubei (China) were the outbreak began. To make comparison easy I have scaled and shifted the chart for Hubei.

The time shift ( "hubei date shift" ) is determined by the "lock down date" that you can specify. So the Hubei charts will be shifted so that the lock down date of Hubei (= 23rd of January 2020) falls together with the "lock down date" you have specified.

The "hubei factor" is the factor used to scale the Hubei deaths and Hubei confirmed cases in the charts. The "hubei factor" is calculated as the ratio of the current total number of deaths for the selected country or province over the total number of deaths in Hubei at corresponding date relative to the start of lock down.


At startup this flow will read the statistics from a local file covid.json . The very first time this local file will not exist and an error message is reported in the dashboard (this is normal). So in that case you must retrieve the data from Github by clicking on the button retrieve data from github . Note that this takes several minutes. You will even loose your browser connection. This is expected. Just be patient and you will be automatically reconnected. If everything is fine then this data is also stored in the local file.

FYI it is not the retrieving that takes a lot of time but converting the data to proper json structure that is time consuming.

Once the data is retrieved, you can select the country , province/state and lock down date and the charts will automatically be updated.

You can always refresh the data with the latest available data from github by clicking on the button (but as said this takes several minutes).

Dashboard example


The getting of the data can be simplified and you can avoid needing to use curl.

Here is an example of getting the data directly and reformatting into json. This example only gets the confirmed cases data not the deaths/recoveries datasets which are both separate.

[{"id":"731e3a80.f158b4","type":"inject","z":"769ea95b.9e7518","name":"","topic":"","payload":"","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":135,"y":100,"wires":[["c14526cf.21f0c8"]],"l":false},{"id":"c14526cf.21f0c8","type":"http request","z":"769ea95b.9e7518","name":"GET Covid-19 Confirmed Cases (WHO/Johns Hopkins)","method":"GET","ret":"txt","paytoqs":false,"url":"https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_19-covid-Confirmed.csv","tls":"","persist":false,"proxy":"","authType":"","x":390,"y":100,"wires":[["122de92d.d482e7"]]},{"id":"122de92d.d482e7","type":"csv","z":"769ea95b.9e7518","name":"","sep":",","hdrin":true,"hdrout":true,"multi":"mult","ret":"\\n","temp":"","skip":"0","strings":true,"x":635,"y":100,"wires":[["9286a886.653c58"]],"l":false},{"id":"3e8a1f4f.c1358","type":"debug","z":"769ea95b.9e7518","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":1030,"y":100,"wires":[]},{"id":"9286a886.653c58","type":"function","z":"769ea95b.9e7518","name":"","func":"const out = {}\n\nconst cdata = flow.get('populations.rows', 'file')\nconst nocmatch = []\n\nmsg.payload.forEach( (country) => {\n    const cname = country['Country/Region']\n\n    // We don't need these\n    delete country['Country/Region']\n    delete country['Province/State']\n    delete country.Lat\n    delete country.Long\n\n    const keys = Object.keys(country)\n    const values = Object.values(country)\n    \n    const dates = []\n    \n    keys.forEach( (key, i) => {\n        let k = key.split('/')\n        let newKey = `20${k[2]}-${k[0].padStart(2, '0')}-${k[1].padStart(2, '0')}`\n\n        dates.push({\n            'date': newKey,\n            'cases': values[i]\n        })\n    })\n    \n    var thiscdata = cdata.filter( c => c['Country (or dependency)'] === cname )\n\n    out[cname] = {\n        'country': cname,\n        //'population': thiscdata[0],\n        'confirmed': dates\n    }\n    \n    // Merge in population data if available\n    if ( thiscdata.length === 0 ) nocmatch[cname] = cname\n    else {\n        Object.keys(thiscdata[0]).forEach( (key, i) => {\n            // Ignore # & country\n            if ( i < 2 ) return\n            \n            out[cname][key] = thiscdata[0][key]\n        })\n    }\n})\n\nreturn [ \n    {topic: msg.topic, payload: out}, \n    {topic:'Countries With No Matching Population Entry', payload: Object.values(nocmatch)},\n]","outputs":2,"noerr":0,"x":730,"y":100,"wires":[["3e8a1f4f.c1358"],["4f8e8d.2ea27174"]]},{"id":"4f8e8d.2ea27174","type":"debug","z":"769ea95b.9e7518","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":1030,"y":140,"wires":[]}]
1 Like

Thanks for sharing this.

The getting of the data can be simplified ...

Did you mean the retrieving of the data or the processing and formatting of the retrieved data into proper json structure ?

Well the retrieval really.

I didn't check the full JSON formatting that you were doing. You do seem to have a lot of JSONata and I've personally found that if I have to write complex JSONata, it is usually better done in a function node. With the many JSONata change nodes, you will be walking through the data many times, with JS, you might be able to do it in one pass.

1 Like

Depends on how complex you’re writing it, oftentimes it fits in a single rule in a change node. It does get harder to read at some point, but I still prefer JSONata over function nodes most of the time. It’s a personal choice for sure.


Todays (2020-03-19) charts for Italy using 5th of March as lock down date (= date when Italy took measures comparable to the lock down of Hubei at 23rd of January 2020).

So you can see the following things:

  1. In chart "new deaths" (reporting the daily number of deaths): the peak (based on comparison with Hubei) is expected around the end of this Month (still 10 days to go).
  2. In chart '"total deaths": Italy might expect more than 15000 deaths (5 times more than today).
  3. The hubei factor (shown at the top of the chart) of 5.424 means that the situation in Italy in terms of deaths is more than 5 times worse than the situation in Hubei.

Take care that this is just a comparison based on shifting (X-axis) and scaling (Y-axis) of the Historical Hubei data. So this doesn't mean that Italy will follow the same path. But it must be noted that (see chart total deaths) that the path of Italy (using lock down date = 5th of March) so far closely matches the China (Hubei) - shifted and scaled evolution.

The charts allow you also to check a potential impact of delaying drastic measures (= lock down date parameter).

For the United Kingdom:

  • (chart 1 below) if lock down date = 18th of March 2020 then about 13,000 deaths might be expected.
  • (chart 2 below) if lock down date = 13th of March 2020 then about 1,800 deaths might be expected.

So in case of the UK: delaying the drastic measures with 5 days increased the number of deaths with a factor 7.

chart 1: United Kingdom with lock down date 3/18/2020

chart 2: United Kingdom with lock down date 3/13/2020

1 Like

@janvda - Where do the country totals come from? I don't see a combined total for the US.

Nice work!


The totals come from:

Indeed, I don't immediately see totals for the complete US, but you can select the relevant US state using the province/state dropdown.

In my calculations I summed up all of the regions to country level.

If you were to change the stats to show cases and deaths as a % of the population you can also get some interesting insight.

Taken from an Excel spreadsheet I created, you can view/copy here: COVID-Confirmed-Cases.xlsx


Here below the charts for Spain based on a lock down date = 12th of March.

When looking at total deaths Chart:

  • Spain (similarly to Italy) might expect up to 15,000 deaths.
    So the situation in Spain is 5 times (see hubei factor) as severe compared to the Province Hubei in China.

disclaimer - this is just an extrapolation based on the historical hubei data and the chosen lock down date of 12th of March. E.g. Using as Lock down date = 9th of March (3 days earlier) reduced the total death with 50% (hubei factor = 2.3 instead of 5.1).

I can generate these charts on requests. Just post a message to this comment specifying your country (if living in the US also specify the state).

Here below an overview of the charts posted so far:

The full list of charts posted, will be kept updated in the initial forum post.

The Charts for Belgium with lock down date = 2020-03-12.


  1. Todays (2020-03-20) statistics (16 new deaths) are not yet included in the total deaths (which is 21 at 2020-03-19) (so today almost a doubling of total deaths). So the actual numbers will most likely be worse than what is shown here but I still hope we stay below 1000. A more clearer view we will get the coming days.

  2. We might expect the peak in new deaths around 5th of April but the actual peak of newly infected people is most likely 2 - 4 weeks earlier. So the actual number of newly infected people might already be going down very rapidly but its effect in new deaths chart we will only see with a delay of several weeks.

1 Like

An update for Belgium with lock down date = 2020-03-12.

Note that I added chart "total deaths (limited to 7 days in the future)". This shows the same information as chart "total deaths" but then only limited to 7 days in the future. This new chart allows to see to what extent the selected country/province/state is following the same graph as Hubei (China).


  1. Hubei factor doubled compared to same chart I posted 2 days ago (from 0.130 to 0.269). So there are 3 explanations I could think of for this:
    a/ the virus in Belgium was spreading substantially faster before the lock down date compared to Hubei. Especially the spreading to the high risk group (elderly people).
    b/ the Belgium measures taken during the lock down data don't have the same positive effect as the measures taken by Hubei.
    c/ some of the increase can be caused by the Hubei statistics that might have reported cases on the next day.
  2. Chart "total deaths (limited to 7 days in future)" also clearly shows that Belgium is not following the Hubei curve. This is concerning. So Belgium might get substantially more deaths than the 850 predicted in chart "total deaths".
1 Like

Chart for the Netherlands with lock down date = 2020-03-15

Notes and Observations:

  1. Hubei factor = 1.088 - so based on this model the Netherlands might expect the same deaths (3500) as Hubei. (Take care that the population of Italy is 3.5 times as much as the population of the Netherlands).
  2. I have taken as lock down date = 2020-03-15 as currently this gives a good match with Hubei (see chart "total deaths (limited to 7 days in future)... but it must be noted that the measures in the Netherlands are currently far from the actual lock down measures taken in Hubei. So the coming days we will see that the limited dutch measures have similar positive effect as in Hubei.

Updated charts for Italy with lock down date 202-03-05


  1. Hubei factor increased from 5.424 to 6.186 compared to same charts generated 3 days ago (2020-03-19) for same lock down date. So Italy might expect more than 6 times the amount of deaths compared to Hubei.
  2. In chart "total deaths (limited to 7 days in the future)" you see that the curve is more rapidly increasing compared to Hubei. This is concerning. It might mean that Italy is not following the same path as Hubei. So the measures taken by Italy around 2020-03-05 don't have the same positive effect as the measures taken by Hubei when they introduced the lock-down.

Charts for France with lock down date = 2020-03-12.


  1. Based on Hubei factor = 2.257 (total deaths = 7000) it seems to be about halve so severe as in Spain or in Italy.
  2. When looking at chart "total deaths (limited to 7 days in future)" it shows that the number is more rapidly increasing than Hubei (a similar thing has been seen for Belgium). So predictions might change the coming days.

New Charts for Belgium for lock down date = 2020-03-12.
(note that the charts already include the 668 new confirmed cases and 54 deaths reported today 2020-03-25).


  • Belgium is not following the Hubei graph as can be seen in graph "total deaths (limited to 7 days in future)". The number of deaths is more rapidly increasing compared to Hubei. This has been reported earlier (see [Belgium chart with data of 4 days ago])([Flow] Corona country comparison with Hubei (China))
  • The hubei factor also increased from 0.269 (at 2020-03-21) to 0.324 today (= 2020-03-25).
1 Like

Do you have the latest UK charts please @janvda
The lockdown date for UK was 23/3/20

Charts for United Kingdom with lock down 2020-03-23


  1. Hubei factor for the United Kingdom based on a lock down date of 2020-03-23 is 17.583 (corresponds to about 55,000 deaths at the end of May).
  2. Let's hope that the measures taken by the UK before 2020-03-23 already reduced the spreading of the virus much more effectively than what happened in Hubei before they introduced the lock down at 23rd of January 2020. In that case the actual numbers will be much lower than what is extrapolated in these charts.


  • The charts with new and total confirmed cases show 0 for united kingdom. This is of course not correct. A couple a days ago the source input for these charts changed which caused this - I still need to make a correction for that.