Skip to content

Instantly share code, notes, and snippets.

@Dudemullet
Last active August 29, 2015 14:23
Show Gist options
  • Save Dudemullet/88fc04352f3f8aad30db to your computer and use it in GitHub Desktop.
Save Dudemullet/88fc04352f3f8aad30db to your computer and use it in GitHub Desktop.
Sensores Pluviales en Cuenca de Mexico
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>test</title>
<!-- CSS -->
<style type="text/css">
.municipio {
fill: white;
stroke: #ddd;
}
.municipio:hover {
stroke: #999;
stroke-width: 2px;
}
.color1 { fill:rgb(247,251,255); }
.color2 { fill:rgb(222,235,247); }
.color3 { fill:rgb(198,219,239); }
.color4 { fill:rgb(158,202,225); }
.color5 { fill:rgb(107,174,214); }
.color6 { fill:rgb(66,146,198); }
.color7 { fill:rgb(33,113,181); }
.color8 { fill:rgb(8,81,156); }
.color9 { fill:rgb(8,48,107); }
.estaciones-pluviales {
fill: rgba(0,100,0,0.3);
}
</style>
</head>
<body>
<!-- HTML -->
<div class="container">
</div>
<!-- Js -->
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/topojson/1.6.19/topojson.min.js"></script>
<script type="text/javascript">
var width = 800,
height = 600;
var svg = d3.select('.container').append("svg")
.attr("width", width)
.attr("height", height);
d3.json("./data.json", function(err, res){
var dataset = res;
var subunits = topojson.feature(dataset, dataset.objects.EdosCVM);
var stations = topojson.feature(dataset, dataset.objects.PluvimentrosCVM);
var projection = d3.geo.albers()
.center([-2.6, 19.6])
.parallels([10.5, 29.5])
.scale(25000)
.translate([width/2, height/2]);
var path = d3.geo.path()
.projection(projection);
var randomWaterLevel = function () {
var waterLevel = Math.floor(Math.random() *8);
this.dataset.waterLevel = waterLevel;
return "municipio " + "color" + waterLevel;
};
// var simulatLevelIncrease
svg.selectAll('path')
.data(subunits.features)
.enter()
.append('path')
.attr("d", path)
.attr("class", "municipio")
.attr('attr', function () {
return 'll';
});
svg.append('g')
.attr('class', 'estaciones-pluviales')
.selectAll('path')
.data(stations.features)
.enter()
.append('path')
.attr('d', path)
.attr("class", 'estacion');
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment