Skip to content

Instantly share code, notes, and snippets.

@sosukeinu
Forked from rowanv/blog_sparkline.js
Created January 16, 2016 14:27
Show Gist options
  • Save sosukeinu/c9f9393fd001a5bc7081 to your computer and use it in GitHub Desktop.
Save sosukeinu/c9f9393fd001a5bc7081 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