wijjit.elements.display.linechart.LineChart
- class wijjit.elements.display.linechart.LineChart(id=None, classes=None, data=None, width=60, height=12, style='line', show_axis=True, axis_width=6, show_labels=True, show_points=False, show_legend=True, color=None, series_colors=None, border_style='single', bind=True)[source]
LineChart element for line and area chart visualization.
This element displays trend data using braille characters for high-resolution rendering within terminal constraints.
- Parameters:
id (
str, optional) – Element identifierclasses (
strorlistofstr, optional) – CSS class names for stylingdata (
listordict, optional) – Single series: list of values/tuples/dicts Multi-series: dict of {series_name: [values]}width (
int, optional) – Display width in columns (default: 60)height (
int, optional) – Display height in rows (default: 12)style (
str, optional) – Chart style: “line”, “area”, “dots” (default: “line”)show_axis (
bool, optional) – Show y-axis with values (default: True)axis_width (
int, optional) – Width reserved for y-axis (default: 6)show_labels (
bool, optional) – Show x-axis labels (default: True)show_points (
bool, optional) – Highlight data points (default: False)show_legend (
bool, optional) – Show legend for multi-series (default: True)color (
str, optional) – Foreground color for the plotted line, on top of the theme style. Accepts a named color,#RRGGBBhex, orrgb(r, g, b)(default: None, use the theme color).series_colors (
dict, optional) – Per-series color overrides, keyed by series name, for multi-series data (default: None). Values take the same forms ascolor. Any series not named here falls back to the next slot of the built-in categorical palette, so a multi-series chart is legible without configuration; passcolorinstead to force every series to a single color.border_style (
str, optional) – Border style drawn within the chart’s dimensions: “single”, “double”, “rounded”, “heavy”, “ascii”, or “none” (default: “single”). When a visible border is present, all content is inset one cell.
- Variables:
Examples
Simple line chart:
>>> chart = LineChart(data=[10, 20, 15, 25, 30, 20])
Area chart:
>>> chart = LineChart(data=[10, 20, 30], style="area")
Multi-series:
>>> chart = LineChart(data={ ... "Sales": [10, 20, 30], ... "Costs": [5, 10, 15] ... })
- __init__(id=None, classes=None, data=None, width=60, height=12, style='line', show_axis=True, axis_width=6, show_labels=True, show_points=False, show_legend=True, color=None, series_colors=None, border_style='single', 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 chart.
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.
render_signature()Hashable/comparable capture of everything
render_to()reads.render_to(ctx)Render the line chart 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 chart 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.
- render_to(ctx)[source]
Render the line chart 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: -
linechart: Base line chart style -linechart.line: Line/data style -linechart.axis: Axis line and text style -linechart.label: X-axis label style -linechart.legend: Legend text style