Built with blockbuilder.org
This visualization we are trying to show avg temprature for 5 cities in the world
xxxxxxxxxx
<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; }
svg { width: 100%; height: 100%;}
</style>
</head>
<body>
<svg />
<script>
var margin = {top:20, bottom:20, left:20, right:20};
d3.csv("cities.csv",(error, data) => {
if (error) {
console.log("Error: ", error)
} else {
dataViz(data)
}
});
function dataViz(incomingData) {
var maxPopulation = d3.max(incomingData, d => parseInt(d.population))
var yScale = d3.scaleLinear().domain([0,maxPopulation]).range([margin.bottom,460 - margin.top]);
d3.select("svg").attr("style","height: 480px; width: 600px;");
d3.select("svg")
.selectAll("rect")
.data(incomingData)
.enter()
.append("rect")
.attr("width", 50)
.attr("height", d => yScale(parseInt(d.population)))
.attr("x", (d,i) => margin.left + i * 55)
.attr("y", d => 480 - margin.top - yScale(parseInt(d.population)))
.style("fill", "#6E9922")
.style("stroke", "#9A8B7A")
.style("stroke-width", "1px");
};
</script>
</body>
https://d3js.org/d3.v4.min.js