xnano.components.schema
xnano.components.schema
¶
xnano.components.schema
Declare table columns and chart series as component class attributes.
Classes:
-
ComponentDescriptor–Named declarative component field.
-
Column–Describe one table column.
-
Series–Describe one chart series.
ComponentDescriptor
dataclass
¶
Column
dataclass
¶
Column(
header: str | None = None,
accessor: Callable[[Any], Any] | None = None,
format: FormatResolver = None,
foreground: ColorResolver = None,
background: ColorResolver = None,
horizontal_align: "Alignment | None" = None,
width: int | float | None = None,
)
Bases: ComponentDescriptor
Describe one table column.
Attributes:
-
header(str | None) –Header displayed for the column.
-
accessor(Callable[[Any], Any] | None) –Row attribute, mapping key, or value callback.
-
format(FormatResolver) –Optional format string or value callback.
-
foreground(ColorResolver) –Cell foreground color.
-
background(ColorResolver) –Cell background color.
-
horizontal_align('Alignment | None') –Cell alignment.
-
width(int | float | None) –Fixed or proportional column width.
Methods:
-
resolve_header–Return the displayed header.
-
resolve_value–Read this column's value from a row.
-
resolve_text–Format a value for display.
-
resolve_color–Resolve the foreground color for a value.
-
resolve_background–Resolve the background color for a value.
accessor
class-attribute
instance-attribute
¶
Custom row value accessor.
foreground
class-attribute
instance-attribute
¶
Foreground color or resolver.
background
class-attribute
instance-attribute
¶
Background color or resolver.
horizontal_align
class-attribute
instance-attribute
¶
Cell text alignment.
width
class-attribute
instance-attribute
¶
Fixed width or fractional width.
name
class-attribute
instance-attribute
¶
name: str = dataclasses.field(default='', init=False)
Attribute name assigned by the component class.
resolve_value
¶
Read this column's value from a row.
resolve_text
¶
Format a value for display.
Source code in xnano/components/schema.py
resolve_color
¶
resolve_background
¶
Series
dataclass
¶
Series(
label: str | None = None,
color: "ColorLike | None" = None,
kind: "GraphTypeLike | None" = None,
marker: "CanvasMarkerLike | None" = None,
)
Bases: ComponentDescriptor
Describe one chart series.
Attributes:
-
label(str | None) –Legend label;
Nonederives it from the attribute name. -
color('ColorLike | None') –Series color.
-
kind('GraphTypeLike | None') –Plot representation.
-
marker('CanvasMarkerLike | None') –Glyph set used to paint the series.
Methods:
-
resolve_label–Return the displayed legend label.
marker
class-attribute
instance-attribute
¶
Marker used to paint samples.
name
class-attribute
instance-attribute
¶
name: str = dataclasses.field(default='', init=False)
Attribute name assigned by the component class.