Added total to the stackedProgressBars component

This commit is contained in:
Alfredo Cardigliano 2018-12-12 23:48:15 +01:00
parent 6015642754
commit 4b77c7640b

View file

@ -168,8 +168,10 @@ function stackedProgressBars(total, bars, other_label, formatter)
local percentage = round(bar.value * 100 / total, 2)
if bar.class == nil then bar.class = "primary" end
if bar.style == nil then bar.style = "" end
if bar.link ~= nil then res[#res + 1] = [[<a href="]] .. bar.link .. [[">]] end
res[#res + 1] = [[
<div class="progress-bar progress-bar-]] .. (bar.class) .. [[" role="progressbar" style="width:]] .. percentage .. [[%;]] .. bar.style .. [["></div>]]
<div class="progress-bar progress-bar-]] .. (bar.class) .. [[" role="progressbar" style="width:]] .. percentage .. [[%;]] .. bar.style .. [["></div></a>]]
if bar.link ~= nil then res[#res + 1] = [[</a>]] end
end
res[#res + 1] = [[
@ -192,9 +194,15 @@ function stackedProgressBars(total, bars, other_label, formatter)
end
for _, bar in ipairs(legend_items) do
res[#res + 1] = [[<span><span class="label label-]].. (bar.class) ..[[" style="]] .. bar.style .. [[">&nbsp;</span><span>]] .. bar.title .. " (".. formatter(bar.value) ..")</span></span>"
res[#res + 1] = [[<span>]]
if bar.link ~= nil then res[#res + 1] = [[<a href="]] .. bar.link .. [[">]] end
res[#res + 1] = [[<span class="label label-]].. (bar.class) ..[[" style="]] .. bar.style .. [[">&nbsp;</span>]]
if bar.link ~= nil then res[#res + 1] = [[</a>]] end
res[#res + 1] = [[<span>]] .. bar.title .. " (".. formatter(bar.value) ..")</span></span>"
end
res[#res + 1] = [[<span style="margin-left: 0"><span></span><span>&nbsp;&nbsp;-&nbsp;&nbsp;]] .. i18n("total") .. ": ".. formatter(total) .."</span></span>"
return table.concat(res)
end