shyft.dashboard.time_series.view_container.figure

Classes

Figure(*, viewer[, y_axes, width, height, ...])

Figure class is the view container for a figure

Exceptions

FigureError

class shyft.dashboard.time_series.view_container.figure.Figure(*, viewer: shyft.dashboard.time_series.ts_viewer.TsViewer, y_axes: List[YAxis] | YAxis | None = None, width: int = 600, height: int = 300, title: str | None = '', tools: List[FigureTool] | FigureTool | None = None, x_axis_formatter: DatetimeTickFormatter | None = None, min_border_top: int = 0, min_border_left: int = 0, min_border_right: int = 0, min_border_bottom: int = 0, show_grid: bool = True, show_x_axis_label: bool = True, text_font: str = 'monospace', title_text_font_style: str = 'bold', title_text_font_size: int = 10, figure_font_size: int = 10, init_renderers: Dict[Type[BaseFigureRenderer], int] | None = None, logger: logging.Logger | None = None)

Bases: BaseViewContainer

Figure class is the view container for a figure

Examples

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

# create view container
figure = Figure(viewer=viewer)

# 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
line_view = Line(view_container=figure, color=”blue”, label=”test line”, unit=”MW”)

# 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=[line_view])

# add views and data source to the viewer
viewer.add_ds_view_handle(ds_view_handles=[ds_view_handle]
__init__(*, viewer: shyft.dashboard.time_series.ts_viewer.TsViewer, y_axes: List[YAxis] | YAxis | None = None, width: int = 600, height: int = 300, title: str | None = '', tools: List[FigureTool] | FigureTool | None = None, x_axis_formatter: DatetimeTickFormatter | None = None, min_border_top: int = 0, min_border_left: int = 0, min_border_right: int = 0, min_border_bottom: int = 0, show_grid: bool = True, show_x_axis_label: bool = True, text_font: str = 'monospace', title_text_font_style: str = 'bold', title_text_font_size: int = 10, figure_font_size: int = 10, init_renderers: Dict[Type[BaseFigureRenderer], int] | None = None, logger: logging.Logger | None = None) None
Parameters:
  • viewer – the TsViewer this figure belongs to

  • y_axes – additional y-axes for this figure

  • width – width of the figure in pixels

  • height – height of the figure in pixels

  • title – title of the figure

  • tools – tools connected to this figure

  • x_axis_formatter – ticker format of the x-axis

  • min_border_top – the minimum padding in pixels above the central plotting region

  • min_border_left – the minimum padding in pixels left of the central plotting region

  • min_border_right – the minimum padding in pixels right of the central plotting region

  • min_border_bottom – the minimum padding in pixels below the central plotting region

  • show_grid – switch to turn on/off a grid in the figure

  • show_x_axis_label – switch to turn on/off label of x-axis

  • text_font – text font for the figure

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

  • title_text_font_size – title text font size, in pixels

  • figure_font_size – font size of axes, in pixels

  • init_renderers – how many of each renderer type to initialise at start

add_renderer_to_bokeh(*, new_renderers: List[BaseFigureRenderer]) None

This function adds a new renderer to bokeh figure

add_tool(tool: FigureTool) None

This function adds a FigureTool to the figure

add_view(*, view: FigureView) None

This function adds a view to the figure i.e. it will add a corresponding renderer to the figure.

clear() None

This function removes all renderers and views from the figure

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

This function removes views from figure and clears the renderer

draw_figure(y_axis: YAxis | None = None) None

This function triggers redrawing of all renderers in the figure or y axis provided

generate_renderers(*, renderer_type: Type[BaseFigureRenderer], number: int = 1) List[BaseFigureRenderer]

This function generates new renderers and adds them to bokeh

get_idle_renderer(*, view: FigureView) BaseFigureRenderer

This function returns an idle renderer

has_renderer_on_y_axis(y_axis: YAxis) bool

” This function checks if figure has at least one renderer with the given y_axis

property layout

This property returns the preferred layout of the figure

property layout_components: Dict[str, List]

This property returns all layout components of the figure

next_new_data_update_y_range() None

This function triggers data update for all renderes for the next new data

remove_renderer_from_bokeh(*, renderer) None

This function removes a renderer from bokeh figure

set_title(*, title: str) None

This function updates the figure meta info

update_title(dt: int | None) None

This function updates the figure title showing the lowest dt int the figure

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

This port function to update plots if the dt in the widget selection box is triggered

update_y_range() None

This function updates the figure y-range according to available data

exception shyft.dashboard.time_series.view_container.figure.FigureError

Bases: RuntimeError