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, y_axes=None, width=600, height=300, title='', tools=None, x_axis_formatter=None, x_range=None, min_border_top=0, min_border_left=0, min_border_right=0, min_border_bottom=0, show_grid=True, show_x_axis_label=True, text_font='monospace', title_text_font_style='bold', title_text_font_size=10, figure_font_size=10, init_renderers=None, logger=None)[source]¶
Bases:
BaseViewContainerFigure 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]- Parameters:
viewer (shyft.dashboard.time_series.ts_viewer.TsViewer) – the TsViewer this figure belongs to
y_axes (List[YAxis] | YAxis | None) – additional y-axes for this figure
width (int) – width of the figure in pixels
height (int) – height of the figure in pixels
title (str | None) – title of the figure
tools (List[FigureTool] | FigureTool | None) – tools connected to this figure
x_axis_formatter (DatetimeTickFormatter | None) – ticker format of the x-axis
x_range (tuple[int, int] | None) – selected range of the x-axis e.g. (start=start, end=end)
min_border_top (int) – the minimum padding in pixels above the central plotting region
min_border_left (int) – the minimum padding in pixels left of the central plotting region
min_border_right (int) – the minimum padding in pixels right of the central plotting region
min_border_bottom (int) – the minimum padding in pixels below the central plotting region
show_grid (bool) – switch to turn on/off a grid in the figure
show_x_axis_label (bool) – switch to turn on/off label of x-axis
text_font (str) – text font for the figure
title_text_font_style (str) – title text font style (bold, italic, …)
title_text_font_size (int) – title text font size, in pixels
figure_font_size (int) – font size of axes, in pixels
init_renderers (Dict[Type[BaseFigureRenderer], int] | None) – how many of each renderer type to initialise at start
logger (logging.Logger | None)
- __init__(*, viewer, y_axes=None, width=600, height=300, title='', tools=None, x_axis_formatter=None, x_range=None, min_border_top=0, min_border_left=0, min_border_right=0, min_border_bottom=0, show_grid=True, show_x_axis_label=True, text_font='monospace', title_text_font_style='bold', title_text_font_size=10, figure_font_size=10, init_renderers=None, logger=None)[source]¶
- Parameters:
viewer (shyft.dashboard.time_series.ts_viewer.TsViewer) – the TsViewer this figure belongs to
y_axes (List[YAxis] | YAxis | None) – additional y-axes for this figure
width (int) – width of the figure in pixels
height (int) – height of the figure in pixels
title (str | None) – title of the figure
tools (List[FigureTool] | FigureTool | None) – tools connected to this figure
x_axis_formatter (DatetimeTickFormatter | None) – ticker format of the x-axis
x_range (tuple[int, int] | None) – selected range of the x-axis e.g. (start=start, end=end)
min_border_top (int) – the minimum padding in pixels above the central plotting region
min_border_left (int) – the minimum padding in pixels left of the central plotting region
min_border_right (int) – the minimum padding in pixels right of the central plotting region
min_border_bottom (int) – the minimum padding in pixels below the central plotting region
show_grid (bool) – switch to turn on/off a grid in the figure
show_x_axis_label (bool) – switch to turn on/off label of x-axis
text_font (str) – text font for the figure
title_text_font_style (str) – title text font style (bold, italic, …)
title_text_font_size (int) – title text font size, in pixels
figure_font_size (int) – font size of axes, in pixels
init_renderers (Dict[Type[BaseFigureRenderer], int] | None) – how many of each renderer type to initialise at start
logger (logging.Logger | None)
- Return type:
None
- 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)[source]¶
This function adds a view to the figure i.e. it will add a corresponding renderer to the figure.
- Parameters:
view (FigureView)
- Return type:
None
- has_renderer_on_y_axis(y_axis)[source]¶
” This function checks if figure has at least one renderer with the given y_axis
- Parameters:
y_axis (YAxis)
- Return type:
bool
- clear_views(*, specific_views=None)[source]¶
This function removes views from figure and clears the renderer
- Parameters:
specific_views (List[FigureView] | None)
- Return type:
None
- update_view_data(*, view_data)[source]¶
This port function to update plots if the dt in the widget selection box is triggered
- Parameters:
view_data (Dict[FigureView, Quantity[TsVector]])
- Return type:
None
- get_idle_renderer(*, view)[source]¶
This function returns an idle renderer
- Parameters:
view (FigureView)
- Return type:
- generate_renderers(*, renderer_type, number=1)[source]¶
This function generates new renderers and adds them to bokeh
- Parameters:
renderer_type (Type[BaseFigureRenderer])
number (int)
- Return type:
List[BaseFigureRenderer]
- add_renderer_to_bokeh(*, new_renderers)[source]¶
This function adds a new renderer to bokeh figure
- Parameters:
new_renderers (List[BaseFigureRenderer])
- Return type:
None
- remove_renderer_from_bokeh(*, renderer)[source]¶
This function removes a renderer from bokeh figure
- Return type:
None
- set_title(*, title)[source]¶
This function updates the figure meta info
- Parameters:
title (str)
- Return type:
None
- update_title(dt)[source]¶
This function updates the figure title showing the lowest dt int the figure
- Parameters:
dt (int | None)
- Return type:
None
- draw_figure(y_axis=None)[source]¶
This function triggers redrawing of all renderers in the figure or y axis provided
- Parameters:
y_axis (YAxis | None)
- Return type:
None
- update_y_range()[source]¶
This function updates the figure y-range according to available data
- Return type:
None
- next_new_data_update_y_range()[source]¶
This function triggers data update for all renderes for the next new data
- Return type:
None
- add_tool(tool)[source]¶
This function adds a FigureTool to the figure
- Parameters:
tool (FigureTool)
- Return type:
None