shyft.dashboard.time_series.view_container.legend

Classes

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

class shyft.dashboard.time_series.view_container.legend.Legend(*, viewer, title='', width=200, height=300, text_font_size=8, text_font='verdana', title_text_font_style='bold', title_text_font_size='10pt', logger=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])
Parameters:
  • viewer (shyft.dashboard.time_series.ts_viewer.TsViewer) – the TsViewer this legend belongs to

  • title (str | None) – legend title text

  • width (int) – pixel width of the legend box

  • height (int) – pixel height of the legend box

  • text_font_size (int) – text font size for legend items

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

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

  • title_text_font_size (str) – text font size for legend title

  • logger (LoggerBox | None) – optional logger or LoggerBox instance

__init__(*, viewer, title='', width=200, height=300, text_font_size=8, text_font='verdana', title_text_font_style='bold', title_text_font_size='10pt', logger=None)[source]
Parameters:
  • viewer (shyft.dashboard.time_series.ts_viewer.TsViewer) – the TsViewer this legend belongs to

  • title (str | None) – legend title text

  • width (int) – pixel width of the legend box

  • height (int) – pixel height of the legend box

  • text_font_size (int) – text font size for legend items

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

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

  • title_text_font_size (str) – text font size for legend title

  • logger (LoggerBox | None) – optional logger or LoggerBox instance

Return type:

None

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

This function adds a new view to the view_container

Parameters:

view (LegendItem)

Return type:

None

label_callback(obj, attr, old_value, new_value)[source]
Return type:

None

update_view_data(*, view_data)[source]

This function updates the views with new data

Parameters:

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

Return type:

None

clear()[source]

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

Return type:

None

clear_views(*, specific_views=None)[source]

This function removes all or specific views from the view_container

Parameters:

specific_views (List[LegendItem] | None)

Return type:

None

update_data_source()[source]

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

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

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

Return type:

None

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

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

Return type:

None