syntagmatic / parallel-coordinates

A d3-based parallel coordinates plot in canvas. This library is no longer actively developed.
http://syntagmatic.github.com/parallel-coordinates/
Other
511 stars 211 forks source link

'brushreset' event implementation #257

Open daniel-zillion opened 8 years ago

daniel-zillion commented 8 years ago

I found it quite advantageous to have an event fired when the brush strokes are reset by either pc.brushReset() or when a single click is detected in the chart area.

The implementation requires only three changes:

var events = d3.dispatch
    .apply(this,["render", "resize", "highlight", "brush", "brushend", "axesreorder","brushreset"]
    .concat(d3.keys(__))),
.
.
// Okay, somewhat unexpected, but not totally unsurprising, a mousclick is
// considered a drag without move. So we have to deal with that case
if (strum && strum.p1[0] === strum.p2[0] && strum.p1[1] === strum.p2[1]) {
    removeStrum(strums);
    events.brushreset.call(pc);
}
 function brushReset(dimension) {
    __.brushed = false;
    if (g) {
      g.selectAll('.brush')
        .each(function(d) {
          d3.select(this).call(
            brushes[d].clear()
          );
        });
      pc.render();
      events.brushreset.call(pc);
    }
    return this;
  };
jfourment commented 8 years ago

Hi, I agree something must be done about the brushReset events. I think a call to brushReset() should simply trigger a brush event as it is a brush event. So that any listener responsible for updating a datatable would automatically do its work on a reset.