@@ -43,8 +43,53 @@ def __init__(
43
43
verbose : bool = False ,
44
44
show_dash_kwargs : dict | None = None ,
45
45
):
46
+ """Initialize a dynamic aggregation data mirror using a dash web app.
47
+
48
+ Parameters
49
+ ----------
50
+ figure: BaseFigure
51
+ The figure that will be decorated. Can be either an empty figure
52
+ (e.g., ``go.Figure()``, ``make_subplots()``, ``go.FigureWidget``) or an
53
+ existing figure.
54
+ convert_existing_traces: bool
55
+ A bool indicating whether the high-frequency traces of the passed ``figure``
56
+ should be resampled, by default True. Hence, when set to False, the
57
+ high-frequency traces of the passed ``figure`` will not be resampled.
58
+ default_n_shown_samples: int, optional
59
+ The default number of samples that will be shown for each trace,
60
+ by default 1000.\n
61
+ .. note::
62
+ * This can be overridden within the :func:`add_trace` method.
63
+ * If a trace withholds fewer datapoints than this parameter,
64
+ the data will *not* be aggregated.
65
+ default_downsampler: AbstractSeriesDownsampler
66
+ An instance which implements the AbstractSeriesDownsampler interface and
67
+ will be used as default downsampler, by default ``EfficientLTTB`` with
68
+ _interleave_gaps_ set to True. \n
69
+ .. note:: This can be overridden within the :func:`add_trace` method.
70
+ resampled_trace_prefix_suffix: str, optional
71
+ A tuple which contains the ``prefix`` and ``suffix``, respectively, which
72
+ will be added to the trace its legend-name when a resampled version of the
73
+ trace is shown. By default a bold, orange ``[R]`` is shown as prefix
74
+ (no suffix is shown).
75
+ show_mean_aggregation_size: bool, optional
76
+ Whether the mean aggregation bin size will be added as a suffix to the trace
77
+ its legend-name, by default True.
78
+ convert_traces_kwargs: dict, optional
79
+ A dict of kwargs that will be passed to the :func:`add_traces` method and
80
+ will be used to convert the existing traces. \n
81
+ .. note::
82
+ This argument is only used when the passed ``figure`` contains data and
83
+ ``convert_existing_traces`` is set to True.
84
+ verbose: bool, optional
85
+ Whether some verbose messages will be printed or not, by default False.
86
+ show_dash_kwargs: dict, optional
87
+ A dict that will be used as default kwargs for the :func:`show_dash` method.
88
+ Note that the passed kwargs will be take precedence over these defaults.
89
+
90
+ """
46
91
# Parse the figure input before calling `super`
47
- if is_figure (figure ) and not is_fr (figure ):
92
+ if is_figure (figure ) and not is_fr (figure ):
48
93
# A go.Figure
49
94
# => base case: the figure does not need to be adjusted
50
95
f = figure
@@ -55,7 +100,7 @@ def __init__(
55
100
f ._data_validator .set_uid = False
56
101
57
102
if isinstance (figure , BaseFigure ):
58
- # A base figure object, can be;
103
+ # A base figure object, can be;
59
104
# - a go.FigureWidget
60
105
# - a plotly-resampler figure: subclass of AbstractFigureAggregator
61
106
# => we first copy the layout, grid_str and grid ref
@@ -75,7 +120,7 @@ def __init__(
75
120
f ._grid_ref = figure .get ("_grid_ref" )
76
121
f .add_traces (figure .get ("data" ))
77
122
# `pr_props` is not None when loading a pickled plotly-resampler figure
78
- f ._pr_props = figure .get ("pr_props" )
123
+ f ._pr_props = figure .get ("pr_props" )
79
124
# `f._pr_props`` is an attribute to store properties of a
80
125
# plotly-resampler figure. This attribute is only used to pass
81
126
# information to the super() constructor. Once the super constructor is
@@ -156,8 +201,8 @@ def show_dash(
156
201
``config`` parameter for this property in this method.
157
202
See more https://dash.plotly.com/dash-core-components/graph
158
203
**kwargs: dict
159
- Additional app.run_server() kwargs. e.g.: port
160
- Note that these kwargs take precedence over the ones passed to the
204
+ Additional app.run_server() kwargs. e.g.: port, ...
205
+ Also note that these kwargs take precedence over the ones passed to the
161
206
constructor via the ``show_dash_kwargs`` argument.
162
207
163
208
"""
@@ -183,7 +228,7 @@ def show_dash(
183
228
and "height" not in kwargs
184
229
):
185
230
# If app height is not specified -> re-use figure height for inline dash app
186
- # Note: default layout height is 450 (whereas default app height is 650)
231
+ # Note: default layout height is 450 (whereas default app height is 650)
187
232
# See: https://plotly.com/python/reference/layout/#layout-height
188
233
fig_height = self .layout .height if self .layout .height is not None else 450
189
234
kwargs ["height" ] = fig_height + 18
0 commit comments