shyft.dashboard.maps.map_layer

Functions

find_tags_from_tooltips(tool_tips)

This function evaluates tooltips for bokeh.Hover for required fields in data source

Classes

MapLayer(*, map_viewer, name, layer_type, ...)

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

Enum defining expected keys to create a bokeh glyph

Exceptions

MapLayerError

exception shyft.dashboard.maps.map_layer.MapLayerError[source]

Bases: RuntimeError

class shyft.dashboard.maps.map_layer.MapLayerType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: Enum

Enum defining expected keys to create a bokeh glyph

Note

  • First variable should be x coordinates

  • Second variable should be y coordinates

POINT = ('x', 'y')
POLYGON = ('xs', 'ys')
LABEL = ('x', 'y', 'text')
shyft.dashboard.maps.map_layer.find_tags_from_tooltips(tool_tips: List[Tuple[str, str]]) Set[str][source]

This function evaluates tooltips for bokeh.Hover for required fields in data source

Parameters:

tool_tips – List of Tuples with 2 strings as defiend in bokeh

Examples

tt = [(“Type”, “@type”),
(“Name”, “@name”)]
find_tags_from_tooltips(tt)
>>> {‘type’, ‘name’}
Return type:

a set of required field names

class shyft.dashboard.maps.map_layer.MapLayer(*, map_viewer: statkraft.bokeh.maps.map_viewer.MapViewer, name: str, layer_type: MapLayerType, glyph_variable_kwargs: Dict[str, str | float | int], glyph_fixed_kwargs: Dict[str, str | float | int], visible: bool = True, selectable: bool = False, update_axes: bool = True, hover_tool_tips: List[Tuple[str, str]] | None = None)[source]

Bases: Bindable, Hashable

__init__(*, map_viewer: statkraft.bokeh.maps.map_viewer.MapViewer, name: str, layer_type: MapLayerType, glyph_variable_kwargs: Dict[str, str | float | int], glyph_fixed_kwargs: Dict[str, str | float | int], visible: bool = True, selectable: bool = False, update_axes: bool = True, hover_tool_tips: List[Tuple[str, str]] | None = None) None[source]

Layer of Map Viewer

Each layer adds a bokeh glyph to the map. The draw order is controlled by the order the layers are created. The type of bokeh glyphs are controlled by the LayerType:

  • LayerType.POINT => Circles

  • nLayerType.POLYGON => Patches

Labels are only supported for LayerType.POINT

Parameters:
  • map_viewer – MapViewer instance to add this layer to

  • name – name of the layer

  • layer_type – type of the layer

  • glyph_variable_kwargs – glyph variable kwargs which are controlled in the data source e.g. {‘xs’: ‘x_values’}

  • glyph_fixed_kwargs – glyph fixed kwargs which are set only by initialisation e.g {‘color’: ‘red’}

  • visible – visibility of the layer at initialisation

  • selectable – if glyphs can be selected with the selection tool

  • update_axes – if the bbox of this layer should be used in MapViewer.figure_axis

  • hover_tool_tips – hover over information

on_bind(*, parent: statkraft.bokeh.maps.map_viewer.MapViewer) None[source]

Function which is call when bound to a figure

property bbox: Tuple[float, float, float, float] | None

returns bounding box of defined geometry i.e x_min, y_min, x_max, y_max if data is defined

check_data_compatibility(new_data: Dict[str, List[str] | List[int] | List[float]]) None[source]

This function checks if new data is compatible with layer :raises LayerError when incompatible:

updated_data(new_data: Dict[str, List[str] | List[int] | List[float]]) None[source]

This function is updates the layer data if proper defined

property visible: bool

Visibility of the glyph