Correct a JavaScript exception for empty distributions

If you create a distribution but don't write to it, the mean of the
distribution is NaN - which Aeson encodes as `null`. Thus we have to
make sure that when working with the mean, we check for `null`.
This commit is contained in:
Oliver Charles 2014-07-12 11:02:19 +01:00
parent 9a6e426075
commit e2fee86469

View file

@ -293,8 +293,13 @@ $(document).ready(function () {
}
if (!paused) {
if (value.type === DISTRIBUTION) {
var val = value.mean.toPrecision(8) + '\n+/-' +
Math.sqrt(value.variance).toPrecision(8) + ' sd';
if (value.mean !== null) {
var val = value.mean.toPrecision(8) + '\n+/-' +
Math.sqrt(value.variance).toPrecision(8) + ' sd';
}
else {
var val = "N/A";
}
} else { // COUNTER, GAUGE, LABEL
var val = value.val;
}