-
Notifications
You must be signed in to change notification settings - Fork 0
Ordinal Scales
Scales are functions that map from an input domain to an output range. Ordinal scales have a discrete domain, such as a set of names or categories. There are also quantitative scales, which have a continuous domain, such the set of real numbers. Scales are an optional feature in D3; you don't have to use them, if you prefer to do the math yourself. However, using scales can greatly simplify the code needed to map a dimension of data to a visual representation.
A scale object, such as that returned by d3.scale.ordinal, is both an object and a function. That is: you can call the scale like any other function, and the scale has additional methods that change its behavior. Like other classes in D3, scales follow the method chaining pattern where setter methods return the scale itself, allowing multiple setters to be invoked in a concise statement.
# d3.scale.ordinal()
…
# ordinal.domain(values)
…
# ordinal.range(values)
…
# ordinal.rangePoints(values[, padding])
…
# ordinal.rangeBands(values[, padding])
…
# ordinal.rangeRoundBands(values[, padding])
…
# ordinal.rangeBand()
…