(COVID19 - Monitoraggio ed Analisi della situazione italiana)
(COVID19 - Monitoraggio ed Analisi della situazione italiana)
Riga 17: Riga 17:
 
Plotly.d3.csv('https://raw.githubusercontent.com/plotly/datasets/master/gapminderDataFiveYear.csv', function(err, rows){
 
Plotly.d3.csv('https://raw.githubusercontent.com/plotly/datasets/master/gapminderDataFiveYear.csv', function(err, rows){
  
     function unpack(rows, key) {
+
     function unpack(rows, key) {     return rows.map(function(row) { return row[key]; });   }
        return rows.map(function(row) { return row[key]; });
 
    }
 
  
var allCountryNames = unpack(rows, 'country'),
+
var allCountryNames = unpack(rows, 'country'),   allYear = unpack(rows, 'year'),   allGdp = unpack(rows, 'gdpPercap'),   listofCountries = [],   currentCountry,   currentGdp = [],   currentYear = [];
    allYear = unpack(rows, 'year'),
 
    allGdp = unpack(rows, 'gdpPercap'),
 
    listofCountries = [],
 
    currentCountry,
 
    currentGdp = [],
 
    currentYear = [];
 
  
   for (var i = 0; i < allCountryNames.length; i++ ){
+
   for (var i = 0; i < allCountryNames.length; i++ ){   if (listofCountries.indexOf(allCountryNames[i]) === -1 ){     listofCountries.push(allCountryNames[i]);   } }
    if (listofCountries.indexOf(allCountryNames[i]) === -1 ){
 
      listofCountries.push(allCountryNames[i]);
 
    }
 
  }
 
 
    
 
    
   function getCountryData(chosenCountry) {
+
   function getCountryData(chosenCountry) {   currentGdp = [];   currentYear = [];   for (var i = 0 ; i < allCountryNames.length ; i++){     if ( allCountryNames[i] === chosenCountry ) {       currentGdp.push(allGdp[i]);       currentYear.push(allYear[i]);     }    } };
    currentGdp = [];
 
    currentYear = [];
 
    for (var i = 0 ; i < allCountryNames.length ; i++){
 
      if ( allCountryNames[i] === chosenCountry ) {
 
        currentGdp.push(allGdp[i]);
 
        currentYear.push(allYear[i]);
 
      }  
 
     }
 
  };
 
  
 
// Default Country Data
 
// Default Country Data
 
setBubblePlot('Afghanistan');
 
setBubblePlot('Afghanistan');
 
    
 
    
function setBubblePlot(chosenCountry) {
+
function setBubblePlot(chosenCountry) {   getCountryData(chosenCountry);   
    getCountryData(chosenCountry);   
 
  
     var trace1 = {
+
     var trace1 = {     x: currentYear,     y: currentGdp,     mode: 'lines+markers',     marker: {       size: 12,        opacity: 0.5}};
      x: currentYear,
 
      y: currentGdp,
 
      mode: 'lines+markers',
 
      marker: {
 
        size: 12,  
 
         opacity: 0.5}};
 
  
 
     var data = [trace1];
 
     var data = [trace1];

Revisione 17:30, 13 Mar 2020

COVID19 - Monitoraggio ed Analisi della situazione italiana

       Country: 

COVID19 - Monitoraggio ed Analisi della situazione italiana[edit]

       Country: