bsw/jbe@0: function ui.bargraph(args) bsw/jbe@0: ui.container{ bsw/jbe@0: attr = { bsw/jbe@0: class = "bargraph", bsw/jbe@0: }, bsw/jbe@0: content = function() bsw/jbe@0: for i, bar in ipairs(args.bars) do bsw@2: if bar.value > 0 then bsw@2: local value = bar.value * args.width / args.max_value / 2 bsw@2: ui.container{ bsw@2: attr = { bsw@2: style = "width: " .. tostring(value) .. "px; background-color: " .. bar.color .. ";", bsw@2: title = tostring(bar.value) bsw@2: }, bsw@2: content = function() slot.put(" ") end bsw@2: } bsw@2: end bsw/jbe@0: end bsw/jbe@0: end bsw/jbe@0: } bsw/jbe@0: end