1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
local gears = require "gears"
local lit = require "lib.lit"
local qbezier = require "quarrel.bezier"
local qui = require "quarrel.ui"
local wibox = require "wibox"
local widget = wibox.widget {
widget = wibox.container.constraint,
height = 120,
width = 120,
strategy = "exact",
{
widget = lit.widget.linechart,
-- max_value = 30,
-- step_width = 10,
-- scale = true,
-- stack = false,
-- forced_height = 30,
-- step_hook = curvaceous
-- values = { 1, 10, 100 },
fill = true,
fill_color = "#00ff00",
-- fill_border = true,
fill_border_color = "#ff0000",
draw_bg = function(cr, width, _, min, max, transform)
cr:set_line_width(1)
local min_abs = math.abs(min)
local dash_pattern = { 6, 4 }
local rendered_zero, zero_overlap = false, false
for i = 0, 4 do
local temp = ((min_abs + max) * (i / 4)) - min_abs
rendered_zero = rendered_zero or temp == 0
if rendered_zero and not zero_overlap and min < 0 then
cr:set_source_rgba(gears.color.parse_color "#0000ff")
zero_overlap = true
else
cr:set_dash(dash_pattern, 1, 0)
cr:set_source_rgba(gears.color.parse_color "#ff0000ff")
end
local y = transform(temp)
cr:move_to(0, y)
cr:line_to(width, y)
cr:stroke()
cr:set_dash({}, 0, 0)
end
if not rendered_zero then
cr:set_source_rgba(gears.color.parse_color "#0000ff")
local h_0 = transform(0)
cr:move_to(0, h_0)
cr:line_to(width, h_0)
cr:stroke()
end
end,
},
}
-- for _ = 1, 100 do
-- widget.widget:add_value(math.random(0, 30))
-- end
-- require "gears.timer" {
-- autostart = true,
-- timeout = 0.2,
-- callback = function ()
-- widget.widget:add_value(math.random(0, 30))
-- end
-- }
return widget
|