Skip to content

Instantly share code, notes, and snippets.

@radiodario
Last active August 29, 2015 14:02
Show Gist options
  • Save radiodario/5574a6642f424a6da9fc to your computer and use it in GitHub Desktop.
Save radiodario/5574a6642f424a6da9fc to your computer and use it in GitHub Desktop.
wtfd3.js
var data = [
[
{
time: new Date(2000, 1, 1),
value: 10
},
{
time: new Date(2000, 1, 2),
value: 20
},
{
time: new Date(2000, 1, 3),
value: 30
},
{
time: new Date(2000, 1, 4),
value: 40
}
], [
{
time: new Date(2010, 1, 1),
value: 10
},
{
time: new Date(2010, 1, 2),
value: 20
},
{
time: new Date(2010, 1, 3),
value: 30
},
{
time: new Date(2010, 1, 4),
value: 40
}
]
];
var paths = this.selection.data(data);
paths.enter()
.append('g')
.attr("class", "series")
.append('path')
.attr("class", "line");
paths.selectAll('path.line')
.attr("d", function(d, i) {
console.log(JSON.stringify(d), i)
// lines is an array of line generators with different
// scales (i.e. drawing two time series with different x scales
// on top of each other)
return lines[i](d);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment