holoviews.plotting.plotly.dash module#

class holoviews.plotting.plotly.dash.DashComponents(graphs, kdims, store, resets, children)#

Bases: tuple

children#

Alias for field number 4

graphs#

Alias for field number 0

kdims#

Alias for field number 1

resets#

Alias for field number 3

store#

Alias for field number 2

class holoviews.plotting.plotly.dash.HoloViewsFunctionSpec(fn, kdims, streams)#

Bases: tuple

fn#

Alias for field number 0

kdims#

Alias for field number 1

streams#

Alias for field number 2

class holoviews.plotting.plotly.dash.StreamCallback(input_ids, fn, output_id)#

Bases: tuple

fn#

Alias for field number 1

input_ids#

Alias for field number 0

output_id#

Alias for field number 2

holoviews.plotting.plotly.dash.build_derived_callback(derived_stream)[source]#

Build StreamCallback for Derived stream

Parameters:
derived_stream

A Derived stream

Returns:
StreamCallback
holoviews.plotting.plotly.dash.build_history_callback(history_stream)[source]#

Build StreamCallback for History stream

Parameters:
history_stream

A History stream

Returns:
StreamCallback
holoviews.plotting.plotly.dash.decode_store_data(store_data)[source]#

Decode a dict that was encoded by the encode_store_data function.

Parameters:
store_datadict that was encoded by encode_store_data
Returns:
decoded dict
holoviews.plotting.plotly.dash.encode_store_data(store_data)[source]#

Encode store_data dict into a JSON serializable dict

This is currently done by pickling store_data and converting to a base64 encoded string. If HoloViews supports JSON serialization in the future, this method could be updated to use this approach instead

Parameters:
store_datadict potentially containing HoloViews objects
Returns:
dict that can be JSON serialized
holoviews.plotting.plotly.dash.plot_to_figure(plot, reset_nclicks=0, layout_ranges=None, responsive=True, use_ranges=True)[source]#

Convert a HoloViews plotly plot to a plotly.py Figure.

Parameters:
plotA HoloViews plotly plot object
reset_nclicksint

Number of times a reset button associated with the plot has been clicked

Returns:
A plotly.py Figure
holoviews.plotting.plotly.dash.populate_store_with_stream_contents(store_data, streams)[source]#

Add contents of streams to the store dictionary

Parameters:
store_data

The store dictionary

streams

List of streams whose contents should be added to the store

Returns:
None
holoviews.plotting.plotly.dash.populate_stream_callback_graph(stream_callbacks, streams)[source]#

Populate the stream_callbacks dict with StreamCallback instances associated with all of the History and Derived streams in input stream list.

Input streams to any History or Derived streams are processed recursively

Parameters:
stream_callbacks

dict from id(stream) to StreamCallbacks that should be populated. Order will be a breadth-first traversal of the provided streams list, and any input streams that these depend on.

streams

List of streams to build StreamCallbacks from

Returns:
None
holoviews.plotting.plotly.dash.to_dash(app, hvobjs, reset_button=False, graph_class=dash.dcc.Graph, button_class=dash.html.Button, responsive='width', use_ranges=True)[source]#

Build Dash components and callbacks from a collection of HoloViews objects

Parameters:
appdash.Dash application instance
hvobjs

List of HoloViews objects to build Dash components from

reset_buttonbool

If True, construct a Button component that, when clicked, will reset the interactive stream values associated with the provided HoloViews objects to their initial values. Defaults to False.

graph_class

Class to use when creating Graph components, one of dcc.Graph (default) or ddk.Graph.

button_class

Class to use when creating reset button component. E.g. html.Button (default) or dbc.Button

responsivebool, str

If True graphs will fill their containers width and height responsively. If False, graphs will have a fixed size matching their HoloViews size. If “width” (default), the width is responsive but height matches the HoloViews size. If “height”, the height is responsive but the width matches the HoloViews size.

use_rangesbool

If True, initialize graphs with the dimension ranges specified in the HoloViews objects. If False, allow Dash to perform its own auto-range calculations.

Returns:
DashComponents named tuple with properties:
  • graphs: List of graph components (with type matching the input

    graph_class argument) with order corresponding to the order of the input hvobjs list.

  • resets: List of reset buttons that can be used to reset figure state.

    List has length 1 if reset_button=True and is empty if reset_button=False.

  • kdims: Dict from kdim names to Dash Components that can be used to

    set the corresponding kdim value.

  • store: dcc.Store the must be included in the app layout

  • children: Single list of all components above. The order is graphs,

    kdims, resets, and then the store.

holoviews.plotting.plotly.dash.to_function_spec(hvobj)[source]#

Convert Dynamic HoloViews object into a pure function that accepts kdim values and stream contents as positional arguments.

This borrows the low-level holoviews decollate logic, but instead of returning DynamicMap with cloned streams, returns a HoloViewsFunctionSpec.

Parameters:
hvobjA potentially dynamic Holoviews object
Returns:
HoloViewsFunctionSpec
holoviews.plotting.plotly.dash.update_stream_values_for_type(store_data, stream_event_data, uid_to_streams_for_type)[source]#

Update the store with values of streams for a single type

Parameters:
store_data

Current store dictionary

stream_event_data

Potential stream data for current plotly event and traces in figures

uid_to_streams_for_type

Mapping from trace UIDs to HoloViews streams of a particular type

Returns:
any_change

Whether any stream value has been updated