I'm trying to extract value from this json file , so far I can see my object in console , but how can I extract the target value to be use in d3
d3.json "https://api.github.com/repos/wesm/D3py/commits", (data) ->
console.log data[0]
return
Here's the json https://api.github.com/repos/wesm/D3py/commits
ultimately I want to be able to use it to create svg circle using these element , so I am planning on put the value into the simple list like this ...
svg_w = 800
svg_h = 400
padding = 50
svg = d3.select("body").append("svg").attr("width", svg_w).attr("height", svg_h)
list = [
{ "item": 1, "date": "2012-01-04T01:39:42Z", "commit_name": "Mike Dewar", "id":1, "message" : "clenaed up typos in README" },
{ "item": 2, "date": "2012-01-04T01:37:33Z", "commit_name": "Mike Dewar", "id":2, "message" : "updated the README to point people at the v2 branch" },
{ "item": 3, "date": "2011-12-16T03:09:41Z", "commit_name": "Mike Dewar", "id":2, "message" : "added ignore file" },
{ "item": 4, "date": "2011-10-06T12:05:53Z", "commit_name": "Mike Dewar", "id":2, "message" : "merging" },
{ "item": 5, "date": "2011-08-16T20:48:02Z", "commit_name": "Mike Dewar", "id":3, "message" : "added time series" }]
names = (m.item for m in list)
console.log names
nodes = svg.append("g").attr("class", "nodes").selectAll("circle")
.data(names).enter().append("g")
.attr("transform", (d, i) ->
dx = i * 70 + padding
dy = svg_h / 2
"translate(" + dx + "," + dy + ")"
)
nodes.append("circle").attr("class", "node").attr "r", 20
nodes.append("text").attr("text-anchor", "middle").text (d) ->d.name