shyft.dashboard.time_series.tools.figure_tools

Classes

Actions(*values)

ActiveScroll(*values)

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

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

Parameters:

logger – optional logger

__init__(logger=None)[source]
Parameters:

logger – optional logger

abstractmethod on_bind(*, parent)[source]

Abstract method which is call on bind to a parent

Parameters:

parent (Any)

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

Bases: FigureTool

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

Parameters:
  • logger – optional logger

  • width (int)

  • height (int)

  • padding (int | None)

  • sizing_mode (str | None)

__init__(width=120, height=30, padding=None, sizing_mode=None, logger=None)[source]
Parameters:
  • logger – optional logger

  • width (int)

  • height (int)

  • padding (int | None)

  • sizing_mode (str | None)

on_bind(*, parent)[source]

Abstract method which is call on bind to a parent

Parameters:

parent (Any)

Return type:

None

on_click()[source]
Return type:

None

property layout_components: Dict[str, List[Any]]
class shyft.dashboard.time_series.tools.figure_tools.ActiveScroll(*values)[source]

Bases: Enum

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

Bases: FigureTool, Widget

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

Parameters:
  • logger – optional logger

  • height (int)

  • width (int)

  • padding (int | None)

  • sizing_mode (str | None)

__init__(height=30, width=140, padding=None, sizing_mode=None, logger=None)[source]
Parameters:
  • logger – optional logger

  • height (int)

  • width (int)

  • padding (int | None)

  • sizing_mode (str | None)

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

Abstract method which is call on bind to a parent

Parameters:

parent (Any)

set_active_scroll(active_scroll)[source]
Parameters:

active_scroll (ActiveScroll)

change_active_scroll(attr, old, new)[source]
Parameters:
  • attr (str)

  • old (int)

  • new (int)

Return type:

None

class shyft.dashboard.time_series.tools.figure_tools.ExportLineDataButton(label='Download Figure Data', height=50, width=150, padding=None, sizing_mode=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

Parameters:
  • logger – optional logger

  • label (str)

  • height (int)

  • width (int)

  • padding (int | None)

  • sizing_mode (str | None)

__init__(label='Download Figure Data', height=50, width=150, padding=None, sizing_mode=None, logger=None)[source]
Parameters:
  • logger – optional logger

  • label (str)

  • height (int)

  • width (int)

  • padding (int | None)

  • sizing_mode (str | None)

on_bind(*, parent)[source]

Abstract method which is call on bind to a parent

Parameters:

parent (Any)

Return type:

None

on_click()[source]
Return type:

None

static js_callback(*, sources, names)[source]

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

Parameters:
  • sources (List[ColumnDataSource])

  • names (List[str])

Return type:

str

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)[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.

Parameters:

hover_tools (List[HoverTool]) – hover tools which are to interact with toggle dropdown.

__init__(hover_tools)[source]
Parameters:

hover_tools (List[HoverTool]) – 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='snap_to_data', tooltips=None, formatters=None, show_arrow=False, mode='mouse', logger=None)[source]

Bases: FigureTool

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

Parameters:
  • point_policy (str) – ‘snap_to_data’ or ‘follow_mouse’

  • tooltips (List[Tuple[str, str]]) – a list of tooltips where each row contains a label, and its associated value

  • formatters (Dict[str, str]) – how the tooltips will be formatted: available formatters: “printf”, “datetime”, and “numeral”

  • show_arrow (bool) – to show the arrow

  • mode (str) – 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

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

  • tooltips (List[Tuple[str, str]]) – a list of tooltips where each row contains a label, and its associated value

  • formatters (Dict[str, str]) – how the tooltips will be formatted: available formatters: “printf”, “datetime”, and “numeral”

  • show_arrow (bool) – to show the arrow

  • mode (str) – 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)[source]

Abstract method which is call on bind to a parent

Parameters:

parent (Any)

register_view_renderer(view, renderer)[source]
Parameters:
remove_renderer(renderer)[source]
Parameters:

renderer (BaseFigureRenderer)

Return type:

None

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

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

__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()[source]
Return type:

str

on_bind(*, parent)[source]

Abstract method which is call on bind to a parent

Parameters:

parent (Any)

Return type:

None

manipulate_period(clicked)[source]
Parameters:

clicked (bool)

Return type:

None

pan_start_event_callback(event)[source]
Parameters:

event (PanStart)

Return type:

None

pan_event_callback(event)[source]
Parameters:

event (Pan)

Return type:

None

set_time_period_restrictions()[source]
Return type:

None

calculate_coordinates(*, y_axis=False)[source]
Parameters:

y_axis (bool)

Return type:

Tuple[ndarray, ndarray, ndarray, ndarray]

update_plot(*, y_axis=False)[source]
Return type:

None

pan_end_event_callback(event)[source]
Parameters:

event (PanEnd)

Return type:

None

update_on_change_y_range(attr, old, new)[source]
Return type:

None

class shyft.dashboard.time_series.tools.figure_tools.ShowTsLabel(label='show label', height=30, width=140, padding=None, sizing_mode=None, logger=None)[source]

Bases: FigureTool, Widget

Hover tool to display the label of a time series.

Parameters:
  • label (the label)

  • height (the height)

  • width (the width)

  • padding (optional padding)

  • sizing_mode (optional sizing mode)

  • logger (optional logger)

__init__(label='show label', height=30, width=140, padding=None, sizing_mode=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)[source]

Abstract method which is call on bind to a parent

Parameters:

parent (Any)

Return type:

None

on_click()[source]
Return type:

None

class shyft.dashboard.time_series.tools.figure_tools.Actions(*values)[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, width=120, height=120, time_zone='Europe/Oslo', color='#b3de69', title='Select time period selector', padding=None, sizing_mode=None, layout_margin=None, logger=None)[source]

Bases: FigureTool, Widget

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

Parameters:
  • logger – optional logger

  • slider_width (int)

  • width (int)

  • height (int)

  • color (str)

  • padding (int | None)

  • sizing_mode (str | None)

  • layout_margin (Tuple[int, int, int, int])

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

  • slider_width (int)

  • width (int)

  • height (int)

  • color (str)

  • padding (int | None)

  • sizing_mode (str | None)

  • layout_margin (Tuple[int, int, int, int])

on_bind(*, parent)[source]

Abstract method which is call on bind to a parent

Parameters:

parent (Any)

Return type:

None

on_click(clicked)[source]
Return type:

None

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

range (Tuple[float, float])

update_title()[source]
Return type:

str

property layout
class shyft.dashboard.time_series.tools.figure_tools.TimeIntervalSelectorSlider(width, title='Time period', time_zone='Europe/Oslo', color='#b3de69', sizing_mode=None, show_value=False, tooltips=False, layout_margin=None, logger=None)[source]

Bases: FigureTool, Widget

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

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)

__init__(width, title='Time period', time_zone='Europe/Oslo', color='#b3de69', sizing_mode=None, show_value=False, tooltips=False, layout_margin=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)[source]

Abstract method which is call on bind to a parent

Parameters:

parent (Any)

Return type:

None

on_click(clicked)[source]
Parameters:

clicked (bool)

Return type:

None

reset_on_click(clicked)[source]
Parameters:

clicked (bool)

Return type:

None

update_slider()[source]
set_slider_range_restrictions()[source]
Return type:

None

set_time_period_restrictions()[source]
Return type:

None

update_selected_area(selected_area)[source]
Parameters:

selected_area (Tuple[float, float])

update_title()[source]
Return type:

str