(Andamenti regionali)
Riga 22: Riga 22:
 
<script>
 
<script>
  
Plotly.d3.csv(
+
    Plotly.d3.csv('https://raw.githubusercontent.com/pcm-dpc/COVID-19/master/dati-regioni/dpc-covid19-ita-regioni.csv', function(err, rows){
  "https://raw.githubusercontent.com/pcm-dpc/COVID-19/master/dati-regioni/dpc-covid19-ita-regioni.csv",
 
  function(err, rows) {
 
    function unpack(rows, key) {
 
      return rows.map(function(row) {
 
        return row[key];
 
      });
 
    }
 
  
    var allRegionNames = unpack(rows, "denominazione_regione"),
+
        function unpack(rows, key) {
      allDay = unpack(rows, "data"),
+
            return rows.map(function(row) { return row[key]; });
      allRicoverati = unpack(rows, "ricoverati_con_sintomi"),
+
        }
      allTi = unpack(rows, "terapia_intensiva"),
 
      allTo = unpack(rows, "totale_ospedalizzati"),
 
      allIdom = unpack(rows, "isolamento_domiciliare"),
 
      allAttPos = unpack(rows, "totale_attualmente_positivi"),
 
      allNewPos = unpack(rows, "nuovi_attualmente_positivi"),
 
      allDimGuariti = unpack(rows, "dimessi_guariti"),
 
      allMorti = unpack(rows, "deceduti"),
 
      allTotCasi = unpack(rows, "totale_casi"),
 
      allTamponi = unpack(rows, "tamponi"),
 
      listofRegions = [],
 
      currentCountry,
 
      currentGdp = [],
 
      currentYear = [];
 
    currTitle = "Abruzzo";
 
    currallRicoverati = [];
 
    currallTi = [];
 
    currallTo = [];
 
    currallIdom = [];
 
    currallAttPos = [];
 
    currallNewPos = [];
 
    currallDimGuariti = [];
 
    currallMorti = [];
 
    currallTotCasi = [];
 
    currallTamponi = [];
 
  
    for (var i = 0; i < allRegionNames.length; i++) {
+
        var allRegionNames = unpack(rows, 'denominazione_regione'),
      if (listofRegions.indexOf(allRegionNames[i]) === -1) {
+
            allDay = unpack(rows, 'data'),
        listofRegions.push(allRegionNames[i]);
+
            allRicoverati = unpack(rows, 'ricoverati_con_sintomi'),
      }
+
            allTi = unpack(rows, 'terapia_intensiva'),
    }
+
            allTo = unpack(rows, 'totale_ospedalizzati'),
 +
            allIdom = unpack(rows, 'isolamento_domiciliare'),
 +
            allAttPos = unpack(rows, 'totale_attualmente_positivi'),
 +
            allNewPos = unpack(rows, 'nuovi_attualmente_positivi'),
 +
            allDimGuariti = unpack(rows, 'dimessi_guariti'),
 +
            allMorti = unpack(rows, 'deceduti'),
 +
            allTotCasi = unpack(rows, 'totale_casi'),
 +
            allTamponi = unpack(rows, 'tamponi'),
  
    function getRegionData(chosenCountry) {
+
            listofRegions = [],
      currTitle = chosenCountry;
+
            currentCountry,
      currentYear = [];
+
            currentGdp = [],
      currallRicoverati = [];
+
            currentYear = [];
      currallTi = [];
+
            currTitle = 'Abruzzo';
      currallTo = [];
+
            currallRicoverati = [];
      currallIdom = [];
+
            currallTi = [];
      currallAttPos = [];
+
            currallTo = [];
      currallNewPos = [];
+
            currallIdom = [];
      currallDimGuariti = [];
+
            currallAttPos = [];
      currallMorti = [];
+
            currallNewPos = [];
      currallTotCasi = [];
+
            currallDimGuariti = [];
      currallTamponi = [];
+
            currallMorti = [];
 +
            currallTotCasi = [];
 +
            currallTamponi = [];
  
      for (var i = 0; i < allRegionNames.length; i++) {
+
            currallMortiTi = [];
        if (allRegionNames[i] === chosenCountry) {
+
            currallMortiOsp = [];
          currentYear.push(allDay[i]);
+
 
          currallRicoverati.push(allRicoverati[i]);
+
        for (var i = 0; i < allRegionNames.length; i++ ){
          currallTi.push(allTi[i]);
+
            if (listofRegions.indexOf(allRegionNames[i]) === -1 ){
          currallTo.push(allTo[i]);
+
                listofRegions.push(allRegionNames[i]);
          currallIdom.push(allIdom[i]);
+
            }
          currallAttPos.push(allAttPos[i]);
 
          currallNewPos.push(allNewPos[i]);
 
          currallDimGuariti.push(allDimGuariti[i]);
 
          currallMorti.push(allMorti[i]);
 
          currallTotCasi.push(allTotCasi[i]);
 
          currallTamponi.push(allTamponi[i]);
 
 
         }
 
         }
      }
 
    }
 
  
    // Default Region Data
+
        function getRegionData(chosenCountry) {
    setBubblePlot("Abruzzo");
+
            currTitle = chosenCountry;
 +
            currentYear = [];
 +
            currallRicoverati = [];
 +
            currallTi = [];
 +
            currallTo = [];
 +
            currallIdom = [];
 +
            currallAttPos = [];
 +
            currallNewPos = [];
 +
            currallDimGuariti = [];
 +
            currallMorti = [];
 +
            currallTotCasi = [];
 +
            currallTamponi = [];
 +
 
 +
            currallMortiTi = [];
 +
            currallMortiOsp = [];
 +
 
 +
            for (var i = 0 ; i < allRegionNames.length ; i++){
 +
                if ( allRegionNames[i] === chosenCountry ) {
 +
                    currentYear.push(allDay[i]);
 +
                    currallRicoverati.push(allRicoverati[i]);
 +
                    currallTi.push(allTi[i]);
 +
                    currallTo.push(allTo[i]);
 +
                    currallIdom.push(allIdom[i]);
 +
                    currallAttPos.push(allAttPos[i]);
 +
                    currallNewPos.push(allNewPos[i]);
 +
                    currallDimGuariti.push(allDimGuariti[i]);
 +
                    currallMorti.push(allMorti[i]);
 +
                    currallTotCasi.push(allTotCasi[i]);
 +
                    currallTamponi.push(allTamponi[i]);
  
    function setBubblePlot(chosenCountry) {
+
                    currallMortiTi.push(parseInt(allTi[i])+parseInt(allMorti[i]));
      getRegionData(chosenCountry);
+
                    currallMortiOsp.push(parseInt(allTo[i])+parseInt(allMorti[i]));
 +
                }
 +
            }
 +
        };
 +
 
 +
        // Default Region Data
 +
        setBubblePlot('Abruzzo');
 +
 
 +
        function setBubblePlot(chosenCountry) {
 +
            getRegionData(chosenCountry);
  
 
             var trace1 = {
 
             var trace1 = {
Riga 127: Riga 134:
  
 
             var trace3 = {
 
             var trace3 = {
 +
                visible: 'legendonly',
 
                 x: currentYear,
 
                 x: currentYear,
 
                 y: currallTo,
 
                 y: currallTo,
Riga 150: Riga 158:
  
 
             var trace5 = {
 
             var trace5 = {
 +
                visible: 'legendonly',
 
                 x: currentYear,
 
                 x: currentYear,
 
                 y: currallAttPos,
 
                 y: currallAttPos,
Riga 218: Riga 227:
 
             };
 
             };
  
      var data = [
+
            var trace11 = {
        trace1,
+
                x: currentYear,
        trace2,
+
                y: currallMortiTi,
        trace3,
+
                mode: 'markers',
        trace4,
+
                name: 'Morti+Terapia Intensiva',
        trace5,
+
                marker: {
        trace6,
+
                    size: 10,
        trace7,
+
                    opacity: 0.5
        trace8,
+
                }
        trace9,
+
            };
        trace10
 
      ];
 
  
      var updatemenus = [
+
            var trace12 = {
        {
+
                x: currentYear,
          buttons: [
+
                y: currallMortiOsp,
            {
+
                mode: 'markers',
              args: [{ "yaxis.type": "linear", "yaxis.tickmode": "auto" }],
+
                name: 'Morti+Ospedalizzati',
              label: "Linear",
+
                marker: {
              method: "relayout"
+
                    size: 10,
            },
+
                    opacity: 0.5
            {
+
                }
              args: [{ "yaxis.type": "log", "yaxis.dtick": 1 }],
+
            };
              label: "SemiLog",
 
              method: "relayout"
 
            }
 
          ],
 
          direction: "left",
 
          pad: { r: 10, t: 10 },
 
          showactive: true,
 
          type: "buttons",
 
          x: 0.1,
 
          xanchor: "left",
 
          y: 1.1,
 
          yanchor: "top"
 
        }
 
      ];
 
  
      var annotations = [
+
            var data = [trace1,
        {
+
                        trace2,
          text: "Plot type:",
+
                        trace3,
          x: 0,
+
                        trace4,
          y: 1.085,
+
                        trace5,  
          yref: "paper",
+
                        trace6,  
          align: "left",
+
                        trace7,  
          showarrow: false
+
                        trace8,  
        }
+
                        trace9,  
      ];
+
                        trace10,
 +
                    trace11,
 +
                trace12];
  
      var layout = {
+
            var updatemenus=[
        title: "Andamento regionale " + currTitle,
+
                {
        //height: 400,
+
                    buttons: [
        //width: 800,
+
                        {
        margin: { l: 40, r: 0 },
+
                            args: [{'yaxis.type': 'linear',
        updatemenus: updatemenus,
+
                                    'yaxis.tickmode':'auto'}],
        //annotations: annotations,
+
                            label: 'Linear',
        showlegend: true,
+
                            method: 'relayout'
        legend: { orientation: "h" },
+
                        },
        yaxis: {
+
                        {
          autorange: true
+
                            args: [{'yaxis.type':'log',
 +
                                    'yaxis.dtick':1}],
 +
                            label:'SemiLog',
 +
                            method:'relayout'
 +
                        }
 +
                    ],
 +
                    direction: 'left',
 +
                    pad: {'r': 10, 't': 10},
 +
                    showactive: true,
 +
                    type: 'buttons',
 +
                    x: 0.1,
 +
                    xanchor: 'left',
 +
                    y: 1.1,
 +
                    yanchor: 'top'
 +
                }
 +
            ]
  
          //type: 'log',
+
            var annotations = [
          //fixedrange: true,
+
                {
          //range: [0,3.70]
+
                text: 'Plot type:',
          //range: [0,5000]
+
                x: 0,
        }
+
                y: 1.085,
      };
+
                yref: 'paper',
      var options = {
+
                align: 'left',
        scrollZoom: true,
+
                showarrow: false
        displayModeBar: false,
+
                }
        responsive: true
+
            ]
      };
 
      Plotly.newPlot("myDiv", data, layout, options);
 
    }
 
  
    var innerContainer = document.querySelector('[data-num="0"'),
+
            var layout = {
      plotEl = innerContainer.querySelector(".plot"),
+
                title: 'Andamento regionale ' + currTitle,
      countrySelector = innerContainer.querySelector(".countrydata");
+
                //height: 400,
 +
                //width: 800,
 +
                updatemenus: updatemenus,
 +
                //annotations: annotations,
 +
                showlegend: true,
 +
                //legend: {"orientation": "h"},
 +
                yaxis: {
 +
                    autorange: true
 +
                   
 +
                    //type: 'log',
 +
                    //fixedrange: true,
 +
                    //range: [0,3.70]
 +
                    //range: [0,5000]
 +
                }
 +
            };
 +
            var options = {
 +
                scrollZoom: true,
 +
                displayModeBar: false
 +
            };
 +
            Plotly.newPlot('myDiv', data, layout,options);
 +
        };
  
    function assignOptions(textArray, selector) {
+
         var innerContainer = document.querySelector('[data-num="0"'),
      for (var i = 0; i < textArray.length; i++) {
+
            plotEl = innerContainer.querySelector('.plot'),
         var currentOption = document.createElement("option");
+
            countrySelector = innerContainer.querySelector('.countrydata');
        currentOption.text = textArray[i];
 
        selector.appendChild(currentOption);
 
      }
 
    }
 
  
    assignOptions(listofRegions, countrySelector);
+
        function assignOptions(textArray, selector) {
 +
            for (var i = 0; i < textArray.length;  i++) {
 +
                var currentOption = document.createElement('option');
 +
                currentOption.text = textArray[i];
 +
                selector.appendChild(currentOption);
 +
            }
 +
        }
  
    function updateCountry() {
+
        assignOptions(listofRegions, countrySelector);
      setBubblePlot(countrySelector.value);
 
    }
 
  
    countrySelector.addEventListener("change", updateCountry, false);
+
        function updateCountry(){
  }
+
            setBubblePlot(countrySelector.value);
);
+
        }
  
 +
        countrySelector.addEventListener('change', updateCountry, false);
 +
    });
  
 
</script>
 
</script>

Revisione 17:15, 14 Mar 2020

COVID19 - Monitoraggio ed Analisi della situazione italiana

Andamenti regionali

Regione:

Disclaimer

Dati forniti dal Ministero della Salute, elaborazione e gestione dati a cura del Dipartimento della Protezione Civile: https://github.com/pcm-dpc/COVID-19

Rielaborazione a cura del Control of dynamic system Lab, Politecnico di Bari

COVID19 - Monitoraggio ed Analisi della situazione italiana[edit]

Andamenti regionali[edit]

Regione:

Disclaimer[edit]

Dati forniti dal Ministero della Salute, elaborazione e gestione dati a cura del Dipartimento della Protezione Civile: https://github.com/pcm-dpc/COVID-19

Rielaborazione a cura del Control of dynamic system Lab, Politecnico di Bari