I'm kind of new to D3.js. I'm reading Getting Started with D3 by Mike Dewar. I tried the very first example in the book, and it doesn't work. I've been tearing my hear out over this. What is wrong with my code here?
In the <head>
section:
<script src="http://mbostock.github.com/d3/d3.js"></script>
<script>
function draw(data) {
"use strict";
d3.select("body")
.append("ul")
.selectAll("li")
.data(data)
.enter()
.append("li")
.text(function (d) {
return d.name + ": " + d.status;
});
}
</script>
In the <body>
:
<script>
d3.json("flare.json", draw);
</script>
And the JSON file:
[
{
"status": ["GOOD SERVICE"],
"name": ["123"],
"url": [null],
"text": ["..."],
"plannedworkheadline": [null],
"Time": [" 7:35AM"],
"Date": ["12/15/2011"]
}
]
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…