shyft.dashboard.time_series.view_container.legend

Classes

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

Examples

class shyft.dashboard.time_series.view_container.legend.Legend(*, viewer: shyft.dashboard.time_series.ts_viewer.TsViewer, title: str | None = '', width: int = 200, height: int = 300, text_font_size: int = 8, text_font: str = 'verdana', title_text_font_style: str = 'bold', title_text_font_size: str = '10pt', logger: LoggerBox | None = None)[source]

Bases: BaseViewContainer

Examples

# create the viewer app
viewer = TsViewer(bokeh_document=doc, title=’Example Ts Viewer’)
# create the view container
figure = Figure(viewer=viewer)
# create the legend container
legend = Legend(viewer=viewer)
# set up a data source
data_source = DataSource(ts_adapter=TsAdapter(), unit=’MW’)
# create views
fill_in_between = FillInBetween(view_container=figure, color=’purple’, label=’Example Percentile’, unit=’MW’,
indices=(0, 1))
line = Line(view_container=figure, color=’blue’, unit=’MW’, label=’Example Line’, index=1)
# add views to a legend item
legend_item = LegendItem(view_container=legend, label=’Example Legend Item’, views=[line, fill_in_between])
# add data source and views to a DsViewHandle
ds_view_handle = DsViewHandle(data_source=data_source, views=[line, fill_in_between, legend_item])
__init__(*, viewer: shyft.dashboard.time_series.ts_viewer.TsViewer, title: str | None = '', width: int = 200, height: int = 300, text_font_size: int = 8, text_font: str = 'verdana', title_text_font_style: str = 'bold', title_text_font_size: str = '10pt', logger: LoggerBox | None = None) None[source]
Parameters:
  • viewer – the TsViewer this legend belongs to

  • title – legend title text

  • width – pixel width of the legend box

  • height – pixel height of the legend box

  • text_font_size – text font size for legend items

  • text_font – text font for legend items (options: ‘monospace’,’verdana’, ‘times’, ‘helvetica’, etc.)

  • title_text_font_style – text font style (bold, italic, …) for legend title

  • title_text_font_size – text font size for legend title

  • logger – optional logger or LoggerBox instance

property layout

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

add_view(*, view: LegendItem) None[source]

This function adds a new view to the view_container

label_callback(obj, attr, old_value, new_value) None[source]
update_view_data(*, view_data: Dict[LegendItem, Quantity[TsVector]]) None[source]

This function updates the views with new data

clear() None[source]

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

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

This function removes all or specific views from the view_container

update_data_source()[source]

This function updates the legend data source and shows the legend items

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

This function triggers the in change callback for visible attribute in legend_views

expand_callback(obj, attr, old_value, new_value) None[source]

This function triggers the in change callback for visible attribute in legend_views