diff --git a/README.md b/README.md index c6669c8..0c1221b 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ var x = d3.scaleLinear(); ## API Reference -* [Continuous](#continuous-scales) ([Linear](#linear-scales), [Power](#power-scales), [Log](#log-scales), [Identity](#identity-scales), [Time](#time-scales)) +* [Continuous](#continuous-scales) ([Linear](#linear-scales), [Power](#power-scales), [Log](#log-scales), [Identity](#identity-scales), [Time](#time-scales), [Radial](#radial-scales)) * [Sequential](#sequential-scales) * [Diverging](#diverging-scales) * [Quantize](#quantize-scales) @@ -51,7 +51,7 @@ var x = d3.scaleLinear(); ### Continuous Scales -Continuous scales map a continuous, quantitative input [domain](#continuous_domain) to a continuous output [range](#continuous_range). If the range is also numeric, the mapping may be [inverted](#continuous_invert). A continuous scale is not constructed directly; instead, try a [linear](#linear-scales), [power](#power-scales), [log](#log-scales), [identity](#identity-scales), [time](#time-scales) or [sequential color](#sequential-scales) scale. +Continuous scales map a continuous, quantitative input [domain](#continuous_domain) to a continuous output [range](#continuous_range). If the range is also numeric, the mapping may be [inverted](#continuous_invert). A continuous scale is not constructed directly; instead, try a [linear](#linear-scales), [power](#power-scales), [log](#log-scales), [identity](#identity-scales), [radial](#radial-scales), [time](#time-scales) or [sequential color](#sequential-scales) scale. # continuous(value) · [Source](https://github.com/d3/d3-scale/blob/master/src/continuous.js), [Examples](https://observablehq.com/@d3/continuous-scales) @@ -389,6 +389,14 @@ Identity scales are a special case of [linear scales](#linear-scales) where the Constructs a new identity scale with the specified [domain](#continuous_domain) and [range](#continuous_range). If *range* is not specified, it defaults to [0, 1]. +#### Radial Scales + +Radial scales are a variant of [linear scales](#linear-scales) where the range is internally squared, so that an input value corresponds linearly to the squared output value. These scales are useful when you want the input value to correspond to the area of a graphical mark, and the mark is specified by radius, as in a radial bar chart. Radial scales do not support [interpolate](#continuous_interpolate). + +# d3.scaleRadial([[domain, ]range]) · [Source](https://github.com/d3/d3-scale/blob/master/src/radial.js), [Examples](https://observablehq.com/@d3/radial-stacked-bar-chart) + +Constructs a new radial scale with the specified [domain](#continuous_domain) and [range](#continuous_range). If *domain* or *range* is not specified, each defaults to [0, 1]. + #### Time Scales Time scales are a variant of [linear scales](#linear-scales) that have a temporal domain: domain values are coerced to [dates](https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Date) rather than numbers, and [invert](#continuous_invert) likewise returns a date. Time scales implement [ticks](#time_ticks) based on [calendar intervals](https://github.com/d3/d3-time), taking the pain out of generating axes for temporal domains. diff --git a/src/radial.js b/src/radial.js index 6e7d23e..5c00cc6 100644 --- a/src/radial.js +++ b/src/radial.js @@ -34,6 +34,10 @@ export default function radial() { return arguments.length ? (squared.range((range = Array.from(_, number)).map(square)), scale) : range.slice(); }; + scale.rangeRound = function(_) { + return scale.range(_).round(true); + }; + scale.round = function(_) { return arguments.length ? (round = !!_, scale) : round; };