Skip to content

Commit f60e7f3

Browse files
mbostockFil
andauthored
fix zero for negative domains (#934)
* fix zero for negative domains * test negative domain with the zero option * Update test/plots/travelers-covid-drop.js Co-authored-by: Mike Bostock <[email protected]> * order options Co-authored-by: Philippe Rivière <[email protected]>
1 parent 3832868 commit f60e7f3

File tree

4 files changed

+118
-2
lines changed

4 files changed

+118
-2
lines changed

src/scales/quantitative.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,8 @@ export function ScaleQ(key, scale, channels, {
9898
const [min, max] = extent(domain);
9999
if ((min > 0) || (max < 0)) {
100100
domain = slice(domain);
101-
if (order(domain) < 0) domain[domain.length - 1] = 0;
102-
else domain[0] = 0;
101+
if (order(domain) !== Math.sign(min)) domain[domain.length - 1] = 0; // [2, 1] or [-2, -1]
102+
else domain[0] = 0; // [1, 2] or [-1, -2]
103103
}
104104
}
105105

0 commit comments

Comments
 (0)