shyft.dashboard.time_series.view_container.table

Classes

StatisticsTable(*, viewer[, width, height, ...])

Table(*, viewer[, width, height, title, ...])

Table class is the view container for a table

Exceptions

exception shyft.dashboard.time_series.view_container.table.TableError[source]

Bases: RuntimeError

class shyft.dashboard.time_series.view_container.table.Table(*, viewer, width=600, height=600, title='', max_column_width=None, min_column_width=120, visible=True, time_formatter=<function basic_time_formatter>, tools=None, logger=None, alternative_view_time_axis=None)[source]

Bases: BaseViewContainer

Table class is the view container for a table

Examples

# create the viewer app
viewer = TsViewer(bokeh_document=doc, title=’Test Ts Viewer’)

# create view container
table1 = Table(viewer=viewer, tools=[])

# create a data source
data_source = DataSource(ts_adapter=A_time_series_adapter(unit_to_decorate=’MW’), unit=’MW’,
request_time_axis_type=DsViewTimeAxisType.padded_view_time_axis,
time_range=UtcPeriod(start_time, end_time))

# create a view in where we put the view container
table_view = TableView(view_container_uid=table1.uid, columns={0: ‘column 1’, 1: ‘column 2’},
label=’Generic Label’)

# create a handle for the data source and list of views connected to the data source
ds_view_handle = DsViewHandle(data_source=data_source, views=[table_view, line_view, fill_in_between_view])

# add views and data source to the viewer
viewer.add_ds_view_handles(ds_view_handles=[ds_view_handle])
Parameters:
  • viewer (shyft.dashboard.time_series.ts_viewer.TsViewer) – which TsViewer it is connected to

  • width (int) – pixel width of the table

  • height (int) – pixel height of the table

  • title (str) – title of the table

  • max_column_width (int | None) – sets an upper limit of the size of the columns, if None upper = infinite

  • min_column_width (int) – sets a lower limit of the size of the columns

  • visible (bool) – switch for visibility

  • time_formatter (Callable[[Iterable, str], List[str]]) – the time format of the time column

  • tools (List[TableTool] | TableTool) – optional table tools see table tools/table_tools.py

  • logger (logging.Logger | None)

  • alternative_view_time_axis (BaseViewTimeAxis)

__init__(*, viewer, width=600, height=600, title='', max_column_width=None, min_column_width=120, visible=True, time_formatter=<function basic_time_formatter>, tools=None, logger=None, alternative_view_time_axis=None)[source]
Parameters:
  • viewer (shyft.dashboard.time_series.ts_viewer.TsViewer) – which TsViewer it is connected to

  • width (int) – pixel width of the table

  • height (int) – pixel height of the table

  • title (str) – title of the table

  • max_column_width (int | None) – sets an upper limit of the size of the columns, if None upper = infinite

  • min_column_width (int) – sets a lower limit of the size of the columns

  • visible (bool) – switch for visibility

  • time_formatter (Callable[[Iterable, str], List[str]]) – the time format of the time column

  • tools (List[TableTool] | TableTool) – optional table tools see table tools/table_tools.py

  • logger (logging.Logger | None)

  • alternative_view_time_axis (BaseViewTimeAxis)

Return type:

None

property layout: Any

This property returns the preferred layout of the view_container

property layout_components: Dict[str, List[Any]]

This property returns all layout components of the view_container

property visible: bool

This property returns the visibility of the table

add_view(*, view)[source]

This function adds a new view to the view_container

Parameters:

view (TableView)

Return type:

None

update_stored_view_data()[source]

This function only updates the time series who are stored within the view container

update_view_data(*, view_data)[source]

This function updates the table with new data as sent in by view_data

Parameters:

view_data (Dict[TableView, Quantity[TsVector]])

Return type:

None

prepare_data_and_update_data_source(needs_data_source_update=True)[source]

This function prepares all the view data and creates the bokeh data and table columns that should be updated and updates the data source

Parameters:

needs_data_source_update (bool)

update_data_source()[source]

This function updates the data that is to be shown

reset_columns()[source]

This function uses the stored time series and sets all columns but the time column to nothing

reset_data_source()[source]

This function clears the data that bokeh should handle

view_range_callback()[source]

This callback is triggered whenever the view range changes view_range = self.view_time_axis.view_range

Return type:

None

estimate_view_range_indices()[source]

Indices of aligned time, such that i0 <= view range <= i1.

If the overlap of view range and aligned time is zero, no indices are set for view_range_indices (empty list).

Examples:

1)
aligned_time: |t_a0         |t_a1         |t_a2         |t_a3
view range:          |---------------|

# self.view_range_indices = [0, 2]

2)
aligned_time: |t_a0         |t_a1         |t_a2         |t_a3
view range:                                        |---------------|

# self.view_range_indices = [2, 3]

3)
aligned_time: |t_a0         |t_a1         |t_a2         |t_a3
view range:                                             |---------|

# self.view_range_indices = []
Return type:

None

clear()[source]

This function removes all views from the view_container and resets the meta data

Return type:

None

clear_views(*, specific_views=None)[source]

This function removes all or specific views from the view container

Parameters:

specific_views (List[TableView] | None)

Return type:

None

update_title(title)[source]

This function sets the title in the correct <div> format

Parameters:

title (str)

Return type:

None

visible_callback(obj, attr, old_value, new_value)[source]

This function is the callback for when the visibility for table view changes

add_tool(tool)[source]

This function adds a FigureTool to the figure

Parameters:

tool (TableTool)

Return type:

None

class shyft.dashboard.time_series.view_container.table.StatisticsTable(*, viewer, width=600, height=600, title='', name_column_width=300, max_column_width=None, min_column_width=120, visible=True, time_formatter=<function basic_time_formatter>, tools=None, logger=None, alternative_view_time_axis=None)[source]

Bases: Table

Parameters:
  • viewer (shyft.dashboard.time_series.ts_viewer.TsViewer) – which TsViewer it is connected to

  • width (int) – pixel width of the table

  • height (int) – pixel height of the table

  • title (str) – title of the table

  • max_column_width (int | None) – sets an upper limit of the size of the columns, if None upper = infinite

  • min_column_width (int) – sets a lower limit of the size of the columns

  • visible (bool) – switch for visibility

  • time_formatter (Callable[[ndarray, str], List[str]]) – the time format of the time column

  • tools (List[TableTool] | TableTool) – optional table tools see table tools/table_tools.py

  • name_column_width (int)

  • logger (logging.Logger | None)

  • alternative_view_time_axis (BaseViewTimeAxis)

__init__(*, viewer, width=600, height=600, title='', name_column_width=300, max_column_width=None, min_column_width=120, visible=True, time_formatter=<function basic_time_formatter>, tools=None, logger=None, alternative_view_time_axis=None)[source]
Parameters:
  • viewer (shyft.dashboard.time_series.ts_viewer.TsViewer) – which TsViewer it is connected to

  • width (int) – pixel width of the table

  • height (int) – pixel height of the table

  • title (str) – title of the table

  • max_column_width (int | None) – sets an upper limit of the size of the columns, if None upper = infinite

  • min_column_width (int) – sets a lower limit of the size of the columns

  • visible (bool) – switch for visibility

  • time_formatter (Callable[[ndarray, str], List[str]]) – the time format of the time column

  • tools (List[TableTool] | TableTool) – optional table tools see table tools/table_tools.py

  • name_column_width (int)

  • logger (logging.Logger | None)

  • alternative_view_time_axis (BaseViewTimeAxis)

Return type:

None

prepare_data_and_update_data_source(needs_data_source_update=True)[source]

This function prepares all the view data and creates the bokeh data and table columns that should be updated and updates the data source

Parameters:

needs_data_source_update (bool)

update_data_source()[source]

This function updates the data that is to be shown

reset_columns()[source]

This function uses the stored time series and sets all columns but the time column to nothing

view_range_callback()[source]

This callback is triggered whenever the view range changes view_range = self.view_time_axis.view_range

Return type:

None