Skip to content
mbostock edited this page Feb 23, 2012 · 12 revisions

API ReferenceCore

Psuedorandom Number Generation

# d3.random.normal([mean, [deviation]])

Returns a function for generating random numbers with a normal (Gaussian) distribution. The expected value of the generated psuedorandom numbers is mean, with the given standard deviation. If deviation is not specified, it defaults to 1.0; if mean is not specified, it defaults to 0.0.

2D Transforms

# d3.transform(string)

Parses the given 2D affine transform string, as defined by SVG's transform attribute. The transform is then decomposed to a standard representation of translate, rotate, x-skew and scale. This behavior is standarded by CSS: see matrix decomposition for animation.

# transform.rotate

Returns the rotation angle θ of this transform, in degrees.

# transform.translate

Returns the [dx, dy] translation of this transform, as a two-element array in local coordinates (typically pixels).

# transform.skew

Returns the x-skew φ of this transform.

# transform.scale

Returns the [kx, ky] scale of this transform, as a two-element array.

# transform.toString

Returns a string representation of this transform, in the form "translate(dx,dy)rotate(θ)skewX(φ)scale(kx,ky)".

Clone this wiki locally