I am using the bootstrap progress bar to show the percentage of miles covered by someone from a total of 23,872 miles.
For example if user A covered only 5 miles which means:
5/23872 = 0.00020945 * 100 = 0.02094504 miles.
Currently anything below 1% does not show up on the progress bar.
Is it possible to be able to show the percentage of miles below 1 the bar so it lights up green just the 28% in the image above.
Code for Conversion:
// Calculating Percentages for each region
var ukPercent = $scope.ukTotal / 23872;
var apacPercent = $scope.apacTotal / 23872;
var naPercent = $scope.naTotal / 23872;
$scope.ukPercentage = ukPercent * 100;
$scope.naPercentage = naPercent * 100;
$scope.apacPercentage = apacPercent * 100;
If you don't care if how much less than 1% it is, how about using
Math.max()
to just start at one percent and then start making meaningful progress after that.Demo in Stack Snippets
Since you have a label, you could even follow Bootstrap's suggestion:
Like this:
I think the best approach would be to use a variable called something like "realProgress" to keep track of the decimal value of your progress bar. Since a bootstrap progress bar only works with integers you can update it's value like so (in Javascript):
realProgress = 0.0; realProgress += some percentage of progress made;
$("#my-progress-bar").css("width", math.Floor(realProgress) + "%");
This way, the progress bar's value still get updated in a way that is meaningful to the user.