Skip to content

Instantly share code, notes, and snippets.

@rowanv
Last active December 31, 2016 20:56
Show Gist options
  • Save rowanv/7a29a8b17c422077dd8a to your computer and use it in GitHub Desktop.
Save rowanv/7a29a8b17c422077dd8a to your computer and use it in GitHub Desktop.
Gist to accompany my "How to make Tufte's discrete sparklines using d3.js" at http://dataviztalk.blogspot.com
var boston_record = [
['home', 'win'],
...
['away', 'loss'],
];
d3.select('#second-wrapper-main')
.selectAll('div')
.data(boston_record)
.enter().append('div')
.attr('class', 'drawn-line')
.attr('data-binary-var', function (d) {
if (d[1] === 'win') {
return 1;
}
else {
return 0;
}
})
.style('left', function(d, i) { return i * 4 + 'px';});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment