#Segment visualiser
Use this module to visualise data segments over a shared timeline.
The module relies on a timeline instance.
A woring demo for this module can be found here here
This library is under heavy development and subject to change.
Evert new API breaking change we will be adding snapshots to the repository so you can always fetch a working copy.
For an in depth explanation on the philosophy and usage of this library please refer to this blog post.
Will be passed to a timeLine later. In this case a Backbone collection.
var collection = new Backbone.Collection([{
"begin": "0",
"duration": "16121",
"end": "16121",
"color": "#A9d"
}, { "begin": "1" …},
}, { "begin": "3" …},
]);
If your data doesn't match the spected structure you can pass in a dataView that lets the visualizer how to access and manipulate the data.
// Sample dataView tells us how to access the data
var view = {
// tell d3 which is our key for sorting
sortIndex: function(d) {
return d.get('begin');
},
// how to retrieve or set the value used as the start of the segment
start: function(d, v) {
// no value, we retrieve
if(!v) return +d.get('begin');
// yesvalue we set :)
d.set('begin', v);
},
// how to retrieve or set the value used as the duration of the segment
duration: function(d, v) {
if(!v) return +d.get('duration');
d.set('duration', v);
},
// how to retrieve or set the value used for the color of the segment
color: function(d, v) {
if(!v) return d.get('color');
d.set('color', v);
}
};
var seg = segmentVis()
.data(collection.models)
.dataView(view)
.name('segments')
.opacity(0.5);
var graph = timeLine()
.width(800)
.height(150)
.xDomain([0, 100]);
// we add layers like this
graph.layer(seg);
// we pass in the drawing method from our timeline object
d3.select('.timeline').call(graph.draw);
This module is released under the BSD-3-Clause license.
This code is part of the WAVE project, funded by ANR (The French National Research Agency), ContInt program, 2012-2015.