(Andamento nazionale)
(COVID19 - Monitoraggio ed Analisi della situazione italiana)
Riga 2: Riga 2:
 
== Andamento nazionale ==
 
== Andamento nazionale ==
 
<html>
 
<html>
<div id="myDiv" style="height:500px;"></div>
+
<div id="myDiv2" style="height:500px;"></div>
 +
<script>
 +
Plotly.d3.csv('https://raw.githubusercontent.com/pcm-dpc/COVID-19/master/dati-andamento-nazionale/dpc-covid19-ita-andamento-nazionale.csv', function(err, rows){
  
 +
    function unpack(rows, key) {
 +
        return rows.map(function(row) { return row[key]; });
 +
    }
 +
 +
    var allRegionNames = unpack(rows, 'stato'),
 +
        allDay = unpack(rows, 'data'),
 +
        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 = 'ITA';
 +
        currallRicoverati = [];
 +
        currallTi = [];
 +
        currallTo = [];
 +
        currallIdom = [];
 +
        currallAttPos = [];
 +
        currallNewPos = [];
 +
        currallDimGuariti = [];
 +
        currallMorti = [];
 +
        currallTotCasi = [];
 +
        currallTamponi = [];
 +
 +
        currallMortiTi = [];
 +
        currallMortiOsp = [];
 +
        //allDay = allDay.split(' ')[0];
 +
 +
    for (var i = 0; i < allRegionNames.length; i++ ){
 +
        if (listofRegions.indexOf(allRegionNames[i]) === -1 ){
 +
            listofRegions.push(allRegionNames[i]);
 +
        }
 +
    }
 +
 +
    function getRegionData(chosenCountry) {
 +
        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].split(' ')[0]);
 +
                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]);
 +
 +
                currallMortiTi.push(parseInt(allTi[i])+parseInt(allMorti[i]));
 +
                currallMortiOsp.push(parseInt(allTo[i])+parseInt(allMorti[i]));
 +
            }
 +
        }
 +
    };
 +
 +
    // Default Region Data
 +
    setBubblePlot('ITA');
 +
 +
    function setBubblePlot(chosenCountry) {
 +
        getRegionData(chosenCountry);
 +
 +
        var trace1 = {
 +
            visible: 'legendonly',
 +
            x: currentYear,
 +
            y: currallRicoverati,
 +
           
 +
            name: 'Ricoverati con sintomi',
 +
            mode: 'markers',
 +
            marker: {
 +
                size: 6,
 +
                opacity: 1
 +
            }
 +
        };
 +
 +
        var trace2 = {
 +
            visible: 'legendonly',
 +
            x: currentYear,
 +
            y: currallTi,
 +
           
 +
            mode: 'markers',
 +
            name: 'Terapia Intensiva',
 +
            marker: {
 +
                size: 6,
 +
                opacity: 1
 +
            }
 +
        };
 +
 +
        var trace3 = {
 +
            visible: 'legendonly',
 +
            x: currentYear,
 +
            y: currallTo,
 +
           
 +
            mode: 'markers',
 +
            name: 'Totale ospedalizzati',
 +
            marker: {
 +
                size: 6,
 +
                opacity: 1,
 +
                symbol: 'triangle-down'
 +
            }
 +
        };
 +
 +
        var trace4 = {
 +
            visible: 'legendonly',
 +
            x: currentYear,
 +
            y: currallIdom,
 +
           
 +
            mode: 'markers',
 +
            name: 'Isolamento domiciliare',
 +
            marker: {
 +
                size: 6,
 +
                opacity: 1,
 +
                symbol: 'triangle-left'
 +
            }
 +
        };
 +
 +
        var trace5 = {
 +
            visible: 'legendonly',
 +
            x: currentYear,
 +
            y: currallAttPos,
 +
           
 +
            mode: 'markers',
 +
            name: 'Totale attualmente positivi',
 +
            marker: {
 +
                size: 6,
 +
                opacity: 1,
 +
                symbol: 'triangle-right'
 +
            }
 +
        };
 +
 +
        var trace6 = {
 +
            visible: 'legendonly',
 +
            x: currentYear,
 +
            y: currallNewPos,
 +
           
 +
            mode: 'markers',
 +
            name: 'Nuovi attualmente positivi',
 +
            marker: {
 +
                size: 6,
 +
                opacity: 1,
 +
                symbol: 'pentagon'
 +
            }
 +
        };
 +
 +
        var trace7 = {
 +
            x: currentYear,
 +
            y: currallDimGuariti,
 +
           
 +
            mode: 'markers',
 +
            name: 'Dimessi guariti',
 +
            marker: {
 +
                size: 6,
 +
                opacity: 1,
 +
                symbol: 'triangle-up'
 +
               
 +
            }
 +
        };
 +
 +
        var trace8 = {
 +
            x: currentYear,
 +
            y: currallMorti,
 +
           
 +
            mode: 'markers',
 +
            name: 'Deceduti',
 +
            marker: {
 +
                size: 6,
 +
                opacity: 1,
 +
                symbol: 'star'
 +
               
 +
            }
 +
        };
 +
 +
        var trace9 = {
 +
            x: currentYear,
 +
            y: currallTotCasi,
 +
           
 +
            mode: 'markers',
 +
            name: 'Totale casi',
 +
            marker: {
 +
                size: 6,
 +
                opacity: 1,
 +
                symbol: 'diamond'
 +
            }
 +
        };
 +
 +
        var trace10 = {
 +
            visible: 'legendonly',
 +
            x: currentYear,
 +
            y: currallTamponi,
 +
           
 +
            mode: 'markers',
 +
            name: 'Tamponi',
 +
            marker: {
 +
                size: 6,
 +
                opacity: 1,
 +
                symbol: 'square'
 +
            }
 +
        };
 +
 +
        var trace11 = {
 +
            x: currentYear,
 +
            y: currallMortiTi,
 +
           
 +
            mode: 'markers',
 +
            name: 'Deceduti+Terapia Intensiva',
 +
            marker: {
 +
                size: 6,
 +
                opacity: 1,
 +
                symbol: 'cross'
 +
            }
 +
        };
 +
 +
        var trace12 = {
 +
            x: currentYear,
 +
            y: currallMortiOsp,
 +
           
 +
            mode: 'markers',
 +
            name: 'Deceduti+Terapia Intensiva+Ricoverati',
 +
            marker: {
 +
                size: 6,
 +
                opacity: 1,
 +
                symbol: 'x'
 +
               
 +
            }
 +
        };
 +
        var d = new Date();
 +
        var when = d.getDate()-1;
 +
        console.log(when);
 +
        [dx, dy,lname, when] = get_logistic(when);
 +
 +
        var trace13 = {
 +
            x: dx,
 +
            y: dy,
 +
            mode: 'line',
 +
            name: lname,
 +
            line: {
 +
                color: 'rgba(255,0,0,0.5)',
 +
                width: 4
 +
            }
 +
        };
 +
 +
 +
        [dxa, dya,lnamea,when] = get_logistic(when);
 +
        var trace14 = {
 +
            x: dxa,
 +
            y: dya,
 +
            mode: 'line',
 +
            name: lnamea,
 +
            line: {
 +
                color: 'rgba(255,120,120,0.5)',
 +
                width: 2
 +
            }
 +
        };
 +
 +
        [dxa, dya,lnamea,when] = get_logistic(when);
 +
        var trace15 = {
 +
            x: dxa,
 +
            y: dya,
 +
            mode: 'line',
 +
            name: lnamea,
 +
            line: {
 +
                color: 'rgba(255,180,180,0.5)',
 +
                width: 2
 +
            }
 +
        };
 +
 +
        [dxa, dya,lnamea,when] = get_logistic(when);
 +
        var trace16 = {
 +
            x: dxa,
 +
            y: dya,
 +
            mode: 'line',
 +
            name: lnamea,
 +
            line: {
 +
                color: 'rgba(255,210,210,0.5)',
 +
                width: 2
 +
            }
 +
        };
 +
 +
        var data = [trace8,
 +
                    trace7,
 +
                    trace11,
 +
                    trace12,
 +
                    trace9,
 +
                    trace1,
 +
                    trace2,
 +
                    trace3,
 +
                    trace4,
 +
                    trace5,
 +
                    trace6,
 +
                    trace10,
 +
                    trace13, trace14, trace15, trace16];
 +
 +
        var updatemenus=[
 +
            {
 +
                buttons: [
 +
                    {
 +
                        args: [{'yaxis.type': 'linear',
 +
                                'yaxis.tickmode':'auto'}],
 +
                        label: 'Linear',
 +
                        method: 'relayout'
 +
                    },
 +
                    {
 +
                        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 layout = {
 +
            title: 'Andamento Italia',
 +
            height: 600,
 +
            plot_bgcolor: "#000",
 +
            //width: 800,
 +
            margin: { l: 40, r: 0},
 +
            updatemenus: updatemenus,
 +
            showlegend: true,
 +
            legend: { orientation: "h" ,
 +
                    x: 0,
 +
                    y: -0.5},
 +
            xaxis: {
 +
                tickmode: "linear", //  If "linear", the placement of the ticks is determined by a starting position `tick0` and a tick step `dtick`
 +
                tick0: '2020-02-24',
 +
                gridcolor: '#555',
 +
                dtick: 24 * 60 * 60 * 1000
 +
            },
 +
            yaxis: {
 +
                autorange: true,
 +
                gridcolor: '#555',
 +
                //type: 'log',
 +
                //fixedrange: true,
 +
                //range: [0,3.70]
 +
                //range: [0,5000]
 +
            }
 +
        };
 +
        var options = {
 +
            scrollZoom: true,
 +
            displayModeBar: false
 +
        };
 +
        Plotly.newPlot('myDiv2', data, layout,options);
 +
    };
 +
 +
    var innerContainer = document.querySelector('[data-num="0"'),
 +
        plotEl = innerContainer.querySelector('.plot'),
 +
        countrySelector = innerContainer.querySelector('.countrydata');
 +
 +
    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 get_logistic(when){
 +
        //document.write('./'+chosenCountry + '.csv');
 +
        //
 +
       
 +
        var nome = when+'.03 - Fitting';
 +
        var x = [];
 +
        var y = [];
 +
        var url = "https://raw.githubusercontent.com/vtandrea/labtest/master/"+'2020-03-'+when+"Italia.csv";
 +
        console.log(url);
 +
        var request = new XMLHttpRequest(); 
 +
        request.open("GET", url, false); 
 +
        request.send(null); 
 +
       
 +
        var csvData = new Array();
 +
        var jsonObject = request.responseText.split(/\r?\n|\r/);
 +
        for (var i = 0; i < jsonObject.length; i++) {
 +
            csvData.push(jsonObject[i].split(','));
 +
        }
 +
        for (var i=1;i<csvData.length;i++){
 +
            x.push(csvData[i][0]);
 +
            y.push(csvData[i][1]);
 +
           
 +
        }
 +
        //if(1){
 +
        if (y[40] == y[41]){
 +
            var x = [];
 +
            var y = [];
 +
            var nome = 'Empty';
 +
        }
 +
        //console.log(csvData[0][1]);
 +
        when = when-1;
 +
        return [x,y, nome,when];
 +
    }
 +
 +
    assignOptions(listofRegions, countrySelector);
 +
 +
    function updateCountry(){
 +
        setBubblePlot(countrySelector.value);
 +
    }
 +
 +
    countrySelector.addEventListener('change', updateCountry, false);
 +
});
 +
</script>
 
</html>
 
</html>
  

Revisione 02:15, 22 Mar 2020

COVID19 - Monitoraggio ed Analisi della situazione italiana

Andamento nazionale

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]

Andamento nazionale[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