Skip to content

Commit 1272c3a

Browse files
blueyedMcSinyx
authored andcommitted
update: handle stacked graphs
With stacked graphs each stack entry (via `stack_colors`) has its own data point, and `data` is expected to be a table. The `get_stack` getter was just added to awesome via [1] in [2] to handle this case. 1: awesomeWM/awesome#284 2: awesomeWM/awesome@3be423f
1 parent 6b4910e commit 1272c3a

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

init.lua

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,15 @@ local function update(widget, reg, disablecache)
7373
local function update_value(data)
7474
local fmtd_data = format_data(data)
7575
if widget.add_value ~= nil then
76-
widget:add_value(tonumber(fmtd_data) and tonumber(fmtd_data)/100)
76+
if widget.get_stack ~= nil and widget:get_stack() then
77+
for idx, _ in ipairs(widget:get_stack_colors()) do
78+
if fmtd_data[idx] then
79+
widget:add_value(tonumber(fmtd_data[idx]) and tonumber(fmtd_data[idx]/100), idx)
80+
end
81+
end
82+
else
83+
widget:add_value(tonumber(fmtd_data) and tonumber(fmtd_data)/100)
84+
end
7785
elseif widget.set_value ~= nil then
7886
widget:set_value(tonumber(fmtd_data) and tonumber(fmtd_data)/100)
7987
elseif widget.set_markup ~= nil then

0 commit comments

Comments
 (0)