I'm fairly new to both Javascript and D3, and I've been trying to try the examples from the website myself.
I used the following for the JS/HTML code:
<!DOCTYPE html>
<html>
<head>
<script src="http://d3js.org/d3.v3.min.js"></script>
<style type="text/css">
</style>
<head>
<body>
<script>
d3.json("mydata.json", function (data) {
var canvas = d3.select("body").append("svg")
.attr("width", 500)
.attr("height", 500)
canvas.selectAll("rect")
.data(data)
.enter()
.append("rect")
.attr("width", function (d) { return d.age * 10; })
.attr("y", function (d, i) { return i * 50; })
.attr("fill", "blue")
})
</script>
</body>
</html>
and for my "mydata.json" I am using:
[
{"name": "Maria", "age": 30},
{"name": "Fred", "age": 50},
{"name": "Jason", "age": 12}
]
Every-time I try and run it, it doesn't have the same result as the examples on the d3 examples page. Please help, I am try to figure out how d3 works, and I am quite a novice programmer.