You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
};
};
Your code is unnecessarily complicated because you are copying the value of the transform attribute from one G element (this) to an off-screen G element created by document.createElementNS. Inlining your code a little bit:
You’ve already posted this to Stack Overflow, but as a reminder: please use Stack Overflow tag d3.js to ask for help. Although I make an effort to assist everyone that asks, I am not always available to provide help promptly or directly. Stack Overflow provides a better collaborative forum for self-help: tens of thousands of D3-related questions have already been asked there, and some answered questions may be relevant to you.
When asking for help, please include a link to a live example that demonstrates the issue, preferably on bl.ocks.org. It is often impossible to debug from code snippets alone. Isolate the issue and reduce your code as much as possible before asking for help. The less code you post, the easier it is for someone to debug, and the more likely you are to get a helpful response.
If you have a question about D3’s behavior and want to discuss it with other users, also consider the d3-js Google Group or joining the d3-js Slack.
In d3 4.9.1 if I make call to get transform of element that has style like this:
Operation:
Output in d3v4.9.1 :
But in d3v4.8.0 it has different output:
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:
Ref: https://stackoverflow.com/questions/38224875/replacing-d3-transform-in-d3-v4
The text was updated successfully, but these errors were encountered: