Built with blockbuilder.org
Last active
March 22, 2017 16:17
-
-
Save arthurwelle/487810b16e9c6470d732c303d26ccc83 to your computer and use it in GitHub Desktop.
TESTE MAPA Microregiões
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
license: mit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<head> | |
<meta charset="utf-8"> | |
<script src="https://d3js.org/d3.v4.min.js"></script> | |
<style> | |
body { margin:0;position:fixed;top:0;right:0;bottom:0;left:0; } | |
</style> | |
</head> | |
<body> | |
<script> | |
var width = 1500; //a largura máxima | |
var height = 1500; //a altura do SVG | |
d3.text("JogosDoSaoPaulo.csv", function(unparsedData){ //inicia os dados | |
var data = d3.csvParseRows(unparsedData); //pega todos as colunas | |
var numerodejogos = 40; | |
var Dia = []; | |
var Mandante = []; | |
var Placar = []; | |
var GolsPro = []; | |
var GolsContra = []; | |
var Adversario= []; | |
var Resultado = []; | |
var Ordem = []; | |
var Campeonato = []; | |
var OrdemEntreAnos = []; | |
var CX = []; | |
var CY = []; | |
var R = []; | |
for (i=0;i<numerodejogos;i++){ // dados em numeros (default javascript é texto) | |
Dia[i] = parseInt(data[i][0]); | |
GolsPro[i] = parseInt(data[i][3]); | |
GolsContra[i] = parseInt(data[i][4]); | |
Resultado[i] = data[i][7]; | |
Campeonato [i]= data[i][6]; | |
CX[i] = parseInt(data[i][8]); | |
CY[i] = parseInt(data[i][9]); | |
R[i] = parseInt(data[i][10]); | |
}; | |
ordena(); | |
function ordena (){ | |
var contador =0; | |
var contadorAnos =0; | |
for(i=0;i<numerodejogos;i++){ | |
if ((data[i+1][0])-(data[i][0])>3000) { | |
contador=0; | |
contadorAnos++; | |
Ordem [i]=contador; | |
OrdemEntreAnos[i]=contadorAnos; | |
}else{ | |
Ordem [i]=contador; | |
OrdemEntreAnos[i]=contadorAnos; | |
contador++; | |
}; | |
}; | |
}; | |
var color = d3.scaleLinear () | |
.domain([0,d3.max(GolsPro)]) | |
.range(["blue","red"]); | |
var canvas = d3.select("body") | |
.append("svg") | |
.attr("width", width) | |
.attr("height", height) | |
.append("g") | |
.attr("transform","translate(40,20)"); | |
var bars = canvas.selectAll("rect") | |
.data(GolsPro) | |
.enter() | |
.append("rect") | |
.attr("width",15) | |
.attr("height",15) | |
.attr("fill",function(d){return color(d);}) | |
.attr("x", function(d, i){return Ordem[i]*17;}) | |
.attr("y", function(d, i){return OrdemEntreAnos[i]*17;}); | |
var circulos = canvas.selectAll("circle") | |
.data(CX) | |
.enter() | |
.attr("r",20) | |
.attr("fill","green") | |
//.attr("cx", function(d){return (d);}) | |
.attr("cx", 82) | |
.attr("cy", 82) | |
.on("click",algoexorbitante); | |
function algoexorbitante(){ | |
canvas.selectAll("rect") | |
.data(Resultado) | |
.attr("fill",function(d){ | |
switch(d){ | |
case "D": return "red" | |
break; | |
case "E": return "yellow" | |
break; | |
case "V": return "blue" | |
break; | |
default : return "green"; | |
}; | |
}); | |
}; | |
}); | |
</script> | |
</body> |
We can make this file beautiful and searchable if this error is corrected: Any value after quoted field isn't allowed in line 1.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19300316,"M","0-0",0,0,"Ypiranga-SP","Paulista","E" , 188 , 449.472 , 39.356 | |
19300323,"NM","1-6",6,1,"Juventus-SP","Paulista","V" , 237 , 437.747 , 29.707 | |
19300330,"M","2-2",2,2,"Palestra Itália","Paulista","E" , 227 , 391.672 , 22.025 | |
19300406,"NM","1-1",1,1,"Portuguesa","Paulista","E" , 122 , 550.165 , 18.326 | |
19300413,"NM","1-3",3,1,"Guarani","Paulista","V" , 173 , 325.422 , 18.23 | |
19300420,"NM","1-6",6,1,"CE América","Paulista","V" , 149 , 474.388 , 17.986 | |
19300503,"NM","2-4",4,2,"Germânia","Paulista","V" , 319 , 284.446 , 16.892 | |
19300511,"NM","2-2",2,2,"Santos","Paulista","E" , 380 , 211.633 , 16.201 | |
19300517,"M","2-2",2,2,"Sírio","Paulista","E" , 324 , 142.06 , 16.067 | |
19300525,"NM","2-1",1,2,"Corinthians","Paulista","D" , 180 , 436.254 , 15.683 | |
19300601,"NM","0-3",3,0,"Atlético Santista","Paulista","V" , 152 , 340.244 , 14.185 | |
19300608,"M","2-1",2,1,"SC Internacional-SP","Paulista","V" , 183 , 445.509 , 12.857 | |
19300617,"NM","0-3",3,0,"AA São Bento","Paulista","V" , 24 , 130.93 , 11.923 | |
19300831,"M","5-0",5,0,"Ypiranga-SP","Paulista","V" , 282 , 401.123 , 11.853 | |
19300907,"M","3-0",3,0,"Atlético Santista","Paulista","V" , 167 , 99.445 , 11.781 | |
19300914,"M","5-1",5,1,"Sírio","Paulista","V" , 156 , 511.879 , 10.766 | |
19300921,"NM","2-2",2,2,"Palestra Itália","Paulista","E" , 176 , 444.943 , 10.247 | |
19300928,"M","1-1",1,1,"SC Internacional-SP","Paulista","E" , 200 , 440.657 , 10.196 | |
19301005,"M","4-0",4,0,"AA São Bento","Paulista","V" , 191 , 444.231 , 9.934 | |
19301012,"M","4-0",4,0,"Juventus-SP","Paulista","V" , 196 , 452.057 , 9.849 | |
19301123,"M","3-3",3,3,"Santos","Paulista","E" , 235 , 119.789 , 9.748 | |
19301130,"M","5-1",5,1,"Portuguesa","Paulista","V" , 385 , 194.55 , 9.585 | |
19301207,"M","1-1",1,1,"Corinthians","Paulista","E" , 380 , 174.59 , 9.501 | |
19301214,"M","5-1",5,1,"Guarani","Paulista","V" , 172 , 411.64 , 9.453 | |
19301221,"M","2-1",2,1,"Germânia","Paulista","V" , 153 , 490.387 , 9.213 | |
19301228,"M","2-1",2,1,"CE América","Paulista","V" , 119 , 534.251 , 8.86 | |
19310329,"NM","2-2",2,2,"Santos","Paulista","E" , 55 , 326.277 , 8.777 | |
19310412,"M","3-1",3,1,"SC Internacional-SP","Paulista","V" , 365 , 235.635 , 8.761 | |
19310501,"NM","3-2",2,3,"Palestra Itália","Paulista","D" , 259 , 159.88 , 8.747 | |
19310510,"M","2-2",2,2,"Guarani","Paulista","E" , 72 , 396.761 , 8.67 | |
19310516,"M","4-1",4,1,"Germânia","Paulista","V" , 149 , 499.399 , 8.615 | |
19310524,"NM","2-4",4,2,"AA São Bento","Paulista","V" , 195 , 447.782 , 8.296 | |
19310531,"M","3-1",3,1,"Juventus-SP","Paulista","V" , 342 , 256.569 , 8.233 | |
19310607,"M","2-0",2,0,"Ypiranga-SP","Paulista","V" , 160 , 373.779 , 8.192 | |
19310614,"M","3-3",3,3,"Atlético Santista","Paulista","E" , 183 , 441.156 , 8.031 | |
19310621,"M","8-1",8,1,"CE América","Paulista","V" , 182 , 451.301 , 7.837 | |
19310628,"M","2-2",2,2,"Corinthians","Paulista","E" , 148 , 400.955 , 7.759 | |
19310920,"M","5-1",5,1,"Sírio","Paulista","V" , 122 , 443.569 , 7.729 | |
19310927,"M","2-1",2,1,"Portuguesa","Paulista","V" , 156 , 499.55 , 7.24 | |
19311018,"M","6-0",6,0,"Ypiranga-SP","Paulista","V" , 24 , 229.255 , 7.088 | |
19311025,"M","4-2",4,2,"Santos","Paulista","V" , 112 , 443.864 , 7.056 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment