Skip to content

Commit

Permalink
Merge pull request #1050 from deribaucourt/master
Browse files Browse the repository at this point in the history
Warn if points are out of range
  • Loading branch information
mirabilos authored Jan 11, 2025
2 parents cc74acf + e292736 commit f9ae77b
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/dygraph-layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,12 +248,14 @@ DygraphLayout.prototype._evaluateLineCharts = function() {
var axis = this.dygraph_.axisPropertiesForSeries(setName);
// TODO (konigsberg): use optionsForAxis instead.
var logscale = this.dygraph_.attributes_.getForSeries("logscale", setName);
var outOfXBounds = 0, outOfYBounds = 0;

for (var j = 0; j < points.length; j++) {
var point = points[j];

// Range from 0-1 where 0 represents left and 1 represents right.
point.x = DygraphLayout.calcXNormal_(point.xval, this._xAxis, isLogscaleForX);
outOfXBounds += (point.x < 0) || (point.x > 1);
// Range from 0-1 where 0 represents top and 1 represents bottom
var yval = point.yval;
if (isStacked) {
Expand All @@ -270,6 +272,14 @@ DygraphLayout.prototype._evaluateLineCharts = function() {
}
}
point.y = DygraphLayout.calcYNormal_(axis, yval, logscale);
outOfYBounds += (point.y < 0) || (point.y > 1);
}

if (outOfXBounds > 2) {
console.warn(outOfXBounds + ' points out of X bounds:' + this._xAxis.minval + ' - ' + this._xAxis.maxval);
}
if (outOfYBounds > 0) {
console.warn(outOfYBounds + ' points out of Y bounds:' + axis.minyval + ' - ' + axis.maxyval);
}

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

0 comments on commit f9ae77b

Please sign in to comment.