bsw@1045: local initiative = param.get("initiative", "table") bsw@1045: local batteled_initiative = param.get("battled_initiative", "table") bsw@1045: bsw@1045: local grey = "#eee" bsw@1045: bsw@1045: if initiative.issue.fully_frozen and initiative.issue.closed bsw@1045: and initiative.negative_votes and initiative.positive_votes and initiative.rank ~= 1 then bsw@1045: if not batteled_initiative then bsw@1045: return bsw@1045: end bsw@1045: local battle1 = Battle:getByInitiativeIds(batteled_initiative.id, initiative.id) bsw@1045: local battle2 = Battle:getByInitiativeIds(initiative.id, batteled_initiative.id) bsw@1045: bsw@1045: if not battle1 or not battle2 then bsw@1045: return bsw@1045: end bsw@1045: bsw@1045: local positive_votes = battle2.count bsw@1045: local negative_votes = battle1.count bsw@1045: bsw@1045: local max_value = initiative.issue.voter_count bsw@1045: if max_value > 0 then bsw@1045: ui.bargraph{ bsw@1045: max_value = max_value * 2, bsw@1045: width = 100, bsw@1045: bars = { bsw@1045: { color = grey, value = max_value - negative_votes }, bsw@1045: { color = "#a00", value = negative_votes }, bsw@1045: { color = "#0a0", value = positive_votes }, bsw@1045: { color = grey, value = max_value - positive_votes }, bsw@1045: } bsw@1045: } bsw@1045: else bsw@1045: ui.bargraph{ bsw@1045: max_value = 1, bsw@1045: width = 100, bsw@1045: bars = { bsw@1045: { color = grey, value = 1 }, bsw@1045: } bsw@1045: } bsw@1045: end bsw@1045: else bsw@1045: local max_value = initiative.issue.population or 0 bsw@1045: local quorum bsw@1045: if initiative.issue.accepted then bsw/jbe@1309: quorum = initiative.issue.initiative_quorum or 0 bsw@1045: else bsw/jbe@1309: quorum = initiative.issue.issue_quorum or 0 bsw/jbe@1309: end bsw/jbe@1309: if quorum > max_value then bsw/jbe@1309: max_value = quorum bsw@1045: end bsw@1045: ui.bargraph{ bsw@1045: max_value = max_value, bsw@1045: width = 100, bsw/jbe@1309: quorum = quorum, bsw@1045: quorum_color = "#00F", bsw@1045: bars = { bsw@1045: { color = "#5a5", value = (initiative.satisfied_supporter_count or 0) }, bsw@1045: { color = "#fa5", value = (initiative.supporter_count or 0) - (initiative.satisfied_supporter_count or 0) }, bsw@1045: { color = grey, value = max_value - (initiative.supporter_count or 0) }, bsw@1045: } bsw@1045: } bsw@1045: end