shyft.dashboard.time_series.view_container.figure
Classes
|
Figure class is the view container for a figure |
Exceptions
- exception shyft.dashboard.time_series.view_container.figure.FigureError[source]
Bases:
RuntimeError
- 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, x_range: tuple[int, int] | 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)[source]
Bases:
BaseViewContainer
Figure class is the view container for a figure
Examples
# create the viewer appviewer = TsViewer(bokeh_document=doc, title=’Test Ts Viewer’)# create view containerfigure = Figure(viewer=viewer)# create a data sourcedata_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 containerline_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 sourceds_view_handle = DsViewHandle(data_source=data_source, views=[line_view])# add views and data source to the viewerviewer.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, x_range: tuple[int, int] | 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 [source]
- 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
x_range – selected range of the x-axis e.g. (start=start, end=end)
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
- 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
- add_view(*, view: FigureView) None [source]
This function adds a view to the figure i.e. it will add a corresponding renderer to the figure.
- has_renderer_on_y_axis(y_axis: YAxis) bool [source]
” This function checks if figure has at least one renderer with the given y_axis
- clear_views(*, specific_views: List[FigureView] | None = None) None [source]
This function removes views from figure and clears the renderer
- update_view_data(*, view_data: Dict[FigureView, Quantity[TsVector]]) None [source]
This port function to update plots if the dt in the widget selection box is triggered
- get_idle_renderer(*, view: FigureView) BaseFigureRenderer [source]
This function returns an idle renderer
- generate_renderers(*, renderer_type: Type[BaseFigureRenderer], number: int = 1) List[BaseFigureRenderer] [source]
This function generates new renderers and adds them to bokeh
- add_renderer_to_bokeh(*, new_renderers: List[BaseFigureRenderer]) None [source]
This function adds a new renderer to bokeh figure
- remove_renderer_from_bokeh(*, renderer) None [source]
This function removes a renderer from bokeh figure
- update_title(dt: int | None) None [source]
This function updates the figure title showing the lowest dt int the figure
- draw_figure(y_axis: YAxis | None = None) None [source]
This function triggers redrawing of all renderers in the figure or y axis provided
- update_y_range() None [source]
This function updates the figure y-range according to available data
- next_new_data_update_y_range() None [source]
This function triggers data update for all renderes for the next new data
- add_tool(tool: FigureTool) None [source]
This function adds a FigureTool to the figure