liquid_feedback_frontend

view env/ui/bargraph.lua @ 159:5d797c6706d5

implement quorum display

show the initiative quorum as a small 1px line in bargraph
allow to update your support on the diff page
better linked title in diff page
show absolute quorum numbers in detail pages of issue and initiative
author Daniel Poelzleithner <poelzi@poelzi.org>
date Sat Oct 09 03:42:48 2010 +0200 (2010-10-09)
parents 00d1004545f1
children 03c205fc17f0
line source
1 function ui.bargraph(args)
2 local text = ""
3 for i, bar in ipairs(args.bars) do
4 if #text > 0 then
5 text = text .. " / "
6 end
7 text = text .. tostring(bar.value)
8 end
9 ui.container{
10 attr = {
11 class = args.class or "bargraph",
12 title = tostring(text)
13 },
14 content = function()
15 local at_least_one_bar = false
16 local quorum = args.quorum and args.quorum * args.width / args.max_value or nil
17 local length = 0
18 for i, bar in ipairs(args.bars) do
19 if bar.value > 0 then
20 at_least_one_bar = true
21 local value = bar.value * args.width / args.max_value
22 if quorum and quorum < length + value then
23 local dlength = math.max(quorum - length - 1, 0)
24 if dlength > 0 then
25 ui.container{
26 attr = {
27 style = "width: " .. tostring(dlength) .. "px; background-color: " .. bar.color .. ";",
28 },
29 content = function() slot.put("&nbsp;") end
30 }
31 end
32 ui.container{
33 attr = {
34 style = "width: 1px; background-color: " .. (args.quorum_color or "blue") ..";",
35 },
36 content = function() slot.put("&nbsp;") end
37 }
38 length = dlength + 1
39 value = value - dlength
40 quorum = nil
41 end
42 length = length + value
43 ui.container{
44 attr = {
45 style = "width: " .. tostring(value) .. "px; background-color: " .. bar.color .. ";",
46 },
47 content = function() slot.put("&nbsp;") end
48 }
49 end
50 end
51 if not at_least_one_bar then
52 slot.put("&nbsp;")
53 end
54 end
55 }
56 end

Impressum / About Us