shyft.dashboard.time_series.view_time_axes

Functions

create_view_time_axis(*, cal, view_period, ...)

Creates a time axis with the range of the view_period, that snaps to the calendar resolution of dt.

period_union(p1, p2)

Classes

ViewTimeAxisProperties(*, dt, cal, ...)

At the view-level, describes the visual-wanted properties of the time-series data to be presented.

shyft.dashboard.time_series.view_time_axes.create_view_time_axis(*, cal: Calendar, view_period: UtcPeriod, clip_period: UtcPeriod, dt: time) TimeAxis[source]

Creates a time axis with the range of the view_period, that snaps to the calendar resolution of dt.

An empty TimeAxis() is returned if:
  • no overlap

  • overlap period contains -oo or +oo

  • dt is zero

Parameters:
  • cal (Calendar to use for calendar semantic trim/add if dt >= DAY)

  • view_period (the visual view-period)

  • clip_period (if a valid clip_period is specified, the time axis will clipped to this period)

  • dt (time step of the time axis)

Returns:

time_axis

Return type:

TimeAxis. Axis type is Fixed if dt < DAY (optimization), else Calendar.

shyft.dashboard.time_series.view_time_axes.period_union(p1: UtcPeriod, p2: UtcPeriod) UtcPeriod[source]
class shyft.dashboard.time_series.view_time_axes.ViewTimeAxisProperties(*, dt: time, cal: Calendar, view_period: UtcPeriod, padded_view_period: UtcPeriod, extend_mode: bool)[source]

Bases: object

At the view-level, describes the visual-wanted properties of the time-series data to be presented. The class have no logic, just group together properties that give a consistent view of current ‘view-port’.

The data-source can use this information to adapt it’s call to the underlying TsAdapter(time-axis,unit)->tsvector so that it is optimal with respect to performance, as well as visualization.

dt
Type:

time-step for aggregation/average, like hour, day, week etc.

cal
Type:

calendar for calendar semantic steps, so the time-steps dt are in multiple of dt, rounded to calendar

view_period
Type:

the current entire view-period (usually also rounded to whole calendar/dt)

padded_view_period
Type:

a period greater/equal to the view-period, to allow for smooth pan/scrolling

extend_mode
Type:

if True, the data-source should ensure to include its own min/max range using the extend_time_axis method

__init__(*, dt: time, cal: Calendar, view_period: UtcPeriod, padded_view_period: UtcPeriod, extend_mode: bool)[source]