class_docstr: Data aggregation functionality wrapper for ``go.FigureWidgets``.
  
  !!! warning
  
      * This wrapper only works within ``jupyter``-based environments.
      * The ``.show()`` method returns a **static figure** on which the
        **dynamic resampling cannot be performed**. To allow dynamic resampling,
        you should just output the ``FigureWidgetResampler`` object in a cell.
class_docstr_tok: ["Data","aggregation","functionality","wrapper","for","``","go.FigureWidgets","``",".","!","!","!","warning","*","This","wrapper","only","works","within","``","jupyter","``","-based","environments",".","*","The","``",".show","(",")","``","method","returns","a","*","*","static","figure","*","*","on","which","the","*","*","dynamic","resampling","can","not","be","performed","*","*",".","To","allow","dynamic","resampling",",","you","should","just","output","the","``","FigureWidgetResampler","``","object","in","a","cell","."]
code: def __init__(
      self,
      figure: BaseFigure | dict = None,
      convert_existing_traces: bool = True,
      default_n_shown_samples: int = 1000,
      default_downsampler: AbstractAggregator = MinMaxLTTB(),
      default_gap_handler: AbstractGapHandler = MedDiffGapHandler(),
      resampled_trace_prefix_suffix: Tuple[str, str] = (
          '<b style="color:sandybrown">[R]</b> ',
          "",
      ),
      show_mean_aggregation_size: bool = True,
      convert_traces_kwargs: dict | None = None,
      verbose: bool = False,
  ):
      # Parse the figure input before calling `super`
      f = self._get_figure_class(go.FigureWidget)()
      f._data_validator.set_uid = False
  
      if isinstance(figure, BaseFigure):
          # A base figure object, can be;
          # - a base plotly figure: go.Figure or go.FigureWidget
          # - a plotly-resampler figure: subclass of AbstractFigureAggregator
          # => we first copy the layout, grid_str and grid ref
          f.layout = figure.layout
          f._grid_str = figure._grid_str
          f._grid_ref = figure._grid_ref
          f.add_traces(figure.data)
      elif isinstance(figure, dict) and (
          "data" in figure
          or "layout" in figure  # or "frames" in figure  # TODO
      ):
          # A figure as a dict, can be;
          # - a plotly figure as a dict (after calling `fig.to_dict()`)
          # - a pickled (plotly-resampler) figure (after loading a pickled figure)
          f.layout = figure.get("layout")
          f._grid_str = figure.get("_grid_str")
          f._grid_ref = figure.get("_grid_ref")
          f.add_traces(figure.get("data"))
          # `pr_props` is not None when loading a pickled plotly-resampler figure
          f._pr_props = figure.get("pr_props")
          # `f._pr_props`` is an attribute to store properties of a plotly-resampler
          # figure. This attribute is only used to pass information to the super()
          # constructor. Once the super constructor is called, the attribute is
          # removed.
  
          # f.add_frames(figure.get("frames")) TODO
      elif isinstance(figure, (dict, list)):
          # A single trace dict or a list of traces
          f.add_traces(figure)
  
      super().__init__(
          f,
          convert_existing_traces,
          default_n_shown_samples,
          default_downsampler,
          default_gap_handler,
          resampled_trace_prefix_suffix,
          show_mean_aggregation_size,
          convert_traces_kwargs,
          verbose,
      )
  
      if isinstance(figure, AbstractFigureAggregator):
          # Copy the `_hf_data` if the previous figure was an AbstractFigureAggregator
          # And adjust the default max_n_samples and
          self._hf_data.update(
              self._copy_hf_data(
                  figure._hf_data, adjust_default_values=True
              )
          )
  
          # Note: This hack ensures that the this figure object initially uses
          # data of the whole view. More concretely; we create a dict
          # serialization figure and adjust the hf-traces to the whole view
          # with the check-update method (by passing no range / filter args)
          with self.batch_update():
              graph_dict: dict = self._get_current_graph()
              update_indices = self._check_update_figure_dict(
                  graph_dict
              )
              for idx in update_indices:
                  self.data[idx].update(graph_dict["data"][idx])
  
      self._prev_layout = (
          None  # Contains the previous xaxis layout configuration
      )
  
      # used for logging purposes to save a history of layout changes
      self._relayout_hist = []
  
      # Assign the the update-methods to the corresponding classes
      showspike_keys = [
          f"{xaxis}.showspikes" for xaxis in self._xaxis_list
      ]
      self.layout.on_change(self._update_spike_ranges, *showspike_keys)
  
      x_relayout_keys = [f"{xaxis}.range" for xaxis in self._xaxis_list]
      self.layout.on_change(self._update_x_ranges, *x_relayout_keys)
  
file_path: plotly-resampler/plotly_resampler/figure_resampler/figurewidget_resampler.py
imports: from __future__ import annotations
  from typing import Tuple
  import plotly.graph_objects
  from plotly.basedatatypes import BaseFigure
  from ..aggregation import AbstractAggregator, AbstractGapHandler, MedDiffGapHandler, MinMaxLTTB
  from .figure_resampler_interface import AbstractFigureAggregator
label_desc: Use image node_id 1 to create a new FigureWidgetResampler object from inherited base classes: AbstractFigureAggregator, go with example: obj = FigureWidgetResampler(figure, convert_existing_traces, default_n_shown_samples, default_downsampler, default_gap_handler, resampled_trace_prefix_suffix, show_mean_aggregation_size, convert_traces_kwargs, verbose)