Open connorgr opened 9 years ago
Here's an idea using d3.dispatch() – https://github.com/mbostock/d3/wiki/Internals#d3_dispatch
To create a dispatcher in d3 you need to create a dispatch variable like:
var dispatch = d3.dispatch("start", "end");
Then you can do things like the following:
dispatch.on("start", listener);
dispatch.start();
Why don't we have a new module called gd3.linker
where the object is really just a dispatch call marked with certain predefined actions that GD3 supports (e.g., tooltip activation or data filtering). Then we could link visualizations like:
var linker = gd3.link(),
mutmtx = gd3.mutmtx().link(linker),
heatmap = gd3.heatmap().link(linker);
mutmtxCell.on('mouseover', function() { if(link) link.brush( d3.select(this).data() ); });
link.on('brush', function() {
// do something to mutation matrix cells
});
By making link a d3 module a user can create multiple sets of linked items, and even add/remove to dispatch sets, which would be super useful in complex environments. Thoughts, @mdml?
Support library-level event listeners like
mutmtx.on('change', function() { ... } );
to enable things like brushing an linking.