Skip to content

Commit 6da3c93

Browse files
committed
Update stack graph example
1 parent 1272c3a commit 6da3c93

File tree

1 file changed

+9
-15
lines changed

1 file changed

+9
-15
lines changed

README.md

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -739,27 +739,21 @@ vicious.register(uptimewidget, vicious.widgets.uptime, "$1 $2:$3", 61)
739739

740740
#### Stacked graph
741741

742-
Stacked graphs (aka multigraphs) are not handled by Vicious at the moment, as
743-
it's hard to pass on color index arguments elegantly. But they are not
744-
unusable, far from it.
742+
Stacked graphs are handled specially by Vicious: `format` functions passed to
743+
the corresponding widget types must return an array instead of a string.
745744

746745
```lua
747-
ctext = wibox.widget.textbox()
748-
cgraph = awful.widget.graph()
749-
cgraph:set_width(100):set_height(20)
750-
cgraph:set_stack(true):set_max_value(100)
751-
cgraph:set_background_color("#494B4F")
752-
cgraph:set_stack_colors({ "#FF5656", "#88A175", "#AECF96" })
753-
vicious.register(ctext, vicious.widgets.cpu,
746+
cpugraph = wibox.widget.graph()
747+
cpugraph:set_stack(true)
748+
cpugraph:set_stack_colors({"red", "yellow", "green", "blue"})
749+
vicious.register(cpugraph, vicious.widgets.cpu,
754750
function (widget, args)
755-
cgraph:add_value(args[2], 1) -- Core 1, color 1
756-
cgraph:add_value(args[3], 2) -- Core 2, color 2
757-
cgraph:add_value(args[4], 3) -- Core 3, color 3
751+
return {args[2], args[3], args[4], args[5]}
758752
end, 3)
759753
```
760754

761-
The snipet above enables graph stacking/multigraph and plots usage of all three
762-
CPU cores on a single graph. The textbox `ctext` is just an empty placeholder.
755+
The snipet above enables graph stacking/multigraph and plots usage of all four
756+
CPU cores on a single graph.
763757

764758
#### Substitute widget types' symbols
765759

0 commit comments

Comments
 (0)