Update stack graph example

This commit is contained in:
Nguyễn Gia Phong 2019-01-23 05:11:12 +07:00
parent 1272c3ad1b
commit 6da3c9304a
1 changed files with 9 additions and 15 deletions

View File

@ -739,27 +739,21 @@ vicious.register(uptimewidget, vicious.widgets.uptime, "$1 $2:$3", 61)
#### Stacked graph #### Stacked graph
Stacked graphs (aka multigraphs) are not handled by Vicious at the moment, as Stacked graphs are handled specially by Vicious: `format` functions passed to
it's hard to pass on color index arguments elegantly. But they are not the corresponding widget types must return an array instead of a string.
unusable, far from it.
```lua ```lua
ctext = wibox.widget.textbox() cpugraph = wibox.widget.graph()
cgraph = awful.widget.graph() cpugraph:set_stack(true)
cgraph:set_width(100):set_height(20) cpugraph:set_stack_colors({"red", "yellow", "green", "blue"})
cgraph:set_stack(true):set_max_value(100) vicious.register(cpugraph, vicious.widgets.cpu,
cgraph:set_background_color("#494B4F")
cgraph:set_stack_colors({ "#FF5656", "#88A175", "#AECF96" })
vicious.register(ctext, vicious.widgets.cpu,
function (widget, args) function (widget, args)
cgraph:add_value(args[2], 1) -- Core 1, color 1 return {args[2], args[3], args[4], args[5]}
cgraph:add_value(args[3], 2) -- Core 2, color 2
cgraph:add_value(args[4], 3) -- Core 3, color 3
end, 3) end, 3)
``` ```
The snipet above enables graph stacking/multigraph and plots usage of all three The snipet above enables graph stacking/multigraph and plots usage of all four
CPU cores on a single graph. The textbox `ctext` is just an empty placeholder. CPU cores on a single graph.
#### Substitute widget types' symbols #### Substitute widget types' symbols