Number
Number shows one number of its source, big: the latest, or an aggregate over a window, see Aggregating.
import dachshund
from dachshund.widgets import Number
with dachshund.row():
dachshund.add(Number("cpu", title="CPU Load", unit="%"))
dachshund.emit("cpu", value=42)
dachshund.widgets.number.number.Number
dataclass
Number(name, *, source='', title=None, actions=list(), action_args=dict(), persist=False, y='value', aggregate='last', over=None, unit=None)
Bases: AggregatedWidget
One number of its source, shown big: the latest, or an aggregate over a window.
Example
with dachshund.row():
dachshund.add(Number("cpu", title="CPU Load", unit="%"))
dachshund.add(Number("requests", aggregate="count", over=timedelta(hours=1)))
dachshund.emit("cpu", value=42)
Options
y(str) - The field read. Defaults to"value".aggregate(str) -"last"for the latest number, or"count","sum","average","min","max"or"distinct"overover. Defaults to"last". See Aggregating.over(timedelta | str) - The window: atimedeltaback from now, or the current"day","week"or"month"in the dashboard'stimezone. Defaults toNone, everything stored. Not for"last".unit(str) - Shown next to the number, as is. Defaults toNone.persist(bool) - Keeps the latest number across restarts, for"last"only. Needs the dashboard'sstorage. Defaults toFalse.
unit
class-attribute
instance-attribute
unit = None
type
class-attribute
type = 'number'
op
class-attribute
op = 'replace'
script
class-attribute
script = Path(__file__).parent / 'number.js'
style
class-attribute
style = Path(__file__).parent / 'number.css'
render_value
render_value(value)
Source code in dachshund/widgets/number/number.py
44 45 | |