# HG changeset patch # User veltr # Date 1352471272 -3600 # Node ID 982d2226771c9e10a46da8f934da00365ab812b6 # Parent 9ee8c00ae5b70e04824ee60e11c97f3f985227d0 Bugfix diff -r 9ee8c00ae5b7 -r 982d2226771c src/widgets/Sparkline.js --- a/src/widgets/Sparkline.js Fri Nov 09 14:33:03 2012 +0100 +++ b/src/widgets/Sparkline.js Fri Nov 09 15:27:52 2012 +0100 @@ -18,24 +18,22 @@ _duration = this.source.getDuration(), _max = 0, _list = this.getWidgetAnnotations(); - for (var _i = 0; _i < this.slice_count; _i++) { var _begin = (_i*_duration/this.slice_count), _end = ((_i+1)*_duration/this.slice_count), - _annotations = _list.reduce(function(_m, _annotation) { - if (_annotation.begin < _end && _annotation.begin >= _begin) { + _volume = 0; + _list.forEach(function(_annotation) { + if (_annotation.begin < _end && _annotation.end >= _begin) { var _d = _annotation.getDuration().milliseconds; if (!_d) { - return _m + 1; + _volume += 1; } else { - return _m + (Math.min(_annotation.end, _end) - Math.max(_annotation.begin, _begin)) / _d; + _volume += (Math.min(_annotation.end, _end) - Math.max(_annotation.begin, _begin)) / _d; } - } else { - return _m } - },0); - _max = Math.max(_max, _annotations); - _slices.push(_annotations); + }); + _max = Math.max(_max, _volume); + _slices.push(_volume); } if (!_max) { return;