Skip to content Skip to sidebar Skip to footer

How To Set The Origin While Drag In D3.js In V4

I am facing a jump issue when I drag a . In this question they suggest to use drag.origin() but D3 v4 version doesn't have this method anymore. Can some body suggest ho

Solution 1:

Instead of origin use subject.

So this

 .origin(function() { 
        var t = d3.select(this);
        return {x: t.attr("x"), y: t.attr("y")};
    })

will become

 .subject(function() { 
        var t = d3.select(this);
        return {x: t.attr("x"), y: t.attr("y")};
    })

Working fiddle using d3 v4 is here

API reference here


Post a Comment for "How To Set The Origin While Drag In D3.js In V4"