feat: gráficos de área en la pestaña Sistema

graph() admite ahora relleno translúcido por serie (s.fill). Las nueve
gráficas de Sistema usan área para mejor legibilidad; la pestaña Red
mantiene líneas porque superpone dos series (down/up).
This commit is contained in:
Egutierrez
2026-06-02 21:43:47 +02:00
parent 8ecf787094
commit 5b1e236988
+20 -12
View File
@@ -219,7 +219,8 @@ local function bar(cr, x, y, w, h, frac, c)
setcol(cr, c); rrect(cr, x, y, math.max(2, w * frac), h, 3); cairo_fill(cr) setcol(cr, c); rrect(cr, x, y, math.max(2, w * frac), h, 3); cairo_fill(cr)
end end
-- Grafico de linea sobre un panel redondeado --------------------------------- -- Grafico sobre un panel redondeado. Cada serie con s.fill=true se dibuja como
-- area (relleno translucido) ademas de la linea; si no, solo linea.
local function graph(cr, x, y, w, h, series) local function graph(cr, x, y, w, h, series)
setcol(cr, COL.panel); rrect(cr, x, y, w, h, 4); cairo_fill(cr) setcol(cr, COL.panel); rrect(cr, x, y, w, h, 4); cairo_fill(cr)
-- Maximo comun a todas las series (fijo si se indica) -- Maximo comun a todas las series (fijo si se indica)
@@ -232,12 +233,19 @@ local function graph(cr, x, y, w, h, series)
end end
end end
for _, s in ipairs(series) do for _, s in ipairs(series) do
cairo_set_line_width(cr, 1.3); setcol(cr, s.c)
local n = #s.data local n = #s.data
local function px(i) return x + (i - 1) / (n - 1) * w end
local function py(i) return y + h - (s.data[i] / maxv) * (h - 4) - 2 end
if s.fill then
cairo_move_to(cr, px(1), y + h)
for i = 1, n do cairo_line_to(cr, px(i), py(i)) end
cairo_line_to(cr, px(n), y + h)
cairo_close_path(cr)
setcol(cr, s.c, 0.25); cairo_fill(cr)
end
cairo_set_line_width(cr, 1.3); setcol(cr, s.c)
for i = 1, n do for i = 1, n do
local px = x + (i - 1) / (n - 1) * w if i == 1 then cairo_move_to(cr, px(i), py(i)) else cairo_line_to(cr, px(i), py(i)) end
local py = y + h - (s.data[i] / maxv) * (h - 4) - 2
if i == 1 then cairo_move_to(cr, px, py) else cairo_line_to(cr, px, py) end
end end
cairo_stroke(cr) cairo_stroke(cr)
end end
@@ -341,34 +349,34 @@ local function draw_sys(cr)
-- CPU -- CPU
local gh = row("CPU " .. math.floor(num("${cpu cpu0}")) .. "%", local gh = row("CPU " .. math.floor(num("${cpu cpu0}")) .. "%",
str("${freq_g}") .. "GHz " .. cputemp .. "°C", COL.teal, 26) str("${freq_g}") .. "GHz " .. cputemp .. "°C", COL.teal, 26)
graph(cr, x, y, gw, gh, { { data = hist.cpu, c = COL.green, max = 100 } }); y = y + gh + 4 graph(cr, x, y, gw, gh, { { data = hist.cpu, c = COL.green, max = 100, fill = true } }); y = y + gh + 4
-- RAM -- RAM
gh = row("RAM " .. math.floor(num("${memperc}")) .. "%", gh = row("RAM " .. math.floor(num("${memperc}")) .. "%",
str("${mem}") .. " / " .. str("${memmax}"), COL.green, 26) str("${mem}") .. " / " .. str("${memmax}"), COL.green, 26)
graph(cr, x, y, gw, gh, { { data = hist.ram, c = COL.green, max = 100 } }); y = y + gh + 4 graph(cr, x, y, gw, gh, { { data = hist.ram, c = COL.green, max = 100, fill = true } }); y = y + gh + 4
-- CPU TEMP -- CPU TEMP
gh = row("CPU TEMP " .. cputemp .. "°C", "", COL.yellow, 20) gh = row("CPU TEMP " .. cputemp .. "°C", "", COL.yellow, 20)
graph(cr, x, y, gw, gh, { { data = hist.cputemp, c = COL.yellow, max = 100 } }); y = y + gh + 4 graph(cr, x, y, gw, gh, { { data = hist.cputemp, c = COL.yellow, max = 100, fill = true } }); y = y + gh + 4
-- GPU -- GPU
gh = row("GPU " .. str("${execi 2 " .. MET .. " gpu_util}") .. "%", gh = row("GPU " .. str("${execi 2 " .. MET .. " gpu_util}") .. "%",
gputemp .. "°C", COL.cyan, 26) gputemp .. "°C", COL.cyan, 26)
graph(cr, x, y, gw, gh, { { data = hist.gputil, c = COL.cyan, max = 100 } }); y = y + gh + 4 graph(cr, x, y, gw, gh, { { data = hist.gputil, c = COL.cyan, max = 100, fill = true } }); y = y + gh + 4
-- GPU TEMP -- GPU TEMP
gh = row("GPU TEMP " .. gputemp .. "°C", "", COL.yellow, 20) gh = row("GPU TEMP " .. gputemp .. "°C", "", COL.yellow, 20)
graph(cr, x, y, gw, gh, { { data = hist.gputemp, c = COL.yellow, max = 100 } }); y = y + gh + 4 graph(cr, x, y, gw, gh, { { data = hist.gputemp, c = COL.yellow, max = 100, fill = true } }); y = y + gh + 4
-- VRAM -- VRAM
gh = row("VRAM " .. str("${execi 2 " .. MET .. " gpu_memp}") .. "%", gh = row("VRAM " .. str("${execi 2 " .. MET .. " gpu_memp}") .. "%",
str("${execi 2 " .. MET .. " gpu_memi}"), COL.purple, 26) str("${execi 2 " .. MET .. " gpu_memi}"), COL.purple, 26)
graph(cr, x, y, gw, gh, { { data = hist.vram, c = COL.purple, max = 100 } }); y = y + gh + 4 graph(cr, x, y, gw, gh, { { data = hist.vram, c = COL.purple, max = 100, fill = true } }); y = y + gh + 4
-- DISK I/O -- DISK I/O
gh = row("DISK I/O", str("${diskio}"), COL.orange, 26) gh = row("DISK I/O", str("${diskio}"), COL.orange, 26)
graph(cr, x, y, gw, gh, { { data = hist.diskio, c = COL.purple } }); y = y + gh + 6 graph(cr, x, y, gw, gh, { { data = hist.diskio, c = COL.purple, fill = true } }); y = y + gh + 6
-- Uso de discos -- Uso de discos
text(cr, x, y + 10, "USO DE DISCOS", COL.snow, 10, true); y = y + 16 text(cr, x, y + 10, "USO DE DISCOS", COL.snow, 10, true); y = y + 16