NumberState

State class for number display with formatting

Displays a numeric value with configurable decimal precision. The actual number to display is stored in the 'value' field, while 'text' is auto-generated based on formatting rules. For decimal point alignment (AUTO_ALIGNED and FIXED_ALIGNED modes), the number is rendered as two separate text elements (integer and decimal parts) positioned to keep the decimal point at the same location.

Constructor

NumberState(
    pos: Point2D | None = None,
    scale: float | None = None,
    opacity: float | None = None,
    rotation: float | None = None,
    skew_x: float | None = None,
    skew_y: float | None = None,
    z_index: float = 0.0,
    clip_state: State | None = None,
    mask_state: State | None = None,
    clip_states: List[State] | None = None,
    mask_states: List[State] | None = None,
    filter: Filter | None = None,
    NON_INTERPOLATABLE_FIELDS: frozenset[str] = frozenset({'NON_INTERPOLATABLE_FIELDS'}),
    fill_color: Optional[Color] = Color.NONE,
    fill_opacity: float = 1,
    fill_gradient: Optional[Gradient] = None,
    fill_pattern: Optional[Pattern] = None,
    stroke_color: Optional[Color] = Color.NONE,
    stroke_opacity: float = 1,
    stroke_width: float = 1,
    stroke_gradient: Optional[Gradient] = None,
    stroke_pattern: Optional[Pattern] = None,
    font_size: float = 16,
    letter_spacing: float = 0,
    text: str = '',
    font_family: str = 'Arial',
    font_weight: str = 'normal',
    text_anchor: str = 'middle',
    dominant_baseline: str = 'central',
    text_rendering: TextRendering = <TextRendering.AUTO: 'auto'>,
    value: float = 0.0,
    format: NumberFormat = <NumberFormat.FIXED: 'fixed'>,
    rounding: Rounding = <Rounding.FLOOR: 'floor'>,
    decimals: int = 2,
    max_decimals: int = 2,
    prefix: str = '',
    suffix: str = '',
    thousands_separator: str = '',
    _integer_part: str = '',
    _decimal_part: str = '',
    _has_decimals: bool = False
) -> None

Methods

get_renderer_class

get_renderer_class()

Get the renderer class for this state.

Returns

The renderer class for this state, or None if not registered

get_vertex_renderer_class

get_vertex_renderer_class()

Get the vertex renderer class for morphing transitions.

is_angle

is_angle(field: Field) -> bool

need_morph

need_morph(state)

with_x

with_x(x: float) -> State

with_y

with_y(y: float) -> State

Properties

x
y