@@ -146,7 +146,8 @@ def __init__(
146146 Whether some verbose messages will be printed or not, by default False.
147147 show_dash_kwargs: dict, optional
148148 A dict that will be used as default kwargs for the [`show_dash`][figure_resampler.figure_resampler.FigureResampler.show_dash] method.
149- Note that the passed kwargs will be take precedence over these defaults.
149+ !!! note
150+ The passed kwargs to the [`show_dash`][figure_resampler.figure_resampler.FigureResampler.show_dash] method will take precedence over these defaults.
150151
151152 """
152153 # Parse the figure input before calling `super`
@@ -467,6 +468,7 @@ def show_dash(
467468 self ,
468469 mode = None ,
469470 config : dict | None = None ,
471+ init_dash_kwargs : dict | None = None ,
470472 graph_properties : dict | None = None ,
471473 ** kwargs ,
472474 ):
@@ -502,6 +504,17 @@ def show_dash(
502504 This ``config`` parameter is the same as the dict that you would pass as
503505 ``config`` argument to the `show` method.
504506 See more [https://plotly.com/python/configuration-options/](https://plotly.com/python/configuration-options/)
507+ init_dash_kwargs: dict, optional
508+ Keyword arguments for the Dash app constructor.
509+ !!! note
510+ This variable is of special interest when working in a jupyterhub +
511+ kubernetes environment. In this case, user notebook servers are spawned
512+ as separate pods and user access to those servers are proxied via
513+ jupyterhub. Dash requires the `requests_pathname_prefix` to be set on
514+ __init__ - which can be done via this `init_dash_kwargs` argument.
515+ Note that you should also pass the `jupyter_server_url` to the
516+ `show_dash` method.
517+ More details: https://github.com/predict-idlab/plotly-resampler/issues/265
505518 graph_properties: dict, optional
506519 Dictionary of (keyword, value) for the properties that should be passed to
507520 the dcc.Graph, by default None.
@@ -510,9 +523,10 @@ def show_dash(
510523 ``config`` parameter for this property in this method.
511524 See more [https://dash.plotly.com/dash-core-components/graph](https://dash.plotly.com/dash-core-components/graph)
512525 **kwargs: dict
513- Additional app.run_server() kwargs. e.g.: port, ...
514- Also note that these kwargs take precedence over the ones passed to the
515- constructor via the ``show_dash_kwargs`` argument.
526+ kwargs for the ``app.run_server()`` method, e.g., port=8037.
527+ !!! note
528+ These kwargs take precedence over the ones that are passed to the
529+ constructor via the ``show_dash_kwargs`` argument.
516530
517531 """
518532 available_modes = ["external" , "inline" , "inline_persistent" , "jupyterlab" ]
@@ -547,9 +561,9 @@ def show_dash(
547561 self .data [trace_idx ].update (updated_trace )
548562
549563 # 1. Construct the Dash app layout
550- app_init_kwargs = {}
564+ init_dash_kwargs = {} if init_dash_kwargs is None else init_dash_kwargs
551565 if self ._create_overview :
552- app_init_kwargs ["assets_folder" ] = os .path .relpath (
566+ init_dash_kwargs ["assets_folder" ] = os .path .relpath (
553567 ASSETS_FOLDER , os .getcwd ()
554568 )
555569
@@ -559,18 +573,19 @@ def show_dash(
559573 # Inline persistent mode: we display a static image of the figure when the
560574 # app is not reachable
561575 # Note: this is the "inline" behavior of JupyterDashInlinePersistentOutput
562- app = JupyterDashPersistentInlineOutput ("local_app" , ** app_init_kwargs )
576+ app = JupyterDashPersistentInlineOutput ("local_app" , ** init_dash_kwargs )
563577 self ._is_persistent_inline = True
564578 else :
565579 # If Jupyter Dash is not installed, inline persistent won't work and hence
566580 # we default to normal inline mode with a normal Dash app
567- app = dash .Dash ("local_app" , ** app_init_kwargs )
581+ app = dash .Dash ("local_app" , ** init_dash_kwargs )
568582 warnings .warn (
569583 "'jupyter_dash' is not installed. The persistent inline mode will not work. Defaulting to standard inline mode."
570584 )
571585 else :
572586 # jupyter dash uses a normal Dash app as figure
573- app = dash .Dash ("local_app" , ** app_init_kwargs )
587+ app = dash .Dash ("local_app" , ** init_dash_kwargs )
588+
574589 # fmt: off
575590 div = dash .html .Div (
576591 style = {
@@ -582,7 +597,7 @@ def show_dash(
582597 TraceUpdater (id = "trace-updater" , gdID = "resample-figure" , sequentialUpdate = False ),
583598 ],
584599 )
585- # # fmt: on
600+ # fmt: on
586601 if self ._create_overview :
587602 overview_config = config .copy () if config is not None else {}
588603 overview_config ["displayModeBar" ] = False
0 commit comments