wijjit.elements.display.sparkline.Sparkline
- class wijjit.elements.display.sparkline.Sparkline(id=None, classes=None, data=None, width=20, height=1, style='line', show_minmax=False, show_current=False, color=None, border_style='none', bind=True)[source]
Sparkline element for compact inline trend visualization.
This element displays a compact trend visualization in a single row, suitable for embedding inline with text or in dashboard displays.
- Parameters:
id (
str, optional) – Element identifierclasses (
strorlistofstr, optional) – CSS class names for stylingdata (
list, optional) – Data values as numbers, tuples, or dicts (default: [])width (
int, optional) – Display width in columns (default: 20)height (
int, optional) – Display height in rows (default: 1)style (
str, optional) – Rendering style: “line”, “bar”, “dot” (default: “line”)show_minmax (
bool, optional) – Show min/max markers (default: False)show_current (
bool, optional) – Show current (last) value text (default: False)color (
str, optional) – Foreground color for the sparkline glyphs, on top of the theme style. Accepts a named color,#RRGGBBhex, orrgb(r, g, b)(default: None, use the theme color).border_style (str)
- Variables:
Examples
Simple sparkline with default line style:
>>> sparkline = Sparkline(data=[10, 20, 15, 25, 30, 20])
Bar-style sparkline:
>>> sparkline = Sparkline(data=[1, 2, 3, 4, 5], style="bar")
With current value display:
>>> sparkline = Sparkline(data=[10, 20, 30], show_current=True)
- __init__(id=None, classes=None, data=None, width=20, height=1, style='line', show_minmax=False, show_current=False, color=None, border_style='none', bind=True)[source]
Methods
__init__([id, classes, data, width, height, ...])add_class(class_name)Add a CSS class to this element.
apply_props(props)Apply props from a VNode, skipping ephemeral props.
get_ephemeral_state()Get ephemeral state that should survive reconciliation.
get_hardware_cursor_position()Absolute screen cell where the hardware terminal cursor should park.
get_height_for_width(width)Return the height this element needs when laid out at
width.Get the intrinsic size of the sparkline.
handle_key(key)Handle a key press.
handle_mouse(event)Handle a mouse event.
has_class(class_name)Check if element has a CSS class.
on_blur()Called when element loses focus.
on_focus()Called when element gains focus.
on_hover_enter()Called when mouse enters element.
on_hover_exit()Called when mouse exits element.
on_mount()Called when element is first added to the element tree.
on_unmount()Called when element is removed from the element tree.
on_update(changed_props)Called when element props are updated during reconciliation.
remove_class(class_name)Remove a CSS class from this element.
Paint memo for the skip-unchanged fast path.
render_to(ctx)Render the sparkline using cell-based rendering.
restore_ephemeral_state(state)Restore ephemeral state after reconciliation.
set_bounds(bounds)Set the element's screen bounds.
set_data(data)Update sparkline data.
toggle_class(class_name)Toggle a CSS class on this element.
Attributes
captures_tabWhether this element wants the Tab key instead of focus movement.
Get the raw data values.
parent_frameGet the parent Frame if this element is inside a scrollable frame.
supports_dynamic_sizingWhether this element supports dynamic sizing.
- set_data(data)[source]
Update sparkline data.
- Parameters:
data (
list) – New data values- Return type:
None
- render_signature()[source]
Paint memo for the skip-unchanged fast path.
Captures the extracted values, the rendering style, the display dimensions, the min/max and current-value toggles, the color override, the border style, and the style-affecting state. See
wijjit.elements.base.Element.render_signature().- Return type:
- render_to(ctx)[source]
Render the sparkline using cell-based rendering.
- Parameters:
ctx (
PaintContext) – Paint context with buffer, style resolver, and bounds- Return type:
None
Notes
Theme styles:
This element uses the following theme style classes: -
sparkline: Base sparkline style -sparkline.min: Minimum value marker style -sparkline.max: Maximum value marker style -sparkline.current: Current value text style