mirror of
https://github.com/ntop/ntopng.git
synced 2026-04-29 23:49:33 +00:00
stackedProgressBars component improvements to handle bad inputs
This commit is contained in:
parent
8f6d29d7bc
commit
5c2f560b84
1 changed files with 6 additions and 0 deletions
|
|
@ -161,6 +161,12 @@ function stackedProgressBars(total, bars, other_label, formatter)
|
|||
-- The bars
|
||||
res[#res + 1] = [[<div class="progress">]]
|
||||
|
||||
local sum = 0
|
||||
for _, bar in ipairs(bars) do
|
||||
sum = sum + bar.value
|
||||
end
|
||||
if total > sum then total = sum end
|
||||
|
||||
for _, bar in ipairs(bars) do
|
||||
local percentage = round(bar.value * 100 / total, 2)
|
||||
cumulative = cumulative + bar.value
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue