XHistoryGraph
XHistoryGraph is a Monitor widget in LightGUI's XFrame widget set. Scrolling multi-series time-series line graph.
XHistoryGraph is the workhorse graph for live data: push samples in and it scrolls them left across a 60-second window, one coloured line per series, with a legend showing the current, minimum, maximum and average of each series. Feed it CPU and memory percentages, temperatures, or anything else that changes over time.

Key methods
add_series(name, color)— register a named series with its line colourset_window_seconds(seconds)— how much history stays visible (default 60)push(series, value)— append one sample to one seriespush_all(values)— append one sample to every series at once
Every widget also gets the shared properties visible, enabled, bounds (x, y, width, height) and style_name, plus the background / foreground colours from the active style.
Example
Two series, one call per sample — the graph scrolls and the legend updates itself.
XHistoryGraph widget(display, screen, window, gc, &styles, 20, 20, 720, 480);
widget.add_series("CPU", Srgb{0, 170, 70});
widget.add_series("MEM", Srgb{0, 100, 200});
widget.set_window_seconds(60);
widget.push(0, 55.0); // CPU sample
widget.push(1, 38.0); // MEM sample
widget.draw();The snippet above is the widget part only. As with every XFrame example, the full program opens a display, creates a window and a style manager, then runs the standard event loop — see the complete example in the repo.
Build it from the repo root:
g++ -std=c++17 -Iwidgets/components -Iwidgets examples/XHistoryGraph.cpp -lX11 -o XHistoryGraphRun it under Xvfb or a real X server; close the window to quit.
Example in the repo
The full working example is examples/XHistoryGraph.cpp in the lightgui repo (C is canonical). The same widget is ported to the Rust and Python repos under the same name — see the links below.
Get the code
These widgets ship in all three LightGUI repos:
- lightgui (C)
- lightgui_rust (Rust)
- lightgui_python (Python)