Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions src/scales/quantitative.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ export function ScaleQ(key, scale, channels, {
clamp,
domain = (registry.get(key) === radius ? inferRadialDomain : inferDomain)(channels),
round,
range = registry.get(key) === radius ? [0, 3] : undefined, // see inferRadialDomain
range = registry.get(key) === radius ? inferRadialRange(channels, domain) : undefined,
scheme,
type,
interpolate = registry.get(key) === color ? (range !== undefined ? interpolateRgb : scheme !== undefined ? Scheme(scheme) : type === "cyclical" ? interpolateRainbow : interpolateTurbo) : round ? interpolateRound : undefined,
Expand Down Expand Up @@ -219,11 +219,13 @@ function inferDomain(channels) {
];
}

function inferRadialDomain(channels) {
return [0, max(channels, ({value}) => value === undefined ? value : max(value))];
}

// We don’t want the upper bound of the radial domain to be zero, as this would
// be degenerate, so we ignore nonpositive values.
function inferRadialDomain(channels) {
return [
0,
quantile(channels, 0.5, ({value}) => value === undefined ? NaN : quantile(value, 0.25, positive))
];
function inferRadialRange(channels, domain) {
const h25 = quantile(channels, 0.5, ({value}) => value === undefined ? NaN : quantile(value, 0.25, positive));
return domain.map(d => 3 * Math.sqrt(d / h25));
}
Loading