- 
                Notifications
    You must be signed in to change notification settings 
- Fork 291
Closed
Description
In d3 4.9.1 if I make call to get transform of element that has style like this:
<g style="transform: translateX(3.84559px);"></g>
Operation:
d3.select(this).style("transform")
Output in d3v4.9.1 :
translateX(3.84559px)
But in d3v4.8.0 it has different output:
matrix(1, 0, 0, 1, 3.84559, 0)
Is there any change in this new version that is causing this issue?
I was having function to find different parameters of transform property, which is now broken:
contents.getTransformation = function (transform) {
    // console.log(transform);
    var g = document.createElementNS("http://www.w3.org/2000/svg", "g");
    g.setAttributeNS(null, "transform", transform);
    var matrix = g.transform.baseVal.consolidate().matrix;
    var a = matrix.a;
    var b = matrix.b;
    var c = matrix.c;
    var d = matrix.d;
    var e = matrix.e;
    var f = matrix.f;
    var scaleX = Math.sqrt(a * a + b * b);
    var scaleY = Math.sqrt(c * c + d * d);
    var skewX = a * c + b * d;
    if (scaleX) {
        a /= scaleX;
        b /= scaleX;
    }
    if (skewX) {
        c -= a * skewX;
        d -= b * skewX;
    }
    if (scaleY) {
        c /= scaleY;
        d /= scaleY;
        skewX /= scaleY;
    }
    if (a * d < b * c) {
        a = -a;
        b = -b;
        skewX = -skewX;
        scaleX = -scaleX;
    }
    return {
        translateX: e,
        translateY: f,
        rotate: Math.atan2(b, a) * Math.PI / 180,
        skewX: Math.atan(skewX) * Math.PI / 180,
        scaleX: scaleX,
        scaleY: scaleY
    };
};
Ref: https://stackoverflow.com/questions/38224875/replacing-d3-transform-in-d3-v4
Metadata
Metadata
Assignees
Labels
No labels