When I run d3.select(this).attr("transform")
on an element, I get a response translate(20.00,778)
. However I need to get individual values of translate.
In v3, one can use
var t = d3.transform(element.attr("transform"));
t.translate;
However d3.transform is not available in v4. How to achieve an equivalent result?
Try this.
string = element.attr("transform");
translate = string.substring(string.indexOf("(")+1, string.indexOf(")")).split(",");
Then you can access dx by translate[0] and dy by translate[1].
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With