d3.js

Disable d3 brush resize


Is it possible to have a brush that is a static width ie a brush that is not resizable? It would still need to be draggable. There doesn't seem to be anything indicating whether it's possible in the documentation.


Solution

  • There's no explicit option for that, but all you need to do is reset the domain in the brush event handler, for example

    var brush = d3.svg.brush().on("brush", brushed);
    
    function brushed() {
      brush.extent(desiredDomain);
    }