Skip to content

Commit b8e2a42

Browse files
authored
inferRadialRange (#235)
1 parent dee5b37 commit b8e2a42

File tree

5 files changed

+1123
-1120
lines changed

5 files changed

+1123
-1120
lines changed

src/scales/quantitative.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ export function ScaleQ(key, scale, channels, {
137137
clamp,
138138
domain = (registry.get(key) === radius ? inferRadialDomain : inferDomain)(channels),
139139
round,
140-
range = registry.get(key) === radius ? [0, 3] : undefined, // see inferRadialDomain
140+
range = registry.get(key) === radius ? inferRadialRange(channels, domain) : undefined,
141141
scheme,
142142
type,
143143
interpolate = registry.get(key) === color ? (range !== undefined ? interpolateRgb : scheme !== undefined ? Scheme(scheme) : type === "cyclical" ? interpolateRainbow : interpolateTurbo) : round ? interpolateRound : undefined,
@@ -219,11 +219,13 @@ function inferDomain(channels) {
219219
];
220220
}
221221

222+
function inferRadialDomain(channels) {
223+
return [0, max(channels, ({value}) => value === undefined ? value : max(value))];
224+
}
225+
222226
// We don’t want the upper bound of the radial domain to be zero, as this would
223227
// be degenerate, so we ignore nonpositive values.
224-
function inferRadialDomain(channels) {
225-
return [
226-
0,
227-
quantile(channels, 0.5, ({value}) => value === undefined ? NaN : quantile(value, 0.25, positive))
228-
];
228+
function inferRadialRange(channels, domain) {
229+
const h25 = quantile(channels, 0.5, ({value}) => value === undefined ? NaN : quantile(value, 0.25, positive));
230+
return domain.map(d => 3 * Math.sqrt(d / h25));
229231
}

0 commit comments

Comments
 (0)