class_docstr: Abstract interface for data aggregation functionality for plotly figures.
class_docstr_tok: ["Abstract","interface","for","data","aggregation","functionality","for","plotly","figures","."]
docstr: Instantiate a resampling data mirror.
  
  Parameters
  ----------
  figure: BaseFigure
      The figure that will be decorated. Can be either an empty figure
      (e.g., ``go.Figure()``, ``make_subplots()``, ``go.FigureWidget``) or an
      existing figure.
  convert_existing_traces: bool
      A bool indicating whether the high-frequency traces of the passed ``figure``
      should be resampled, by default True. Hence, when set to False, the
      high-frequency traces of the passed ``figure`` will not be resampled.
  default_n_shown_samples: int, optional
      The default number of samples that will be shown for each trace,
      by default 1000.
  
      !!! note
          * This can be overridden within the [`add_trace`][figure_resampler.figure_resampler_interface.AbstractFigureAggregator.add_trace] method.
          * If a trace withholds fewer datapoints than this parameter,
            the data will *not* be aggregated.
  default_downsampler: AbstractAggregator
      An instance which implements the AbstractSeriesDownsampler interface and
      will be used as default downsampler, by default ``MinMaxLTTB``. 
  
      !!! note
          This can be overridden within the [`add_trace`][figure_resampler.figure_resampler_interface.AbstractFigureAggregator.add_trace] method.
  default_gap_handler: GapHandler
      An instance which implements the AbstractGapHandler interface and will be
      used as default gap handler, by default ``MedDiffGapHandler``. 
  
      !!! note
          This can be overridden within the [`add_trace`][figure_resampler.figure_resampler_interface.AbstractFigureAggregator.add_trace] method.
  resampled_trace_prefix_suffix: str, optional
      A tuple which contains the ``prefix`` and ``suffix``, respectively, which
      will be added to the trace its legend-name when a resampled version of the
      trace is shown. By default, a bold, orange ``[R]`` is shown as prefix
      (no suffix is shown).
  show_mean_aggregation_size: bool, optional
      Whether the mean aggregation bin size will be added as a suffix to the trace
      its legend-name, by default True.
  convert_traces_kwargs: dict, optional
      A dict of kwargs that will be passed to the [`add_traces`][figure_resampler.figure_resampler_interface.AbstractFigureAggregator.add_traces] method and
      will be used to convert the existing traces. 
  
      !!! note
          This argument is only used when the passed ``figure`` contains data and
          ``convert_existing_traces`` is set to True.
  verbose: bool, optional
      Whether some verbose messages will be printed or not, by default False.
docstr_tok: ["Instantiate","a","resampling","data","mirror",".","Parameters","--","--","--","--","--","figure",":","BaseFigure","The","figure","that","will","be","decorated",".","Can","be","either","an","empty","figure","(","e.g.",",","``","go.Figure","(",")","``",",","``","make_subplots","(",")","``",",","``","go.FigureWidget","``",")","or","an","existing","figure",".","convert_existing_traces",":","bool","A","bool","indicating","whether","the","high-frequency","traces","of","the","passed","``","figure","``","should","be","resampled",",","by","default","True",".","Hence",",","when","set","to","False",",","the","high-frequency","traces","of","the","passed","``","figure","``","will","not","be","resampled",".","default_n_shown_samples",":","int",",","optional","The","default","number","of","samples","that","will","be","shown","for","each","trace",",","by","default","1000",".","!","!","!","note","*","This","can","be","overridden","within","the","[","`","add_trace","`","]","[","figure_resampler.figure_resampler_interface.AbstractFigureAggregator.add_trace","]","method",".","*","If","a","trace","withholds","fewer","datapoints","than","this","parameter",",","the","data","will","*","not","*","be","aggregated",".","default_downsampler",":","AbstractAggregator","An","instance","which","implements","the","AbstractSeriesDownsampler","interface","and","will","be","used","as","default","downsampler",",","by","default","``","MinMaxLTTB","``",".","!","!","!","note","This","can","be","overridden","within","the","[","`","add_trace","`","]","[","figure_resampler.figure_resampler_interface.AbstractFigureAggregator.add_trace","]","method",".","default_gap_handler",":","GapHandler","An","instance","which","implements","the","AbstractGapHandler","interface","and","will","be","used","as","default","gap","handler",",","by","default","``","MedDiffGapHandler","``",".","!","!","!","note","This","can","be","overridden","within","the","[","`","add_trace","`","]","[","figure_resampler.figure_resampler_interface.AbstractFigureAggregator.add_trace","]","method",".","resampled_trace_prefix_suffix",":","str",",","optional","A","tuple","which","contains","the","``","prefix","``","and","``","suffix","``",",","respectively",",","which","will","be","added","to","the","trace","its","legend-name","when","a","resampled","version","of","the","trace","is","shown",".","By","default",",","a","bold",",","orange","``","[","R","]","``","is","shown","as","prefix","(","no","suffix","is","shown",")",".","show_mean_aggregation_size",":","bool",",","optional","Whether","the","mean","aggregation","bin","size","will","be","added","as","a","suffix","to","the","trace","its","legend-name",",","by","default","True",".","convert_traces_kwargs",":","dict",",","optional","A","dict","of","kwargs","that","will","be","passed","to","the","[","`","add_traces","`","]","[","figure_resampler.figure_resampler_interface.AbstractFigureAggregator.add_traces","]","method","and","will","be","used","to","convert","the","existing","traces",".","!","!","!","note","This","argument","is","only","used","when","the","passed","``","figure","``","contains","data","and","``","convert_existing_traces","``","is","set","to","True",".","verbose",":","bool",",","optional","Whether","some","verbose","messages","will","be","printed","or","not",",","by","default","False","."]
code: def __init__(
      self,
      figure: BaseFigure,
      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,
  ):
      """Instantiate a resampling data mirror.
  
      Parameters
      ----------
      figure: BaseFigure
          The figure that will be decorated. Can be either an empty figure
          (e.g., ``go.Figure()``, ``make_subplots()``, ``go.FigureWidget``) or an
          existing figure.
      convert_existing_traces: bool
          A bool indicating whether the high-frequency traces of the passed ``figure``
          should be resampled, by default True. Hence, when set to False, the
          high-frequency traces of the passed ``figure`` will not be resampled.
      default_n_shown_samples: int, optional
          The default number of samples that will be shown for each trace,
          by default 1000.\n
          !!! note
              * This can be overridden within the [`add_trace`][figure_resampler.figure_resampler_interface.AbstractFigureAggregator.add_trace] method.
              * If a trace withholds fewer datapoints than this parameter,
                the data will *not* be aggregated.
      default_downsampler: AbstractAggregator
          An instance which implements the AbstractSeriesDownsampler interface and
          will be used as default downsampler, by default ``MinMaxLTTB``. \n
          !!! note
              This can be overridden within the [`add_trace`][figure_resampler.figure_resampler_interface.AbstractFigureAggregator.add_trace] method.
      default_gap_handler: GapHandler
          An instance which implements the AbstractGapHandler interface and will be
          used as default gap handler, by default ``MedDiffGapHandler``. \n
          !!! note
              This can be overridden within the [`add_trace`][figure_resampler.figure_resampler_interface.AbstractFigureAggregator.add_trace] method.
      resampled_trace_prefix_suffix: str, optional
          A tuple which contains the ``prefix`` and ``suffix``, respectively, which
          will be added to the trace its legend-name when a resampled version of the
          trace is shown. By default, a bold, orange ``[R]`` is shown as prefix
          (no suffix is shown).
      show_mean_aggregation_size: bool, optional
          Whether the mean aggregation bin size will be added as a suffix to the trace
          its legend-name, by default True.
      convert_traces_kwargs: dict, optional
          A dict of kwargs that will be passed to the [`add_traces`][figure_resampler.figure_resampler_interface.AbstractFigureAggregator.add_traces] method and
          will be used to convert the existing traces. \n
          !!! note
              This argument is only used when the passed ``figure`` contains data and
              ``convert_existing_traces`` is set to True.
      verbose: bool, optional
          Whether some verbose messages will be printed or not, by default False.
  
      """
      self._hf_data: Dict[str, dict] = {}
      self._global_n_shown_samples = default_n_shown_samples
      self._print_verbose = verbose
      self._show_mean_aggregation_size = show_mean_aggregation_size
  
      assert len(resampled_trace_prefix_suffix) == 2
      self._prefix, self._suffix = resampled_trace_prefix_suffix
  
      self._global_downsampler = default_downsampler
      self._global_gap_handler = default_gap_handler
  
      # Given figure should always be a BaseFigure that is not wrapped by
      # a plotly-resampler class
      assert isinstance(figure, BaseFigure)
      assert not issubclass(type(figure), AbstractFigureAggregator)
      self._figure_class = figure.__class__
  
      # Overwrite the passed arguments with the property dict values
      # (this is the case when the PR figure is created from a pickled object)
      if hasattr(figure, "_pr_props"):
          pr_props = figure._pr_props  # a dict of PR properties
          if pr_props is not None:
              # Overwrite the default arguments with the serialized properties
              for k, v in pr_props.items():
                  setattr(self, k, v)
          delattr(figure, "_pr_props")  # should not be stored anymore
  
      if convert_existing_traces:
          # call __init__ with the correct layout and set the `_grid_ref` of the
          # to-be-converted figure
          f_ = self._figure_class(layout=figure.layout)
          f_._grid_str = figure._grid_str
          f_._grid_ref = figure._grid_ref
          super().__init__(f_)
  
          if convert_traces_kwargs is None:
              convert_traces_kwargs = {}
  
          # make sure that the UIDs of these traces do not get adjusted
          self._data_validator.set_uid = False
          self.add_traces(figure.data, **convert_traces_kwargs)
      else:
          super().__init__(figure)
          self._data_validator.set_uid = False
  
      # A list of al xaxis and yaxis string names
      # e.g., "xaxis", "xaxis2", "xaxis3", .... for _xaxis_list
      self._xaxis_list = self._re_matches(
          re.compile(r"xaxis\d*"), self._layout.keys()
      )
      self._yaxis_list = self._re_matches(
          re.compile(r"yaxis\d*"), self._layout.keys()
      )
      # edge case: an empty `go.Figure()` does not yet contain axes keys
      if not len(self._xaxis_list):
          self._xaxis_list = ["xaxis"]
          self._yaxis_list = ["yaxis"]
  
imports: from __future__ import annotations
  import itertools
  import re
  from abc import ABC
  from collections import namedtuple
  from copy import copy
  from typing import Dict, Iterable, List, Optional, Tuple, Union
  from uuid import uuid4
  import dash
  import numpy
  import pandas
  import plotly.graph_objects
  from pandas.io.json._normalize import nested_to_record
  from plotly.basedatatypes import BaseFigure, BaseTraceType
  from ..aggregation import AbstractAggregator, MedDiffGapHandler, MinMaxLTTB
  from ..aggregation.aggregation_interface import DataPointSelector
  from ..aggregation.gap_handler_interface import AbstractGapHandler
  from ..aggregation.plotly_aggregator_parser import PlotlyAggregatorParser
  from .utils import round_number_str, round_td_str
label_desc: Use image node_id 1 to create a new AbstractFigureAggregator object from inherited base classes: BaseFigure, ABC with example: obj = AbstractFigureAggregator(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)