wijjit.elements.display.heatmap.HeatMap
- class wijjit.elements.display.heatmap.HeatMap(id=None, classes=None, data=None, width=40, height=10, cell_width=2, cell_height=1, color_scale='heat', show_values=False, show_legend=True, show_labels=False, row_labels=None, col_labels=None, min_value=None, max_value=None, border_style='single', bind=True)[source]
HeatMap element for grid-based color intensity visualization.
This element displays a 2D grid where cell colors represent values, creating a heat map visualization.
- Parameters:
id (
str, optional) – Element identifierclasses (
strorlistofstr, optional) – CSS class names for stylingdata (
listoflist, optional) – 2D grid of values (default: [])width (
int, optional) – Display width in columns (default: 40)height (
int, optional) – Display height in rows (default: 10)cell_width (
int, optional) – Width of each cell in characters (default: 2)cell_height (
int, optional) – Height of each cell in rows (default: 1)color_scale (
str, optional) – Color scale: “green”, “red”, “blue”, “heat”, “cool” (default: “heat”)show_values (
bool, optional) – Show values inside cells (default: False)show_legend (
bool, optional) – Show color legend (default: True)show_labels (
bool, optional) – Show row/column labels (default: False)row_labels (
listofstr, optional) – Labels for rows (default: None)col_labels (
listofstr, optional) – Labels for columns (default: None)min_value (
float, optional) – Minimum value for color scaling (default: auto)max_value (
float, optional) – Maximum value for color scaling (default: auto)border_style (
str, optional) – Border style drawn within the element bounds (e.g."single","double","rounded","none") (default:"single")
- Variables:
Examples
Simple heat map:
>>> heatmap = HeatMap(data=[ ... [1, 2, 3], ... [4, 5, 6], ... [7, 8, 9] ... ])
With custom color scale:
>>> heatmap = HeatMap(data=grid, color_scale="cool")
With labels:
>>> heatmap = HeatMap( ... data=grid, ... row_labels=["A", "B", "C"], ... col_labels=["X", "Y", "Z"], ... show_labels=True ... )
- __init__(id=None, classes=None, data=None, width=40, height=10, cell_width=2, cell_height=1, color_scale='heat', show_values=False, show_legend=True, show_labels=False, row_labels=None, col_labels=None, min_value=None, max_value=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 heat map.
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 heat map 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 heat map 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 heat map 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: -
heatmap: Base heat map style -heatmap.cell: Cell style -heatmap.label: Label text style -heatmap.legend: Legend style