Skip to content

Instantly share code, notes, and snippets.

@rickdg
Created October 30, 2014 11:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rickdg/4eb7890692c4ddc0d051 to your computer and use it in GitHub Desktop.
Save rickdg/4eb7890692c4ddc0d051 to your computer and use it in GitHub Desktop.
Tributary Users
{"description":"Tributary Users","endpoint":"","display":"html","public":true,"require":[],"fileconfigs":{"inlet.js":{"default":true,"vim":false,"emacs":false,"fontSize":12},"style.css":{"default":true,"vim":false,"emacs":false,"fontSize":12},"_.md":{"default":true,"vim":false,"emacs":false,"fontSize":12},"config.json":{"default":true,"vim":false,"emacs":false,"fontSize":12}},"tab":"edit","display_percent":0.7,"play":false,"loop":false,"restart":false,"autoinit":true,"pause":true,"loop_type":"period","bv":false,"nclones":15,"clone_opacity":0.4,"duration":3000,"ease":"linear","dt":0.01,"hidepanel":false,"fullscreen":false,"ajax-caching":true}
var display = d3.select("#display")
.style("overflow", "scroll");
var url = 'http://tributary.io/api/users';
display.append("input")
.attr({
id: "fetch",
type: "button",
value: "fetch"
})
.on("click", function() {
d3.json(url, function(err, res) {
tributary.data = res;
render();
})
})
function render() {
if(!tributary.data) return;
console.log(tributary.data)
var users = display.selectAll("div.user")
.data(tributary.data)
.enter()
.append("div")
.classed("user", true);
users.append("img")
.attr({
src: function(d) { return d.avatar_url },
width: 72,
height: 72
})
users.append("br")
users.append("span")
.classed("login", true)
.text(function(d) { return d.login });
users.append("br")
users.append("span")
.classed("name", true)
.text(function(d) { return d.name });
users.append("br")
users.append("span")
.text(function(d) { return "inlets: " + (d.inlets || 0) });
};
render();
if(!tributary.data || !tributary.data.length) {
d3.json(url, function(err, res) {
tributary.data = res;
render();
})
}
#fetch {
position:relative;
margin-top: 20px;
right: 40px;
font-size:29px;
float:right;
}
.user {
float:left;
margin-left: 10px;
margin-top: 20px;
height: 120px;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment