Skip to content
Merged
Changes from 1 commit
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: 10 additions & 4 deletions src/dygraph.js
Original file line number Diff line number Diff line change
Expand Up @@ -2533,16 +2533,22 @@ Dygraph.prototype.computeYAxisRanges_ = function(extremes) {
if (!ypadCompat) {
// When using yRangePad, adjust the upper/lower bounds to add
// padding unless the user has zoomed/panned the Y axis range.

y0 = axis.computedValueRange[0];
y1 = axis.computedValueRange[1];

// special case #781: if we have no sense of scale, center on the sole value.
if (y0 === y1) {
y0 -= 0.5;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For a log scale, this could drop y below zero, which will produce NaNs. In the logscale branch of the conditional on line 2546, you can halve y0 and double y1 instead.

y1 += 0.5;
}

if (logscale) {
y0 = axis.computedValueRange[0];
y1 = axis.computedValueRange[1];
var y0pct = ypad / (2 * ypad - 1);
var y1pct = (ypad - 1) / (2 * ypad - 1);
axis.computedValueRange[0] = utils.logRangeFraction(y0, y1, y0pct);
axis.computedValueRange[1] = utils.logRangeFraction(y0, y1, y1pct);
} else {
y0 = axis.computedValueRange[0];
y1 = axis.computedValueRange[1];
span = y1 - y0;
axis.computedValueRange[0] = y0 - span * ypad;
axis.computedValueRange[1] = y1 + span * ypad;
Expand Down