Riga 1: Riga 1:
 
<html>
 
<html>
 +
    <head>
 +
        <script src="https://cdn.plot.ly/plotly-latest.min.js"></script>
 +
       
 +
    </head>
 +
    <body>
 
<h1> COVID19 - Monitoraggio ed Analisi della situazione italiana</h1>
 
<h1> COVID19 - Monitoraggio ed Analisi della situazione italiana</h1>
 
<h2> Andamento nazionale </h1>
 
<h2> Andamento nazionale </h1>
Riga 23: Riga 28:
 
   <div id="myDiv" height:500px;"></div>
 
   <div id="myDiv" height:500px;"></div>
 
   <div style="height:150px;"></div>
 
   <div style="height:150px;"></div>
 
+
 
 +
<h2> Andamenti Provinciali </h2>
 +
          <div class="showcase__section" id="bubble">
 +
            <div class="spacer --small"></div>
 +
            <div id="bubbleplots">
 +
              <div class="bubbleplot" data-num="1">
 +
                <div class="plot" id="plotdiv"></div>
 +
                <div class="control-row">
 +
                  Provincia: <select class="provdata">
 +
                  </select>
 +
                </div>
 +
              </div>
 +
            </div>
 +
          </div>
 +
        </div>
 +
        <div id="myDiv3" style="height:500px;"></div>
 +
       
 +
<div style="height:150px;"></div>
 
<h2> Disclaimer </h2>
 
<h2> Disclaimer </h2>
 
Dati forniti dal Ministero della Salute, elaborazione e gestione dati a cura del Dipartimento della Protezione Civile: https://github.com/pcm-dpc/COVID-19
 
Dati forniti dal Ministero della Salute, elaborazione e gestione dati a cura del Dipartimento della Protezione Civile: https://github.com/pcm-dpc/COVID-19
Riga 30: Riga 52:
  
 
<script>
 
<script>
// REGIONI
+
    //REGIONI
 
Plotly.d3.csv('https://raw.githubusercontent.com/pcm-dpc/COVID-19/master/dati-regioni/dpc-covid19-ita-regioni.csv', function(err, rows){
 
Plotly.d3.csv('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'),
 +
    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 = 'Abruzzo';
 +
    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('Abruzzo');
 +
 +
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();
 +
    if (d.getHours()<18){
 +
        var when = d.setDate(d.getDate()-1);
 +
    }else{
 +
        var when = d;
 +
    }
 +
    [dx, dy,lname, when] = get_logistic(chosenCountry,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(chosenCountry,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(chosenCountry,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(chosenCountry,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 regionale ' + currTitle,
 +
        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: 7 * 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('myDiv', 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 getRandomColor(){
 +
    var r = 0;
 +
    var g = 0;
 +
    var b = 0;
 +
    r = getRandomInt(0, 255);
 +
    g = getRandomInt(0, 255);
 +
    b = getRandomInt(0, 255);
 +
    return [r,g,b];
 +
}
 +
 +
function getRandomInt(min, max) {
 +
    min = Math.ceil(min);
 +
    max = Math.floor(max);
 +
    return Math.floor(Math.random() * (max - min)) + min; //Il max è escluso e il min è incluso
 +
}
 +
 +
function rapporto(a,b){
 +
    var v = [];
 +
    for (var i=0;i<a.length;i++){
 +
        v.push(a[i]/b[i] * 100);
 +
    }
 +
   
 +
    return v;
 +
}
 +
function get_diff(vect){
 +
    var vdiff = [];
 +
    vdiff.push(0);
 +
    for (var i=1;i<vect.length;i++){
 +
        vdiff.push(vect[i]-vect[i-1]);
 +
    }
 +
   
 +
    return vdiff;
 +
}
 +
function formatDate(date) {
 +
    var d = new Date(date),
 +
        month = '' + (d.getMonth() + 1),
 +
        day = '' + d.getDate(),
 +
        year = d.getFullYear();
 +
 +
    if (month.length < 2)
 +
        month = '0' + month;
 +
    if (day.length < 2)
 +
        day = '0' + day;
 +
 +
    return [year, month, day].join('-');
 +
};
 +
 +
function formatDate2(date) {
 +
    var d = new Date(date),
 +
        month = '' + (d.getMonth() + 1),
 +
        day = '' + d.getDate()
 +
 +
    if (month.length < 2)
 +
        month = '0' + month;
 +
    if (day.length < 2)
 +
        day = '0' + day;
 +
 +
    return [day, month].join('.');
 +
};
 +
 +
function get_logistic(chosenCountry,when){
 +
    d = formatDate(when);
 +
    d2 = formatDate2(when);
 +
    var nome = d2+' - Fitting';
 +
    var x = [];
 +
    var y = [];
 +
    var url = "https://raw.githubusercontent.com/vtandrea/labtest/master/"+d+chosenCountry+".csv";
 +
    when.setDate(when.getDate() - 1);
 +
    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]);
 +
    return [x,y, nome,when];
 +
}
 +
 +
assignOptions(listofRegions, countrySelector);
 +
 +
function updateCountry(){
 +
    setBubblePlot(countrySelector.value);
 +
}
 +
 +
countrySelector.addEventListener('change', updateCountry, false);
 +
});
 +
</script>
 +
 +
 +
 +
<script>
 +
    // ITA
 +
    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) {
 
     function unpack(rows, key) {
Riga 37: Riga 557:
 
     }
 
     }
  
     var allRegionNames = unpack(rows, 'denominazione_regione'),
+
     var allRegionNames = unpack(rows, 'stato'),
 
         allDay = unpack(rows, 'data'),
 
         allDay = unpack(rows, 'data'),
 
         allRicoverati = unpack(rows, 'ricoverati_con_sintomi'),
 
         allRicoverati = unpack(rows, 'ricoverati_con_sintomi'),
Riga 54: Riga 574:
 
         currentGdp = [],
 
         currentGdp = [],
 
         currentYear = [];
 
         currentYear = [];
         currTitle = 'Abruzzo';
+
         currTitle = 'ITA';
 
         currallRicoverati = [];
 
         currallRicoverati = [];
 
         currallTi = [];
 
         currallTi = [];
Riga 114: Riga 634:
  
 
     // Default Region Data
 
     // Default Region Data
     setBubblePlot('Abruzzo');
+
     setBubblePlot('ITA');
  
 
     function setBubblePlot(chosenCountry) {
 
     function setBubblePlot(chosenCountry) {
Riga 288: Riga 808:
 
             var when = d;
 
             var when = d;
 
         }
 
         }
         [dx, dy,lname, when] = get_logistic(chosenCountry,when);
+
         [dx, dy,lname, when] = get_logistic(when);
  
 
         var trace13 = {
 
         var trace13 = {
Riga 302: Riga 822:
  
  
         [dxa, dya,lnamea,when] = get_logistic(chosenCountry,when);
+
         [dxa, dya,lnamea,when] = get_logistic(when);
 
         var trace14 = {
 
         var trace14 = {
 
             x: dxa,
 
             x: dxa,
Riga 314: Riga 834:
 
         };
 
         };
  
         [dxa, dya,lnamea,when] = get_logistic(chosenCountry,when);
+
         [dxa, dya,lnamea,when] = get_logistic(when);
 
         var trace15 = {
 
         var trace15 = {
 
             x: dxa,
 
             x: dxa,
Riga 326: Riga 846:
 
         };
 
         };
  
         [dxa, dya,lnamea,when] = get_logistic(chosenCountry,when);
+
         [dxa, dya,lnamea,when] = get_logistic(when);
 
         var trace16 = {
 
         var trace16 = {
 
             x: dxa,
 
             x: dxa,
Riga 336: Riga 856:
 
                 width: 2
 
                 width: 2
 
             }
 
             }
         };      
+
         };
  
 
         var data = [trace8,  
 
         var data = [trace8,  
Riga 350: Riga 870:
 
                     trace6,
 
                     trace6,
 
                     trace10,
 
                     trace10,
                     trace13, trace14, trace15, trace16,];
+
                     trace13, trace14, trace15, trace16];
  
 
         var updatemenus=[
 
         var updatemenus=[
Riga 380: Riga 900:
  
 
         var layout = {
 
         var layout = {
             title: 'Andamento regionale ' + currTitle,
+
             title: 'Andamento Italia',
 
             height: 600,
 
             height: 600,
 
             plot_bgcolor: "#000",
 
             plot_bgcolor: "#000",
Riga 409: Riga 929:
 
             displayModeBar: false
 
             displayModeBar: false
 
         };
 
         };
         Plotly.newPlot('myDiv', data, layout,options);
+
         Plotly.newPlot('myDiv2', data, layout,options);
 
     };
 
     };
  
Riga 422: Riga 942:
 
             selector.appendChild(currentOption);
 
             selector.appendChild(currentOption);
 
         }
 
         }
    }
 
    function getRandomColor(){
 
        var r = 0;
 
        var g = 0;
 
        var b = 0;
 
        r = getRandomInt(0, 255);
 
        g = getRandomInt(0, 255);
 
        b = getRandomInt(0, 255);
 
        return [r,g,b];
 
    }
 
 
    function getRandomInt(min, max) {
 
        min = Math.ceil(min);
 
        max = Math.floor(max);
 
        return Math.floor(Math.random() * (max - min)) + min; //Il max è escluso e il min è incluso
 
 
     }
 
     }
  
    function rapporto(a,b){
 
        var v = [];
 
        for (var i=0;i<a.length;i++){
 
            v.push(a[i]/b[i] * 100);
 
        }
 
       
 
        return v;
 
    }
 
    function get_diff(vect){
 
        var vdiff = [];
 
        vdiff.push(0);
 
        for (var i=1;i<vect.length;i++){
 
            vdiff.push(vect[i]-vect[i-1]);
 
        }
 
       
 
        return vdiff;
 
    }
 
 
     function formatDate(date) {
 
     function formatDate(date) {
 
         var d = new Date(date),
 
         var d = new Date(date),
Riga 461: Riga 949:
 
             day = '' + d.getDate(),
 
             day = '' + d.getDate(),
 
             year = d.getFullYear();
 
             year = d.getFullYear();
   
+
 
 
         if (month.length < 2)  
 
         if (month.length < 2)  
 
             month = '0' + month;
 
             month = '0' + month;
 
         if (day.length < 2)  
 
         if (day.length < 2)  
 
             day = '0' + day;
 
             day = '0' + day;
   
+
 
 
         return [year, month, day].join('-');
 
         return [year, month, day].join('-');
 
     };
 
     };
Riga 474: Riga 962:
 
             month = '' + (d.getMonth() + 1),
 
             month = '' + (d.getMonth() + 1),
 
             day = '' + d.getDate()
 
             day = '' + d.getDate()
   
+
 
 
         if (month.length < 2)  
 
         if (month.length < 2)  
 
             month = '0' + month;
 
             month = '0' + month;
 
         if (day.length < 2)  
 
         if (day.length < 2)  
 
             day = '0' + day;
 
             day = '0' + day;
   
+
 
 
         return [day, month].join('.');
 
         return [day, month].join('.');
 
     };
 
     };
  
     function get_logistic(chosenCountry,when){
+
     function get_logistic(when){
 
         d = formatDate(when);
 
         d = formatDate(when);
 
         d2 = formatDate2(when);
 
         d2 = formatDate2(when);
Riga 489: Riga 977:
 
         var x = [];
 
         var x = [];
 
         var y = [];
 
         var y = [];
         var url = "https://raw.githubusercontent.com/vtandrea/labtest/master/"+d+chosenCountry+".csv";
+
 
 +
         var url = "https://raw.githubusercontent.com/vtandrea/labtest/master/"+d+"Italia.csv";
 
         when.setDate(when.getDate() - 1);
 
         when.setDate(when.getDate() - 1);
 
         var request = new XMLHttpRequest();   
 
         var request = new XMLHttpRequest();   
Riga 515: Riga 1 004:
 
     }
 
     }
  
     assignOptions(listofRegions, countrySelector);
+
     });
 
 
    function updateCountry(){
 
        setBubblePlot(countrySelector.value);
 
    }
 
 
 
    countrySelector.addEventListener('change', updateCountry, false);
 
});
 
 
</script>
 
</script>
 
 
  
 
<script>
 
<script>
// ITA
+
    // PROV
Plotly.d3.csv('https://raw.githubusercontent.com/pcm-dpc/COVID-19/master/dati-andamento-nazionale/dpc-covid19-ita-andamento-nazionale.csv', function(err, rows){
+
    Plotly.d3.csv('https://raw.githubusercontent.com/pcm-dpc/COVID-19/master/dati-province/dpc-covid19-ita-province.csv', function(err, rows){
  
 
     function unpack(rows, key) {
 
     function unpack(rows, key) {
Riga 535: Riga 1 015:
 
     }
 
     }
  
     var allRegionNames = unpack(rows, 'stato'),
+
     var allRegionNames = unpack(rows, 'denominazione_provincia'),
 
         allDay = unpack(rows, 'data'),
 
         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'),
 
         allTotCasi = unpack(rows, 'totale_casi'),
        allTamponi = unpack(rows, 'tamponi'),
 
  
 
         listofRegions = [],
 
         listofRegions = [],
        currentCountry,
 
        currentGdp = [],
 
 
         currentYear = [];
 
         currentYear = [];
         currTitle = 'ITA';
+
         currTitle = 'Agrigento';
        currallRicoverati = [];
 
        currallTi = [];
 
        currallTo = [];
 
        currallIdom = [];
 
        currallAttPos = [];
 
        currallNewPos = [];
 
        currallDimGuariti = [];
 
        currallMorti = [];
 
 
         currallTotCasi = [];
 
         currallTotCasi = [];
        currallTamponi = [];
 
 
        currallMortiTi = [];
 
        currallMortiOsp = [];
 
        //allDay = allDay.split(' ')[0];
 
  
 
     for (var i = 0; i < allRegionNames.length; i++ ){
 
     for (var i = 0; i < allRegionNames.length; i++ ){
Riga 573: Riga 1 029:
 
         }
 
         }
 
     }
 
     }
 +
    listofRegions.sort();
  
 
     function getRegionData(chosenCountry) {
 
     function getRegionData(chosenCountry) {
 
         currTitle = chosenCountry;
 
         currTitle = chosenCountry;
 
         currentYear = [];
 
         currentYear = [];
        currallRicoverati = [];
 
        currallTi = [];
 
        currallTo = [];
 
        currallIdom = [];
 
        currallAttPos = [];
 
        currallNewPos = [];
 
        currallDimGuariti = [];
 
        currallMorti = [];
 
 
         currallTotCasi = [];
 
         currallTotCasi = [];
        currallTamponi = [];
 
 
        currallMortiTi = [];
 
        currallMortiOsp = [];
 
  
 
         for (var i = 0 ; i < allRegionNames.length ; i++){
 
         for (var i = 0 ; i < allRegionNames.length ; i++){
 
             if ( allRegionNames[i] === chosenCountry ) {
 
             if ( allRegionNames[i] === chosenCountry ) {
 
                 currentYear.push(allDay[i].split(' ')[0]);
 
                 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]);
 
                 currallTotCasi.push(allTotCasi[i]);
                currallTamponi.push(allTamponi[i]);
 
 
                currallMortiTi.push(parseInt(allTi[i])+parseInt(allMorti[i]));
 
                currallMortiOsp.push(parseInt(allTo[i])+parseInt(allMorti[i]));
 
 
             }
 
             }
 
         }
 
         }
Riga 612: Riga 1 045:
  
 
     // Default Region Data
 
     // Default Region Data
     setBubblePlot('ITA');
+
     setBubblePlot('Agrigento');
  
 
     function setBubblePlot(chosenCountry) {
 
     function setBubblePlot(chosenCountry) {
Riga 618: Riga 1 051:
  
 
         var trace1 = {
 
         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,
 
             x: currentYear,
 
             y: currallTotCasi,
 
             y: currallTotCasi,
Riga 734: Riga 1 057:
 
             name: 'Totale casi',
 
             name: 'Totale casi',
 
             marker: {
 
             marker: {
                 size: 6,
+
                 size: 10
                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();
 
        if (d.getHours()<18){
 
            var when = d.setDate(d.getDate()-1);
 
        }else{
 
            var when = d;
 
        }
 
        [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,
+
         var data = [trace1];
                    trace7,
 
                    trace11,
 
                    trace12,
 
                    trace9,
 
                    trace1,
 
                    trace2,
 
                    trace3,
 
                    trace4,
 
                    trace5,
 
                    trace6,
 
                    trace10,
 
                    trace13, trace14, trace15, trace16];
 
  
 
         var updatemenus=[
 
         var updatemenus=[
Riga 878: Riga 1 091:
  
 
         var layout = {
 
         var layout = {
             title: 'Andamento Italia',
+
             title: 'Andamento Provincia di ' + currTitle,
 
             height: 600,
 
             height: 600,
 
             plot_bgcolor: "#000",
 
             plot_bgcolor: "#000",
Riga 886: Riga 1 099:
 
             showlegend: true,
 
             showlegend: true,
 
             legend: { orientation: "h" ,
 
             legend: { orientation: "h" ,
                     x: 0,
+
                     x: 1,
                     y: -0.5},
+
                     y: 1},
 
             xaxis: {
 
             xaxis: {
 
                 tickmode: "linear", //  If "linear", the placement of the ticks is determined by a starting position `tick0` and a tick step `dtick`
 
                 tickmode: "linear", //  If "linear", the placement of the ticks is determined by a starting position `tick0` and a tick step `dtick`
Riga 897: Riga 1 110:
 
                 autorange: true,
 
                 autorange: true,
 
                 gridcolor: '#555',
 
                 gridcolor: '#555',
                //type: 'log',
 
                //fixedrange: true,
 
                //range: [0,3.70]
 
                //range: [0,5000]
 
 
             }
 
             }
 
         };
 
         };
Riga 907: Riga 1 116:
 
             displayModeBar: false
 
             displayModeBar: false
 
         };
 
         };
         Plotly.newPlot('myDiv2', data, layout,options);
+
         Plotly.newPlot('myDiv3', data, layout,options);
 
     };
 
     };
  
     var innerContainer = document.querySelector('[data-num="0"'),
+
     var innerContainer = document.querySelector('[data-num="1"'),
         plotEl = innerContainer.querySelector('.plot'),
+
         //plotEl = innerContainer.querySelector('.plot'),
         countrySelector = innerContainer.querySelector('.countrydata');
+
         countrySelector = innerContainer.querySelector('.provdata');
  
 
     function assignOptions(textArray, selector) {
 
     function assignOptions(textArray, selector) {
Riga 920: Riga 1 129:
 
             selector.appendChild(currentOption);
 
             selector.appendChild(currentOption);
 
         }
 
         }
    }
 
 
    function formatDate(date) {
 
        var d = new Date(date),
 
            month = '' + (d.getMonth() + 1),
 
            day = '' + d.getDate(),
 
            year = d.getFullYear();
 
   
 
        if (month.length < 2)
 
            month = '0' + month;
 
        if (day.length < 2)
 
            day = '0' + day;
 
   
 
        return [year, month, day].join('-');
 
    };
 
 
    function formatDate2(date) {
 
        var d = new Date(date),
 
            month = '' + (d.getMonth() + 1),
 
            day = '' + d.getDate()
 
   
 
        if (month.length < 2)
 
            month = '0' + month;
 
        if (day.length < 2)
 
            day = '0' + day;
 
   
 
        return [day, month].join('.');
 
    };
 
 
    function get_logistic(when){
 
        d = formatDate(when);
 
        d2 = formatDate2(when);
 
        var nome = d2+' - Fitting';
 
        var x = [];
 
        var y = [];
 
 
        var url = "https://raw.githubusercontent.com/vtandrea/labtest/master/"+d+"Italia.csv";
 
        when.setDate(when.getDate() - 1);
 
        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]);
 
        return [x,y, nome,when];
 
 
     }
 
     }
  
Riga 989: Riga 1 138:
  
 
     countrySelector.addEventListener('change', updateCountry, false);
 
     countrySelector.addEventListener('change', updateCountry, false);
});
+
    });
 
</script>
 
</script>
 +
 +
 +
</body>
 
</html>
 
</html>

Revisione 18:16, 1 Apr 2020

COVID19 - Monitoraggio ed Analisi della situazione italiana

Andamento nazionale

Andamenti regionali

Regione:

Andamenti Provinciali

Provincia:

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

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