Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set the origin while drag in d3.js in v4 [duplicate]

I am facing a jump issue when I drag a <rect>.

In this question they suggest to use drag.origin() but D3 v4 version doesn't have this method anymore.

Can some body suggest how to solve the jump issue?

like image 754
chiranjeevigk Avatar asked Jul 29 '16 04:07

chiranjeevigk


1 Answers

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

like image 74
Cyril Cherian Avatar answered Oct 29 '22 10:10

Cyril Cherian