_bokeh_manipulation Module#

_bokeh_manipulation Module#

Here there are all sorts of Bokeh related manipulations, but most dominantly custom jslink.

There are multiple functions in here that set some JS properties of Bokeh JS elements in order to “communicate” between those jslinks, for example the color of the current time cursor is communicated through the bright “played” region.
At times these are confusing, this is a work in progress and will get better as we learn :)
Adds custom jslink interactivity.

Parameters#

player_bokehbokeh.model.Model

.

stay_colorstr

.

follow_colorstr

.

plotsList[bokeh.model.Model]

Bokeh plots for the spectrograms and progress bar

vlinesList[bokeh.model.Model]

Bokeh elements for current time cursors

vspansList[bokeh.model.Model]

Bokeh elements that brighten the section played so far

glyphsList[bokeh.model.Model]

Bokeh elements for play icons and the progress bar circular handle

Returns#

player_bokehbokeh.model.Model

With custom jslink interactivity


waloviz._bokeh_manipulation.apply_theme(plot: Model, theme: Dict[str, Any], theme_elements_mapping: Dict[str, str]) None[source]#
Manually sets theme values of a plot.

Parameters#

plot : bokeh.model.Model

theme : Dict[str, Any]

theme_elements_mappingDict[str, str]

A mapping between theme keys and plot attributes


waloviz._bokeh_manipulation.finalize_player_bokeh_gui(player_bokeh: Model, theme: Dict[str, Any], total_seconds: float, stay_color: str, follow_color: str, aspect_ratio: Optional[float], sizing_mode: Optional[str], single_min_height: int) Model[source]#
Modify bokeh settings and adds custom jslink interactivity.

Parameters#

player_bokehbokeh.model.Model

As rendered by HoloViews

theme : Dict[str, Any]

total_seconds : float

stay_color : str

follow_color : str

aspect_ratio : float | None

single_min_height : int

Returns#

player_bokehbokeh.model.Model

With modifications and custom jslink interactivity


waloviz._bokeh_manipulation.get_audio_xformatter(total_seconds: float) CustomJSTickFormatter[source]#
Create a relative time tick formatter, with dynamic resolution from days up to milliseconds.

Parameters#

total_seconds : float

Returns#

xformatterCustomJSTickFormatter

Relative time tick formatter.


waloviz._bokeh_manipulation.get_follow_callback(plot: Model, vspan: Model) CustomJS[source]#
Create a jslink callback which updates the x range when in “follow” mode.

Parameters#

plotbokeh.model.Model

The current plot

vspansList[bokeh.model.Model]

Bokeh elements that brighten the section played so far

Returns#

follow_callbackCustomJS

A jslink callback.


waloviz._bokeh_manipulation.get_keep_dump_range_callback(plot: Model) CustomJS[source]#
Create a jslink callback which keeps the ‘_dump’ y axis between 0 and 1.
The ‘_dump’ axis is used for the play and stop icons as well as the progress bar handle.

Parameters#

plotbokeh.model.Model

The current plot

Returns#

keep_dump_range_callbackCustomJS

A jslink callback.


waloviz._bokeh_manipulation.get_keep_x_range_callback(plot: Model, plots: List[Model]) CustomJS[source]#
Create a jslink callback which keeps the constant x range when the mouse is over the progress bar.
Uses is_x_fixed , x_fixed_range.start and x_fixed_range.end of the zeroth plot (first spectrogram).

Parameters#

plotbokeh.model.Model

The current plot

plotsList[bokeh.model.Model]

Bokeh plots for the spectrograms and progress bar

Returns#

keep_x_range_callbackCustomJS

A jslink callback.


waloviz._bokeh_manipulation.get_keep_y_range_callback(plot: Model, plots: List[Model]) CustomJS[source]#
Create a jslink callback which keeps the constant y range when the mouse is over the spectrograms.
Uses is_y_fixed , hz_fixed_range.start and hz_fixed_range.end of the zeroth plot (first spectrogram).

Parameters#

plotbokeh.model.Model

The current plot

plotsList[bokeh.model.Model]

Bokeh plots for the spectrograms and progress bar

Returns#

keep_y_range_callbackCustomJS

A jslink callback.


waloviz._bokeh_manipulation.get_move_pbar_callback(vspans: List[Model], plots: List[Model]) CustomJS[source]#
Create a jslink callback which moves the current time to the mouse position when the mouse is over the progress bar.

Parameters#

vspansList[bokeh.model.Model]

Bokeh elements that brighten the section played so far

plotsList[bokeh.model.Model]

Bokeh plots for the spectrograms and progress bar

Returns#

move_pbar_callbackCustomJS

A jslink callback.


waloviz._bokeh_manipulation.get_move_time_callback(vspans: List[Model], plots: List[Model]) CustomJS[source]#
Create a jslink callback which moves the current time to the mouse position.
Used when double clicking.

Parameters#

vspansList[bokeh.model.Model]

Bokeh elements that brighten the section played so far

plotsList[bokeh.model.Model]

Bokeh plots for the spectrograms and progress bar

Returns#

move_time_callbackCustomJS

A jslink callback.


waloviz._bokeh_manipulation.get_play_pause_callback(plots: List[Model], glyphs: List[Model]) CustomJS[source]#
Create a jslink callback which toggles play\pause when the mouse is over the spectrograms.
Makes the zeroth glyph (first spectrogram play icon) visible.

Parameters#

plotsList[bokeh.model.Model]

Bokeh plots for the spectrograms and progress bar

glyphsList[bokeh.model.Model]

Bokeh elements for play icons and the progress bar circular handle

Returns#

play_pause_callbackCustomJS

A jslink callback.


waloviz._bokeh_manipulation.get_record_ranges_callback(plots: List[Model]) CustomJS[source]#
Create a jslink callback which records the previous ranges, important for following and zooming on x axis only.
Saves prev_x_range and prev_y_range in the zeroth plot (first spectrogram).

Parameters#

plotsList[bokeh.model.Model]

Bokeh plots for the spectrograms and progress bar

Returns#

record_ranges_callbackCustomJS

A jslink callback.


waloviz._bokeh_manipulation.get_reset_callback(plot: Model, plots: List[Model]) CustomJS[source]#
Create a jslink callback which updates saved values to their presets.

Parameters#

plotbokeh.model.Model

The current plot

plotsList[bokeh.model.Model]

Bokeh plots for the spectrograms and progress bar

Returns#

reset_callbackCustomJS

A jslink callback.


waloviz._bokeh_manipulation.get_set_pbar_x_range_callback(plot: Model, plots: List[Model]) CustomJS[source]#
Create a jslink callback which stops the x zoom by setting a constant x range when the mouse is over the progress bar.
Sets is_x_fixed , x_fixed_range.start and x_fixed_range.end of the zeroth plot (first spectrogram).

Parameters#

plotbokeh.model.Model

The current plot

plotsList[bokeh.model.Model]

Bokeh plots for the spectrograms and progress bar

Returns#

set_pbar_x_range_callbackCustomJS

A jslink callback.


waloviz._bokeh_manipulation.get_set_y_range_callback(plot: Model, plots: List[Model]) CustomJS[source]#
Create a jslink callback which stops the y zoom by setting a constant y range when the mouse is over the spectrograms.
Sets is_y_fixed , hz_fixed_range.start and hz_fixed_range.end of the zeroth plot (first spectrogram).

Parameters#

plotbokeh.model.Model

The current plot

plotsList[bokeh.model.Model]

Bokeh plots for the spectrograms and progress bar

Returns#

set_y_range_callbackCustomJS

A jslink callback.


waloviz._bokeh_manipulation.get_start_follow_callback(follow_color: str, vspans: List[Model], plots: List[Model]) CustomJS[source]#
Create a jslink callback which activates “follow” mode.
Saves is_following to the zeroth vspan (first spectrogram bright section).
Also used to synchronize the vline follow color with the vspan line_color .

Parameters#

follow_colorList[bokeh.model.Model]

The color of the vlines when in “follow” mode

vspansList[bokeh.model.Model]

Bokeh elements that brighten the section played so far

plotsList[bokeh.model.Model]

Bokeh plots for the spectrograms and progress bar

Returns#

start_follow_callbackCustomJS

A jslink callback.


waloviz._bokeh_manipulation.get_stop_follow_callback(stay_color: str, vspans: List[Model]) CustomJS[source]#
Create a jslink callback which activates “stay” mode, stops “follow” mode.
Sets is_following of the zeroth vspan (first spectrogram bright section).
Also used to synchronize the vline stay color with the vspan line_color .

Parameters#

stay_colorList[bokeh.model.Model]

The color of the vlines when in “stay” mode

vspansList[bokeh.model.Model]

Bokeh elements that brighten the section played so far

Returns#

stop_follow_callbackCustomJS

A jslink callback.


waloviz._bokeh_manipulation.modify_bokeh_elements(player_bokeh: Model, theme: Dict[str, Any], total_seconds: float, aspect_ratio: Optional[float], sizing_mode: Optional[str], single_min_height: int, plots: List[Model], vlines: List[Model], vspans: List[Model], glyphs: List[Model]) Model[source]#
Adds custom jslink interactivity.

Parameters#

player_bokehbokeh.model.Model

.

themeDict[str, Any]

.

total_secondsfloat

.

aspect_ratiofloat | None

.

sizing_modestr | None

.

single_min_heightint

.

plotsList[bokeh.model.Model]

Bokeh plots for the spectrograms and progress bar

vlinesList[bokeh.model.Model]

Bokeh elements for current time cursors

vspansList[bokeh.model.Model]

Bokeh elements that brighten the section played so far

glyphsList[bokeh.model.Model]

Bokeh elements for play icons and the progress bar circular handle

Returns#

player_bokehbokeh.model.Model

With manual modifications