Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script>
- var width = 1000;
- var height = 600;
- var d = [];
- var projection = d3.geo.mercator()
- .translate([width/2, height/2])
- .scale([500]);
- var path = d3.geo.path().projection(projection);
- var color = d3.scale.ordinal().range(colorbrewer.YlGn[9]);
- var svg = d3.select("#viz").append("svg")
- .attr("width",width)
- .attr("height",height);
- d3.json('scm-timezone.json', function(data){
- var com = data.commits;
- d.push(com);
- color.domain([
- d3.min(d[0]),
- d3.max(d[0])
- ]);
- d3.json("world.json", function(json){
- for(var i = 0;i < data.tz.length;i++){
- var dataTZ = data.tz[i];
- var commitValue = parseInt(data.commits[i]);
- for(var j = 0;j<json.features.length;j++){
- var jsonTZ = json.features[j].properties.description;
- if(dataTZ == jsonTZ) {
- json.features[j].properties.value = commitValue;
- }
- }
- }
- svg.selectAll("path")
- .data(json.features)
- .enter()
- .insert("path")
- .attr("d",path)
- .style("fill", function(d) {
- var val = d.properties.value;
- if(val){ return color(val); }
- else { return "white"; }
- });
- });
- });
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement