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/jbe@0: local value = bar.value * args.width / args.max_value / 2 bsw/jbe@0: ui.container{ bsw/jbe@0: attr = { bsw/jbe@0: style = "width: " .. tostring(value) .. "px; background-color: " .. bar.color .. ";", bsw/jbe@0: title = tostring(bar.value) bsw/jbe@0: }, bsw/jbe@0: content = function() slot.put(" ") end bsw/jbe@0: } bsw/jbe@0: end bsw/jbe@0: end bsw/jbe@0: } bsw/jbe@0: end