You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on May 29, 2019. It is now read-only.
The Origin:
First the watcher for "max" is proceeded for both bars.
Next the watcher for "value" is proceeded for only the first bar.
While calculating the totalPercantage the second bar has still the wrong percentage. See:
var totalPercentage = self.bars.reduce(function (total, bar) {
return total + bar.percent;
}, 0);
The Solution:
Recalculate the bar percentage:
var totalPercentage = self.bars.reduce(function (total, bar) {
bar.percent = +(100 * bar.value / bar.max).toFixed(2); //Bugfix
return total + bar.percent;
}, 0);
The text was updated successfully, but these errors were encountered:
There is also a problem with removing an item, because recalculatePercentage is still calculated with the removed one included.
I found a solution with recalculating after removing:
this.removeBar = function (bar) {
this.bars.splice(this.bars.indexOf(bar), 1);
this.bars.forEach(function (bar) { //Bugfix
bar.recalculatePercentage();
});
};
AngularJS v1.4.5
angular-ui-bootstrap Version: 0.13.4
What to do:
See plnkr demo: http://plnkr.co/edit/zf2jb4?p=preview
Go inside the first textbox (100) and use Backspace to reduce it to 10.
The Problem:
The Bars are recalculated wrong.
The Origin:
First the watcher for "max" is proceeded for both bars.
Next the watcher for "value" is proceeded for only the first bar.
While calculating the totalPercantage the second bar has still the wrong percentage. See:
var totalPercentage = self.bars.reduce(function (total, bar) {
return total + bar.percent;
}, 0);
The Solution:
Recalculate the bar percentage:
var totalPercentage = self.bars.reduce(function (total, bar) {
bar.percent = +(100 * bar.value / bar.max).toFixed(2); //Bugfix
return total + bar.percent;
}, 0);
The text was updated successfully, but these errors were encountered: