@@ -146,7 +146,8 @@ def __init__(
146
146
Whether some verbose messages will be printed or not, by default False.
147
147
show_dash_kwargs: dict, optional
148
148
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.
150
151
151
152
"""
152
153
# Parse the figure input before calling `super`
@@ -467,6 +468,7 @@ def show_dash(
467
468
self ,
468
469
mode = None ,
469
470
config : dict | None = None ,
471
+ init_dash_kwargs : dict | None = None ,
470
472
graph_properties : dict | None = None ,
471
473
** kwargs ,
472
474
):
@@ -502,6 +504,17 @@ def show_dash(
502
504
This ``config`` parameter is the same as the dict that you would pass as
503
505
``config`` argument to the `show` method.
504
506
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
505
518
graph_properties: dict, optional
506
519
Dictionary of (keyword, value) for the properties that should be passed to
507
520
the dcc.Graph, by default None.
@@ -510,9 +523,10 @@ def show_dash(
510
523
``config`` parameter for this property in this method.
511
524
See more [https://dash.plotly.com/dash-core-components/graph](https://dash.plotly.com/dash-core-components/graph)
512
525
**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.
516
530
517
531
"""
518
532
available_modes = ["external" , "inline" , "inline_persistent" , "jupyterlab" ]
@@ -547,9 +561,9 @@ def show_dash(
547
561
self .data [trace_idx ].update (updated_trace )
548
562
549
563
# 1. Construct the Dash app layout
550
- app_init_kwargs = {}
564
+ init_dash_kwargs = {} if init_dash_kwargs is None else init_dash_kwargs
551
565
if self ._create_overview :
552
- app_init_kwargs ["assets_folder" ] = os .path .relpath (
566
+ init_dash_kwargs ["assets_folder" ] = os .path .relpath (
553
567
ASSETS_FOLDER , os .getcwd ()
554
568
)
555
569
@@ -559,18 +573,19 @@ def show_dash(
559
573
# Inline persistent mode: we display a static image of the figure when the
560
574
# app is not reachable
561
575
# Note: this is the "inline" behavior of JupyterDashInlinePersistentOutput
562
- app = JupyterDashPersistentInlineOutput ("local_app" , ** app_init_kwargs )
576
+ app = JupyterDashPersistentInlineOutput ("local_app" , ** init_dash_kwargs )
563
577
self ._is_persistent_inline = True
564
578
else :
565
579
# If Jupyter Dash is not installed, inline persistent won't work and hence
566
580
# 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 )
568
582
warnings .warn (
569
583
"'jupyter_dash' is not installed. The persistent inline mode will not work. Defaulting to standard inline mode."
570
584
)
571
585
else :
572
586
# 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
+
574
589
# fmt: off
575
590
div = dash .html .Div (
576
591
style = {
@@ -582,7 +597,7 @@ def show_dash(
582
597
TraceUpdater (id = "trace-updater" , gdID = "resample-figure" , sequentialUpdate = False ),
583
598
],
584
599
)
585
- # # fmt: on
600
+ # fmt: on
586
601
if self ._create_overview :
587
602
overview_config = config .copy () if config is not None else {}
588
603
overview_config ["displayModeBar" ] = False
0 commit comments