How to control scaling speed in D3 V4?

I am currently researching Mike Bostock's scaling feature from this bl.ocks: https://bl.ocks.org/mbostock/431a331294d2b5ddd33f947cf4c81319 and I realized that the speed of the intro can be increased from this line:

.duration(1500)

      

Is there such a way to control scrolling scaling?

+3


source to share


1 answer


You can do this using the wheelDelta

Make Wheel Delta Function

function myDelta() {
  return -d3.event.deltaY * (d3.event.deltaMode ? 120 : 1) / 1500;
}

      

You can increase the constant 1500 to whatever number you choose to adjust the delta.

Now, when scaling, define wheelDelta like this:



var zoom = d3.zoom()
    .scaleExtent([1, 32])
    .translateExtent([[0, 0], [width, height]])
    .extent([[0, 0], [width, height]])
    .wheelDelta(myDelta)//your function
    .on("zoom", zoomed);

      

Link here

Working code here

+2


source







All Articles