how to know the current Zoom level in D3.js

后端 未结 3 1054
独厮守ぢ
独厮守ぢ 2021-01-04 07:40

I have a problem since a few days. I have a graph and when I use Zoom Behavior it works, but I need to know when I reach maximum zoom to load new given

// Sp         


        
3条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-04 08:07

    In the draw function the current event will have the zoom level (d3.event.scale as you mentioned). Also if you keep the behaviour around like:

    var zm = d3.behavior.zoom().x(x).scaleExtent([1,10]).on("zoom", draw);
    

    Then you can find the current zoom level by calling:

    zm.scale();
    

提交回复
热议问题