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

TableError

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

Bases: RuntimeError

class shyft.dashboard.time_series.view_container.table.Table(*, viewer: shyft.dashboard.time_series.ts_viewer.TsViewer, width: int = 600, height: int = 600, title: str = '', max_column_width: int | None = None, min_column_width: int = 120, visible: bool = True, time_formatter: ~typing.Callable[[~typing.Iterable, str], ~typing.List[str]] = <function basic_time_formatter>, tools: ~typing.List[TableTool] | TableTool = None, logger: logging.Logger | None = None, alternative_view_time_axis: ~shyft.dashboard.time_series.axes_handler.BaseViewTimeAxis = 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])
__init__(*, viewer: shyft.dashboard.time_series.ts_viewer.TsViewer, width: int = 600, height: int = 600, title: str = '', max_column_width: int | None = None, min_column_width: int = 120, visible: bool = True, time_formatter: ~typing.Callable[[~typing.Iterable, str], ~typing.List[str]] = <function basic_time_formatter>, tools: ~typing.List[TableTool] | TableTool = None, logger: logging.Logger | None = None, alternative_view_time_axis: ~shyft.dashboard.time_series.axes_handler.BaseViewTimeAxis = None) None[source]
Parameters:
  • viewer – which TsViewer it is connected to

  • width – pixel width of the table

  • height – pixel height of the table

  • title – title of the table

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

  • min_column_width – sets a lower limit of the size of the columns

  • visible – switch for visibility

  • time_formatter – the time format of the time column

  • tools – optional table tools see table tools/table_tools.py

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: TableView) None[source]

This function adds a new view to the view_container

update_stored_view_data()[source]

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

update_view_data(*, view_data: Dict[TableView, Quantity[TsVector]]) None[source]

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

prepare_data_and_update_data_source(needs_data_source_update: bool = 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

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() None[source]

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

estimate_view_range_indices() None[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 = []
clear() None[source]

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

clear_views(*, specific_views: List[TableView] | None = None) None[source]

This function removes all or specific views from the view container

update_title(title: str) None[source]

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

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: TableTool) None[source]

This function adds a FigureTool to the figure

class shyft.dashboard.time_series.view_container.table.StatisticsTable(*, viewer: shyft.dashboard.time_series.ts_viewer.TsViewer, width: int = 600, height: int = 600, title: str = '', name_column_width: int = 300, max_column_width: int | None = None, min_column_width: int = 120, visible: bool = True, time_formatter: ~typing.Callable[[~numpy.ndarray, str], ~typing.List[str]] = <function basic_time_formatter>, tools: ~typing.List[TableTool] | TableTool = None, logger: logging.Logger | None = None, alternative_view_time_axis: ~shyft.dashboard.time_series.axes_handler.BaseViewTimeAxis = None)[source]

Bases: Table

__init__(*, viewer: shyft.dashboard.time_series.ts_viewer.TsViewer, width: int = 600, height: int = 600, title: str = '', name_column_width: int = 300, max_column_width: int | None = None, min_column_width: int = 120, visible: bool = True, time_formatter: ~typing.Callable[[~numpy.ndarray, str], ~typing.List[str]] = <function basic_time_formatter>, tools: ~typing.List[TableTool] | TableTool = None, logger: logging.Logger | None = None, alternative_view_time_axis: ~shyft.dashboard.time_series.axes_handler.BaseViewTimeAxis = None) None[source]
Parameters:
  • viewer – which TsViewer it is connected to

  • width – pixel width of the table

  • height – pixel height of the table

  • title – title of the table

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

  • min_column_width – sets a lower limit of the size of the columns

  • visible – switch for visibility

  • time_formatter – the time format of the time column

  • tools – optional table tools see table tools/table_tools.py

prepare_data_and_update_data_source(needs_data_source_update: bool = 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

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() None[source]

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