Skip to content

Commit ddf0f70

Browse files
committed
implicit zero
1 parent 90a5689 commit ddf0f70

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/scales/quantitative.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,14 @@ export function createScaleQ(
115115
scale.interpolate(interpolate);
116116
}
117117

118+
// If the zero option is not specified, then implicitly extend the domain to
119+
// include zero if the minimum is less than 7% of the spread (and similarly
120+
// for negative domains).
121+
if (zero === undefined && type === "linear") {
122+
const [min, max] = extent(domain);
123+
zero = min > 0 ? min < 0.07 * (max - min) : max < 0 ? max > 0.07 * (min - max) : false;
124+
}
125+
118126
// If a zero option is specified, we assume that the domain is numeric, and we
119127
// want to ensure that the domain crosses zero. However, note that the domain
120128
// may be reversed (descending) so we shouldn’t assume that the first value is

0 commit comments

Comments
 (0)