I'm trying to load a csv file with x and y coordinates and create circles with that coordinates. I've understood how to load a csv file and i can log coordinates in the console but I don't understand why the log function return Not_a_number when i try to create circles. Is there a problem with mine data.map function? Thanks
Here the code:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<script type="text/javascript" src="d3/d3.v3.js"></script>
<style type="text/css">
/* No style rules here yet */
</style>
</head>
<body>
<script type="text/javascript">
//Width and height
var w = 900;
var h = 500;
var padding = 20;
var dataset = [];
d3.csv("dataset.csv", function(data) {
dataset = data.map(function(d,i) {
//THIS WORKS
console.log(d);
console.log(i);
return [ +d["x-coordinate"], +d["y-coordinate"]
]; });
//Create SVG element
var svg = d3.select("body")
.append("svg")
.attr("width", w)
.attr("height", h);
svg.selectAll("circle")
.data(dataset)
.enter()
.append("circle")
.attr("cx", function(d) {
//THIS DOESNT WORK
console.log(d);
return d[0];
})
.attr("cy", function(d) {
return d[1];
})
.attr("r", function(d) {
return d[1];
})
});
</script>
</body>
</html>