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 identifier

  • classes (str or list of str, optional) – CSS class names for styling

  • data (list of list, 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 (list of str, optional) – Labels for rows (default: None)

  • col_labels (list of str, 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")

  • bind (bool | str)

Variables:
  • data (list of list) – 2D grid data

  • width (int) – Display width

  • height (int) – Display height

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]
Parameters:
Return type:

None

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_intrinsic_size()

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_tab

Whether this element wants the Tab key instead of focus movement.

data

Get the raw data values.

parent_frame

Get the parent Frame if this element is inside a scrollable frame.

supports_dynamic_sizing

Whether this element supports dynamic sizing.

property data: list[list[float | int]]

Get the raw data values.

Returns:

Raw data values

Return type:

list of list

set_data(data)[source]

Update heat map data.

Parameters:

data (list of list) – New grid data

Return type:

None

get_intrinsic_size()[source]

Get the intrinsic size of the heat map.

Returns:

(width, height) in characters

Return type:

tuple of int

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