shyft.dashboard.time_series.ts_viewer
Classes
|
TsViewer class is the main class combining all components to view time series in bokeh. |
Exceptions
- class shyft.dashboard.time_series.ts_viewer.TsViewer(*, bokeh_document: Document, title: str | None = '', state: States | None = States.ACTIVE, width: int | None = 150, height: int | None = None, padding: int | None = None, sizing_mode: str | None = None, time_step_restrictions: List[int | float] | ndarray | None = None, zoom_in_interval: int | float | None = None, zoom_out_interval: int | float | None = None, init_view_range: UtcPeriod = None, auto_dt_multiple: int | None = None, thread_pool_executor: ThreadPoolExecutor | None = None, add_dt_selector: bool = True, logger: Logger | None = None, unit_registry: UnitRegistry | None = None, tools: List[TsViewerTool] = None, time_zone: str | None = None, reset_time_axis: bool = True, full_view: bool = True, should_wait_async_view_data: bool = False)[source]
Bases:
object
TsViewer class is the main class combining all components to view time series in bokeh.
Different ViewContainer (As figures, tables) can be added to the viewer.
Examples
# create our viewer appviewer = TsViewer()# create view containertable1 = Table(viewer=viewer)fig1 = Figure(viewer=viewer)All view container will be bound to the same time axis, controlled by a TimeAxisHandler. (i.e. linked x axis of all figures)
To view time series data one need to define the data or how it can be retrieved with a DataSource. In addition one need to define the View(s), i.e. how the data should be visualised in the different ViewContainer. For convenience, book-keeping and easy messaging between apps is the combination of a DataSource and a List[Views] defined as an ds_view_handle.
Examples (continued)
# define data sourcedata_source = DataSource(ts_adapter=”TsAdapter”, unit=’MW’)# define viewspercentile_view = PercentileView(view_container_uid=fig1.uid)table_view = TableView(view_container_uid=table1.uid)# add it to the viewerds_view_handle = viewer.create_ds_view_handle(data_source=data_source,views=[percentile_view, table_view])# OR create an ds_view_handle and add it to the viewerdsviehandle = DsViewHandle(data_source=data_source,views=[percentile_view, table_view])viewer.add_ds_view_handle(ds_view_handle)# OR send it using the port function (takes a List[DsViewHandles])viewer.receive_ds_view_handles_to_add([ds_view_handle])# the ds_view_handle can be removed byviewer.remove_ds_view_handle(ds_view_handle)# OR using the port function (takes a List[DsViewHandles])viewer.receive_ds_view_handles_to_remove([ds_view_handle])- __init__(*, bokeh_document: Document, title: str | None = '', state: States | None = States.ACTIVE, width: int | None = 150, height: int | None = None, padding: int | None = None, sizing_mode: str | None = None, time_step_restrictions: List[int | float] | ndarray | None = None, zoom_in_interval: int | float | None = None, zoom_out_interval: int | float | None = None, init_view_range: UtcPeriod = None, auto_dt_multiple: int | None = None, thread_pool_executor: ThreadPoolExecutor | None = None, add_dt_selector: bool = True, logger: Logger | None = None, unit_registry: UnitRegistry | None = None, tools: List[TsViewerTool] = None, time_zone: str | None = None, reset_time_axis: bool = True, full_view: bool = True, should_wait_async_view_data: bool = False) None [source]
- Parameters:
bokeh_document – the bokeh document it belongs to
title – title of the app
time_step_restrictions – list of time step restrictions
zoom_in_interval – the minimum visible interval
zoom_out_interval – the maximum visible interval
init_view_range – the period which should be the default period
auto_dt_multiple – sets the lowest resolution of the time series
thread_pool_executor – the thread pool executor used for async requests
add_dt_selector – switch to add a time step selector tool
logger – python logger
unit_registry – the unit registry used in the app
tools – list of tools to be part of the TsViewer
state – the initial state
full_view – if set to true, the time-series are not clipped to t_now (should be the default!)
- property layout: column | None
- trigger_data_update() None [source]
This function triggers the reloading of the sources with data, each source is requested for data currently that will result in a call to the function above, request_time_axis(min_dt, data_time_range) to get back a time-axis that is fitted to the current view-range and auto/dt selection .. and the particular data-source limitations min_dt, and data_time_range. (possibly in background thread) and when done they will eventually call the trigger_view_update(…) with the new data.
- TODO: consider passing the current view_range, cal,delta-t .. that is: the view-timeaxis(padded or not)
down to the source so that it can make it’s own choices. That helps a lot..
- source_starting_async_data_update(source: Source)[source]
This function must be called by the source before starting an asynchronous data update operation.
- source_completed_async_data_update(source: Source)[source]
This function must be called by the source after its asynchronous data update.
- trigger_view_update(view_data: Dict[BaseView, Quantity[TsVector]]) None [source]
This function triggers the updating of the views, with given data, it’s usually called by the data-sources when they are finished extracting data from the TsAdapters.
This function merely dispatches the received values to the view-containers that performs the presentation.
- add_view_container(view_container: BaseViewContainer) None [source]
This functions adds a view container to the TsViewer and assignes an uid to the view container
- Raises:
BindableError if view container is already bound to a TsViewer –
- remove_view_container(view_container: BaseViewContainer) None [source]
This functions removes a view container from the TsViewer.
- Raises:
BindableError if view container is is not bound to the TsViewer –
- connect_to_dt_selector(receive_dt: Receiver) None [source]
This function connects the a receiver port to receive the current dt to the dt selector box if available.
- add_ds_view_handles(ds_view_handles: List[DsViewHandle]) None [source]
This function add new ds_view_handles to the TsViewer
- Parameters:
ds_view_handles – ds_view_handles defining data source and views of the data
- remove_ds_view_handles(ds_view_handles: List[DsViewHandle]) None [source]
This function remove ds_view_handles from the TsViewer
- Parameters:
ds_view_handles – ds_view_handles defining data source and views of the data
- add_tool(tool: TsViewerTool) None [source]
- set_layout(layout: List[BaseViewContainer] | List[List[BaseViewContainer]] | Dict[str, BaseViewContainer]) None [source]
Function to quickly define a layout
Use List[ViewContainer] -> columns Use List[List[ViewContainer]] -
- Parameters:
layout –
- property layout_components
This property returns all layout components of the all sub components