Update the y-axis of a brushed area chart

后端 未结 2 512
既然无缘
既然无缘 2021-02-05 09:35

I am using d3.js, and I\'m working on a brushed area chart by modifying this example. In addition to the x-axis changing based on the brush, I\'d like chart\'s y-axis to be redr

2条回答
  •  迷失自我
    2021-02-05 10:36

    A shorter possibility would be to use d3.scale.invert() on your brush.extent() like so:

    var domainExtent = brush.extent().map(function(d){return scale.invert(d);});
    var filteredData = data.filter(function(d){return ((d <= domainExtent[1]) && (d >= domainExtent[0]));});
    

    However, by now d3 has gained d3.brushX(), which only allows brushing in East/West direction by design.

提交回复
热议问题