bug scaling graphs

75 views
Skip to first unread message

Cyril

unread,
Jun 11, 2020, 12:02:38 PM6/11/20
to Smoothie Charts
Hello guys,

I encountered a problem concerning negatives values for my smooties charts graphs :

every time I did a resetBounds the graph was reseting completely..

so i changed the resetBounds like this and it works pretty well :

  TimeSeries.prototype.resetBounds = function() {
    if (this.data.length) {
      // Walk through all data points, finding the min/max value
      // this.maxValue = this.data[0][1];
      // this.minValue = this.data[0][1];
  var tempMaxValue = this.data[0][1];
  var tempMinValue = this.data[0][1];
      for (var i = 1; i < this.data.length; i++) {
        for (var j = 1; j < this.data[i].length; j++) {
var value = parseInt(this.data[i][j]);
if (value > tempMaxValue) {
  tempMaxValue = parseInt(value);
}
if (value < tempMinValue) {
  tempMinValue = parseInt(value);
}
        }
  }
  if (tempMaxValue<tempMinValue) {
  this.maxValue = parseInt(tempMinValue);
  this.minValue = parseInt(tempMaxValue);   
  } else {
  this.maxValue = parseInt(tempMaxValue);
  this.minValue = parseInt(tempMinValue);
  }
    } else {
      // No data exists, so set min/max to NaN
      this.maxValue = Number.NaN;
      this.minValue = Number.NaN;
    }
  };


Reply all
Reply to author
Forward
0 new messages