1+ """Register plotly-resampler to (un)wrap plotly-graph-objects."""
2+
13__author__ = "Jeroen Van Der Donckt, Jonas Van Der Donckt, Emiel Deprost"
24
35from plotly_resampler import FigureResampler , FigureWidgetResampler
@@ -23,7 +25,21 @@ def _already_wrapped(constr):
2325 return constr .__name__ .startswith (WRAPPED_PREFIX )
2426
2527
26- def get_plotly_constr (constr ):
28+ def _get_plotly_constr (constr ):
29+ """Return the constructor of the underlying plotly graph object and thus omit the
30+ possibly wrapped :class:`AbstractFigureAggregator <plotly_resampler.figure_resampler.figure_resampler_interface.AbstractFigureAggregator>`
31+ instance.
32+
33+ Parameters
34+ ----------
35+ constr : callable
36+ The constructor of a instantiatedplotly-object.
37+
38+ Returns
39+ -------
40+ callable
41+ The constructor of a ``go.FigureWidget`` or a ``go.Figure``.
42+ """
2743 if _already_wrapped (constr ):
2844 return constr .__wrapped__ # get the original constructor
2945 return constr
@@ -49,7 +65,7 @@ def _register_wrapper(
4965 ** aggregator_kwargs ,
5066):
5167 constr = getattr (module , constr_name )
52- constr = get_plotly_constr (constr ) # get the original plotly constructor
68+ constr = _get_plotly_constr (constr ) # get the original plotly constructor
5369
5470 # print(f"Wrapping {constr_name} with {pr_class}")
5571
@@ -62,13 +78,19 @@ def wrapped_constr(*args, **kwargs):
6278 setattr (module , constr_name , wrapped_constr )
6379
6480
65- def register_plotly_resampler (mode = "auto" , ** aggregator_kwargs ): # TODO: show kwargs (e.g., port)?
81+ def register_plotly_resampler (mode = "auto" , ** aggregator_kwargs ):
6682 """Register plotly-resampler to plotly.graph_objects.
6783
6884 This function results in the use of plotly-resampler under the hood.
6985
7086 .. Note::
71- We advise to
87+ We advise to use mode= ``widget`` when working in an IPython based environment
88+ as this will just behave as a ``go.FigureWidget``, but with dynamic aggregation.
89+ When using mode= ``auto`` or ``figure``; most figures will be wrapped as
90+ :class:`FigureResampler <plotly_resampler.figure_resampler.FigureResampler>`,
91+ on which
92+ :func:`show_dash <plotly_resampler.figure_resampler.FigureResampler.show_dash>`
93+ needs to be called.
7294
7395 Parameters
7496 ----------
@@ -78,14 +100,14 @@ def register_plotly_resampler(mode="auto", **aggregator_kwargs): # TODO: show k
78100 If 'auto' is used, the mode is determined based on the environment; if it is in
79101 an ipython environment, the mode is 'widget', otherwise it is 'figure'.
80102 If 'figure' is used, all plotly figures are wrapped as FigureResampler objects.
81- If 'widget' is used, all plotly figure widgets are wrapped as
103+ If 'widget' is used, all plotly figure widgets are wrapped as
82104 FigureWidgetResampler objects (we advise to use this mode in ipython environment
83105 with a kernel).
84106 If None is used, wrapping is done as expected (go.Figure -> FigureResampler,
85107 go.FigureWidget -> FigureWidgetResampler).
86108 aggregator_kwargs : dict, optional
87109 The keyword arguments to pass to the plotly-resampler decorator its constructor.
88- See more details in :class:`FigureResampler <FigureResampler>` and
110+ See more details in :class:`FigureResampler <FigureResampler>` and
89111 :class:`FigureWidgetResampler <FigureWidgetResampler>`.
90112
91113 """
0 commit comments