shyft.dashboard.time_series.tools.figure_tools

Classes

Actions(value[, names, module, qualname, ...])

ActiveScroll(value[, names, module, ...])

ExportLineDataButton([label, height, width, ...])

Tool to download all data shown in all figures where this tool is attached to!

FigureTool([logger])

This object represents the base class of all figure tools

HoverTool(*[, point_policy, tooltips, ...])

Tool to display the label, x, and y values of a glyph contained in a figure

HoverToolToggleDropdown(hover_tools)

Tool to toggle the information shown by tooltips.

Modes()

ResetYRange([width, height, padding, ...])

Tool to reset the y-range of a figure to the default view

ShowTsLabel([label, height, width, padding, ...])

Hover tool to display the label of a time series.

TimeIntervalSelectorSlider(width[, title, ...])

Range slider used to select an interval along the time-axis in a given figure

TimePeriodSelectorInFigure([time_zone, logger])

Tool to select a specific time period visually in the view container

TimePeriodSelectorSlider(slider_width[, ...])

Tool to reset the y-range of a figure to the default view

WheelZoomDirection([height, width, padding, ...])

Tool to change the direction of zooming when scrolling the mouse wheel between x and y direction

Exceptions

FigureToolError

exception shyft.dashboard.time_series.tools.figure_tools.FigureToolError[source]

Bases: RuntimeError

class shyft.dashboard.time_series.tools.figure_tools.FigureTool(logger=None)[source]

Bases: BaseTool

This object represents the base class of all figure tools

__init__(logger=None)[source]
Parameters:

logger – optional logger

abstract on_bind(*, parent: Any)[source]

Abstract method which is call on bind to a parent

class shyft.dashboard.time_series.tools.figure_tools.ResetYRange(width: int = 120, height: int = 30, padding: int | None = None, sizing_mode: str | None = None, logger=None)[source]

Bases: FigureTool

Tool to reset the y-range of a figure to the default view

__init__(width: int = 120, height: int = 30, padding: int | None = None, sizing_mode: str | None = None, logger=None)[source]
Parameters:

logger – optional logger

on_bind(*, parent: Any) None[source]

Abstract method which is call on bind to a parent

on_click() None[source]
property layout_components: Dict[str, List[Any]]
class shyft.dashboard.time_series.tools.figure_tools.ActiveScroll(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: Enum

X_axis = 1
Y_axis = 2
class shyft.dashboard.time_series.tools.figure_tools.WheelZoomDirection(height: int = 30, width: int = 140, padding: int | None = None, sizing_mode: str | None = None, logger=None)[source]

Bases: FigureTool, Widget

Tool to change the direction of zooming when scrolling the mouse wheel between x and y direction

__init__(height: int = 30, width: int = 140, padding: int | None = None, sizing_mode: str | None = None, logger=None)[source]
Parameters:

logger – optional logger

property layout: LayoutDOM
property layout_components: Dict[str, List[Any]]

Property to return all layout.dom components of an visualisation app such that they can be arranged by the parent layout obj as desired.

Returns:

layout_components as

Return type:

{‘widgets’: [], ‘figures’: []}

on_bind(*, parent: Any)[source]

Abstract method which is call on bind to a parent

set_active_scroll(active_scroll: ActiveScroll)[source]
change_active_scroll(attr: str, old: int, new: int) None[source]
class shyft.dashboard.time_series.tools.figure_tools.ExportLineDataButton(label: str = 'Download Figure Data', height: int = 50, width: int = 150, padding: int | None = None, sizing_mode: str | None = None, logger=None)[source]

Bases: FigureTool, Widget

Tool to download all data shown in all figures where this tool is attached to!

Two obstacles: - each obj/renderer in a figure has its own data source with own amount of time, value tuples - js callbacks and python callbacks in bokeh are not sync

Therefore: - for each renderer one separate csv file is downloaded - we create a bokeh PreText obj in addition to the download button, to which we attach a js callback for the download after the download the callback is removed again

__init__(label: str = 'Download Figure Data', height: int = 50, width: int = 150, padding: int | None = None, sizing_mode: str | None = None, logger=None)[source]
Parameters:

logger – optional logger

on_bind(*, parent: Any) None[source]

Abstract method which is call on bind to a parent

on_click() None[source]
static js_callback(*, sources: List[ColumnDataSource], names: List[str]) str[source]

Creates js to download all data from multiple data sources to multiple csv files

property layout_components: Dict[str, List[Any]]

Property to return all layout.dom components of an visualisation app such that they can be arranged by the parent layout obj as desired.

Returns:

layout_components as

Return type:

{‘widgets’: [], ‘figures’: []}

property layout: LayoutDOM
class shyft.dashboard.time_series.tools.figure_tools.HoverToolToggleDropdown(hover_tools: List[HoverTool])[source]

Bases: object

Tool to toggle the information shown by tooltips. The three modes are: - info and data - data - no tooltip Info and data should be provided as the default tooltip-mode in the supplied hover tools.

__init__(hover_tools: List[HoverTool])[source]
Parameters:

hover_tools – hover tools which are to interact with toggle dropdown.

callback_hovertool_info(event)[source]
class shyft.dashboard.time_series.tools.figure_tools.HoverTool(*, point_policy: str = 'snap_to_data', tooltips: List[Tuple[str, str]] = None, formatters: Dict[str, str] = None, show_arrow: bool = False, mode: str = 'mouse', logger=None)[source]

Bases: FigureTool

Tool to display the label, x, and y values of a glyph contained in a figure

__init__(*, point_policy: str = 'snap_to_data', tooltips: List[Tuple[str, str]] = None, formatters: Dict[str, str] = None, show_arrow: bool = False, mode: str = 'mouse', logger=None)[source]
Parameters:
  • point_policy – ‘snap_to_data’ or ‘follow_mouse’

  • tooltips – a list of tooltips where each row contains a label, and its associated value

  • formatters – how the tooltips will be formatted: available formatters: “printf”, “datetime”, and “numeral”

  • show_arrow – to show the arrow

  • mode – if ‘mouse’, then only when the mouse is directly over the glyph, if ‘vline’ and ‘hline’: whenever the vertical or horizontal line from the mouse position intersects the glyph

  • logger – the logger

on_bind(*, parent: Any)[source]

Abstract method which is call on bind to a parent

register_view_renderer(view: FigureView, renderer: BaseFigureRenderer)[source]
remove_renderer(renderer: BaseFigureRenderer) None[source]
get_all_hover_tools()[source]
class shyft.dashboard.time_series.tools.figure_tools.TimePeriodSelectorInFigure(time_zone='Europe/Oslo', logger=None)[source]

Bases: FigureTool, Widget

Tool to select a specific time period visually in the view container

__init__(time_zone='Europe/Oslo', logger=None)[source]

All x parameters are in the shyft native coordinates, i.e in epoch time seconds

Parameters:
  • time_zone – time zone to use for period calculations

  • logger – optional logger

property layout: LayoutDOM
property layout_components: Dict[str, List[Any]]

Property to return all layout.dom components of an visualisation app such that they can be arranged by the parent layout obj as desired.

Returns:

layout_components as

Return type:

{‘widgets’: [], ‘figures’: []}

period_to_str() str[source]
on_bind(*, parent: Any) None[source]

Abstract method which is call on bind to a parent

manipulate_period(clicked: bool) None[source]
pan_start_event_callback(event: PanStart) None[source]
pan_event_callback(event: Pan) None[source]
set_time_period_restrictions() None[source]
calculate_coordinates(*, y_axis: bool = False) Tuple[ndarray, ndarray, ndarray, ndarray][source]
update_plot(*, y_axis=False) None[source]
pan_end_event_callback(event: PanEnd) None[source]
update_on_change_y_range(attr, old, new) None[source]
class shyft.dashboard.time_series.tools.figure_tools.ShowTsLabel(label: str = 'show label', height: int = 30, width: int = 140, padding: int | None = None, sizing_mode: str | None = None, logger=None)[source]

Bases: FigureTool, Widget

Hover tool to display the label of a time series.

__init__(label: str = 'show label', height: int = 30, width: int = 140, padding: int | None = None, sizing_mode: str | None = None, logger=None)[source]
Parameters:
  • label (the label) –

  • height (the height) –

  • width (the width) –

  • padding (optional padding) –

  • sizing_mode (optional sizing mode) –

  • logger (optional logger) –

property layout: LayoutDOM
property layout_components: Dict[str, List[Any]]

Property to return all layout.dom components of an visualisation app such that they can be arranged by the parent layout obj as desired.

Returns:

layout_components as

Return type:

{‘widgets’: [], ‘figures’: []}

on_bind(*, parent: Any) None[source]

Abstract method which is call on bind to a parent

on_click() None[source]
class shyft.dashboard.time_series.tools.figure_tools.Actions(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: Enum

freeze = 0
move = 1
extend_right = 2
extend_left = 3
class shyft.dashboard.time_series.tools.figure_tools.Modes[source]

Bases: object

fixed_dt = 'Fixed dt'
snap_to_dt = 'Snap to dt'
free_range = 'Free range'
class shyft.dashboard.time_series.tools.figure_tools.TimePeriodSelectorSlider(slider_width: int, width: int = 120, height: int = 120, time_zone='Europe/Oslo', color: str = '#b3de69', title='Select time period selector', padding: int | None = None, sizing_mode: str | None = None, layout_margin: Tuple[int, int, int, int] = None, logger=None)[source]

Bases: FigureTool, Widget

Tool to reset the y-range of a figure to the default view

__init__(slider_width: int, width: int = 120, height: int = 120, time_zone='Europe/Oslo', color: str = '#b3de69', title='Select time period selector', padding: int | None = None, sizing_mode: str | None = None, layout_margin: Tuple[int, int, int, int] = None, logger=None)[source]
Parameters:

logger – optional logger

on_bind(*, parent: Any) None[source]

Abstract method which is call on bind to a parent

on_click(clicked) None[source]
property layout_components: Dict[str, List[Any]]

Property to return all layout.dom components of an visualisation app such that they can be arranged by the parent layout obj as desired.

Returns:

layout_components as

Return type:

{‘widgets’: [], ‘figures’: []}

update_selected_area(range: Tuple[float, float])[source]
update_title() str[source]
property layout
class shyft.dashboard.time_series.tools.figure_tools.TimeIntervalSelectorSlider(width: int, title: str = 'Time period', time_zone: str = 'Europe/Oslo', color: str = '#b3de69', sizing_mode: str | None = None, show_value: bool = False, tooltips: bool = False, layout_margin: Tuple[int, int, int, int] = None, logger=None)[source]

Bases: FigureTool, Widget

Range slider used to select an interval along the time-axis in a given figure

__init__(width: int, title: str = 'Time period', time_zone: str = 'Europe/Oslo', color: str = '#b3de69', sizing_mode: str | None = None, show_value: bool = False, tooltips: bool = False, layout_margin: Tuple[int, int, int, int] = None, logger=None)[source]
Parameters:
  • width (width of the slider) –

  • title (slider title) –

  • time_zone (time zone to use for period calculations, default: 'Europe/Oslo') –

  • color (color of the box (selected area)) –

  • sizing_mode (the mode used for the items of slider to resize to fill the available space) –

  • show_value (show the the value of slider along the title) –

  • tooltips (slider tooltips) –

  • layout_margin (margin) –

  • logger (optional logger) –

property layout_components: Dict[str, List[Any]]

Property to return all layout.dom components of an visualisation app such that they can be arranged by the parent layout obj as desired.

Returns:

layout_components as

Return type:

{‘widgets’: [], ‘figures’: []}

property layout
on_bind(*, parent: Any) None[source]

Abstract method which is call on bind to a parent

on_click(clicked: bool) None[source]
reset_on_click(clicked: bool) None[source]
update_slider()[source]
set_slider_range_restrictions() None[source]
set_time_period_restrictions() None[source]
update_selected_area(selected_area: Tuple[float, float])[source]
update_title() str[source]