Skip to content

Instantly share code, notes, and snippets.

@moricard
Created February 9, 2013 14:33
Show Gist options
  • Save moricard/4745465 to your computer and use it in GitHub Desktop.
Save moricard/4745465 to your computer and use it in GitHub Desktop.
different vishna load function
var news;
function load () {
d3.json("#path/feed.json", function(data){
//Everything here will be executed once the data has arrived.
news = data;
news.map( function(newsItem) {
//do the treatment for each newsItem here.
//For example, transforming the Timestamp string to an actual javascript Date object:
newsItem.timestamp = new Date(newsItem.Timestamp);
return newsItem;
});
//initialize the scales you want to use.
//Call everything that needs to be done at initialization of the data...
});
}
// ...
function launch() {
force.nodes( news );
}
function addText () {
//...
var text = d3.selectAll("text");
text
.data(news)
.append("svg:text")
.attr("x", 8)
.attr("y", ".31em")
.text(function(d) { return d.keyword; });
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment