trinary / d3-transform

add an interface for svg transform attributes in d3.js
MIT License
160 stars 17 forks source link

transform parameters from an object #11

Closed rogerz closed 9 years ago

rogerz commented 9 years ago

See tests for details

trinary commented 9 years ago

Thanks for the patch! I'm hesitant to add this capability due to the order-dependent and repeatable nature of transforms. Affine transformations are not commutative. for (var x in y) has no guarantee of order in JS and a JS implementation/cross browser behavior change could break people's code if objects are used this way. Additionally, this interface does not allow for multiples of the same kind of transform (e.g. "translate() rotate() translate()"). I understand that "insertion order for everything except integer indexes" is the de facto standard right now but it's not something I want to rely on.

rogerz commented 9 years ago

Good point. The origin of this patch was to generate transform parameters from an layout algorithm and use it later.

It seems a better solution should be save directly the transform string instead of an object.