| Riga 30: | Riga 30: | ||
<script> | <script> | ||
| − | Plotly.d3.csv('https://raw.githubusercontent.com/pcm-dpc/COVID-19/master/dati- | + | 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) { | function unpack(rows, key) { | ||
| Riga 36: | Riga 36: | ||
} | } | ||
| − | var allRegionNames = unpack(rows, ' | + | var allRegionNames = unpack(rows, 'denominazione_regione'), |
allDay = unpack(rows, 'data'), | allDay = unpack(rows, 'data'), | ||
allRicoverati = unpack(rows, 'ricoverati_con_sintomi'), | allRicoverati = unpack(rows, 'ricoverati_con_sintomi'), | ||
| Riga 53: | Riga 53: | ||
currentGdp = [], | currentGdp = [], | ||
currentYear = []; | currentYear = []; | ||
| − | currTitle = ' | + | currTitle = 'Abruzzo'; |
currallRicoverati = []; | currallRicoverati = []; | ||
currallTi = []; | currallTi = []; | ||
| Riga 113: | Riga 113: | ||
// Default Region Data | // Default Region Data | ||
| − | setBubblePlot(' | + | setBubblePlot('Abruzzo'); |
function setBubblePlot(chosenCountry) { | function setBubblePlot(chosenCountry) { | ||
| Riga 282: | Riga 282: | ||
}; | }; | ||
var d = new Date(); | var d = new Date(); | ||
| − | var when = d.getDate()-1; | + | if (d.getHours()<18){ |
| − | + | var when = d.getDate()-1; | |
| − | [dx, dy,lname, when] = get_logistic(when); | + | }else{ |
| + | var when = d.getDate(); | ||
| + | } | ||
| + | [dx, dy,lname, when] = get_logistic(chosenCountry,when); | ||
var trace13 = { | var trace13 = { | ||
| Riga 298: | Riga 301: | ||
| − | [dxa, dya,lnamea,when] = get_logistic(when); | + | [dxa, dya,lnamea,when] = get_logistic(chosenCountry,when); |
var trace14 = { | var trace14 = { | ||
x: dxa, | x: dxa, | ||
| Riga 310: | Riga 313: | ||
}; | }; | ||
| − | [dxa, dya,lnamea,when] = get_logistic(when); | + | [dxa, dya,lnamea,when] = get_logistic(chosenCountry,when); |
var trace15 = { | var trace15 = { | ||
x: dxa, | x: dxa, | ||
| Riga 322: | Riga 325: | ||
}; | }; | ||
| − | [dxa, dya,lnamea,when] = get_logistic(when); | + | [dxa, dya,lnamea,when] = get_logistic(chosenCountry,when); |
var trace16 = { | var trace16 = { | ||
x: dxa, | x: dxa, | ||
| Riga 376: | Riga 379: | ||
var layout = { | var layout = { | ||
| − | title: 'Andamento | + | title: 'Andamento regionale ' + currTitle, |
height: 600, | height: 600, | ||
plot_bgcolor: "#000", | plot_bgcolor: "#000", | ||
| Riga 405: | Riga 408: | ||
displayModeBar: false | displayModeBar: false | ||
}; | }; | ||
| − | Plotly.newPlot(' | + | Plotly.newPlot('myDiv', data, layout,options); |
}; | }; | ||
| Riga 418: | Riga 421: | ||
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 get_logistic(when){ | + | 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 get_logistic(chosenCountry,when){ | ||
//document.write('./'+chosenCountry + '.csv'); | //document.write('./'+chosenCountry + '.csv'); | ||
// | // | ||
| Riga 427: | Riga 444: | ||
var x = []; | var x = []; | ||
var y = []; | var y = []; | ||
| − | var url = "https://raw.githubusercontent.com/vtandrea/labtest/master/"+'2020-03-'+when+" | + | var url = "https://raw.githubusercontent.com/vtandrea/labtest/master/"+'2020-03-'+when+chosenCountry+".csv"; |
console.log(url); | console.log(url); | ||
var request = new XMLHttpRequest(); | var request = new XMLHttpRequest(); | ||
| Riga 467: | Riga 484: | ||
<script> | <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) { | function unpack(rows, key) { | ||
| Riga 473: | Riga 490: | ||
} | } | ||
| − | var allRegionNames = unpack(rows, ' | + | 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 490: | Riga 507: | ||
currentGdp = [], | currentGdp = [], | ||
currentYear = []; | currentYear = []; | ||
| − | currTitle = ' | + | currTitle = 'ITA'; |
currallRicoverati = []; | currallRicoverati = []; | ||
currallTi = []; | currallTi = []; | ||
| Riga 550: | Riga 567: | ||
// Default Region Data | // Default Region Data | ||
| − | setBubblePlot(' | + | setBubblePlot('ITA'); |
function setBubblePlot(chosenCountry) { | function setBubblePlot(chosenCountry) { | ||
| Riga 719: | Riga 736: | ||
}; | }; | ||
var d = new Date(); | var d = new Date(); | ||
| − | var when = d.getDate()-1; | + | if (d.getHours()<18){ |
| − | [dx, dy,lname, when] = get_logistic( | + | var when = d.getDate()-1; |
| + | }else{ | ||
| + | var when = d.getDate(); | ||
| + | } | ||
| + | console.log(when); | ||
| + | [dx, dy,lname, when] = get_logistic(when); | ||
var trace13 = { | var trace13 = { | ||
| Riga 734: | Riga 756: | ||
| − | [dxa, dya,lnamea,when] = get_logistic( | + | [dxa, dya,lnamea,when] = get_logistic(when); |
var trace14 = { | var trace14 = { | ||
x: dxa, | x: dxa, | ||
| Riga 746: | Riga 768: | ||
}; | }; | ||
| − | [dxa, dya,lnamea,when] = get_logistic( | + | [dxa, dya,lnamea,when] = get_logistic(when); |
var trace15 = { | var trace15 = { | ||
x: dxa, | x: dxa, | ||
| Riga 758: | Riga 780: | ||
}; | }; | ||
| − | [dxa, dya,lnamea,when] = get_logistic( | + | [dxa, dya,lnamea,when] = get_logistic(when); |
var trace16 = { | var trace16 = { | ||
x: dxa, | x: dxa, | ||
| Riga 812: | Riga 834: | ||
var layout = { | var layout = { | ||
| − | title: 'Andamento | + | title: 'Andamento Italia', |
height: 600, | height: 600, | ||
plot_bgcolor: "#000", | plot_bgcolor: "#000", | ||
| Riga 841: | Riga 863: | ||
displayModeBar: false | displayModeBar: false | ||
}; | }; | ||
| − | Plotly.newPlot(' | + | Plotly.newPlot('myDiv2', data, layout,options); |
}; | }; | ||
| Riga 854: | Riga 876: | ||
selector.appendChild(currentOption); | selector.appendChild(currentOption); | ||
} | } | ||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
} | } | ||
| − | + | function get_logistic(when){ | |
| − | |||
| − | |||
| − | |||
| − | |||
| − | function get_logistic( | ||
//document.write('./'+chosenCountry + '.csv'); | //document.write('./'+chosenCountry + '.csv'); | ||
// | // | ||
| Riga 877: | Riga 885: | ||
var x = []; | var x = []; | ||
var y = []; | var y = []; | ||
| − | var url = "https://raw.githubusercontent.com/vtandrea/labtest/master/"+'2020-03-'+when | + | var url = "https://raw.githubusercontent.com/vtandrea/labtest/master/"+'2020-03-'+when+"Italia.csv"; |
console.log(url); | console.log(url); | ||
var request = new XMLHttpRequest(); | var request = new XMLHttpRequest(); | ||