Skip to content

Instantly share code, notes, and snippets.

@poezn
Created October 9, 2013 00:27
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 poezn/6894169 to your computer and use it in GitHub Desktop.
Save poezn/6894169 to your computer and use it in GitHub Desktop.
Y-over-Y Improvements
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
{"description":"Y-over-Y Improvements","endpoint":"","display":"svg","public":true,"require":[],"fileconfigs":{"inlet.js":{"default":true,"vim":false,"emacs":false,"fontSize":12},"assets.svg":{"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},"styles.css":{"default":true,"vim":false,"emacs":false,"fontSize":12}},"fullscreen":false,"play":false,"loop":false,"restart":false,"autoinit":true,"pause":true,"loop_type":"pingpong","bv":false,"nclones":15,"clone_opacity":0.4,"duration":3000,"ease":"linear","dt":0.01,"thumbnail":"http://i.imgur.com/GtBcmLe.png"}
var data = {
"domain-mastery": {
"before": 65,
"after": 82
}
};
var units = d3.range(0, 100);
var countPeople = g.selectAll("use.count-people")
.data(units);
var newUnits = countPeople.enter().append("use")
.attr({
"opacity": 1
});
countPeople.exit().remove();
countPeople.attr({
"class": function(d, i) {
var cls = i >= data["domain-mastery"].before ?
(i >= data["domain-mastery"].after ? "no" : "new") :
"yes"
return "count-people " + cls;
},
"transform": function(d, i) {
var tx = (i % 20) * 37,
ty = Math.floor(i / 20) * 74;
return "translate(" + [tx, ty] + ")"
},
"xlink:href": "#man"
});
.yes {
fill: #8CA587;
}
.no {
fill: #DFDFDF;
stroke: #198B1E;
}
.new {
fill: #198B1E;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment