Skip to content

Commit

Permalink
Warn if points are out of range
Browse files Browse the repository at this point in the history
Some users may improperly define the range of their axes, leading to
points being drawn outside of the chart area. In the worst cases, if
all points are out of range, the chart will not be drawn at all.

Adding a warning can help users identify this issue and correct it.

Note that may spew a lot of warnings if their are a lot of points.
  • Loading branch information
deribaucourt committed Oct 22, 2024
1 parent ea40d17 commit af3fd03
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/dygraph-layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,9 @@ DygraphLayout.prototype._evaluateLineCharts = function() {

// Range from 0-1 where 0 represents left and 1 represents right.
point.x = DygraphLayout.calcXNormal_(point.xval, this._xAxis, isLogscaleForX);
if (point.x < 0 || point.x > 1) {
console.warn('x value ' + point.xval + ' out of range ' + this._xAxis.minval + ' - ' + this._xAxis.maxval);
}
// Range from 0-1 where 0 represents top and 1 represents bottom
var yval = point.yval;
if (isStacked) {
Expand All @@ -269,6 +272,9 @@ DygraphLayout.prototype._evaluateLineCharts = function() {
}
}
point.y = DygraphLayout.calcYNormal_(axis, yval, logscale);
if (point.y < 0 || point.y > 1) {
console.warn('y value ' + point.yval + ' out of range ' + axis.minyval + ' - ' + axis.maxyval);
}
}

this.dygraph_.dataHandler_.onLineEvaluated(points, axis, logscale);
Expand Down

0 comments on commit af3fd03

Please sign in to comment.