code: def _add_trace_with_history(self, stream_vis):
      # if history buffer isn't full
      if stream_vis.history_len > len(stream_vis.trace_history):
          self._add_trace(stream_vis)
          stream_vis.trace_history.append(len(self.widget.data) - 1)
          stream_vis.cur_history_index = (
              len(stream_vis.trace_history) - 1
          )
          # if stream_vis.cur_history_index:
          #    self.widget.data[trace_index].showlegend = False
      else:
          # rotate trace
          stream_vis.cur_history_index = (
              stream_vis.cur_history_index + 1
          ) % stream_vis.history_len
          stream_vis.trace_index = stream_vis.trace_history[
              stream_vis.cur_history_index
          ]
          self.clear_plot(stream_vis, False)
          self.widget.data[stream_vis.trace_index].opacity = (
              stream_vis.opacity or 1
          )
  
      cur_history_len = len(stream_vis.trace_history)
      if stream_vis.dim_history and cur_history_len > 1:
          max_opacity = stream_vis.opacity or 1
          min_alpha, max_alpha, dimmed_len = (
              max_opacity * 0.05,
              max_opacity * 0.8,
              cur_history_len - 1,
          )
          alphas = list(
              utils.frange(max_alpha, min_alpha, steps=dimmed_len)
          )
          for i, thi in enumerate(
              range(
                  stream_vis.cur_history_index + 1,
                  stream_vis.cur_history_index + cur_history_len,
              )
          ):
              trace_index = stream_vis.trace_history[
                  thi % cur_history_len
              ]
              self.widget.data[trace_index].opacity = alphas[i]
  
file_path: tensorwatch/tensorwatch/plotly/base_plotly_plot.py
imports: from ..vis_base import VisBase
  import time
  from abc import abstractmethod
  from ..None import utils
label_desc: Use image node_id 3 for calling the BasePlotlyPlot obj's underlying member method code with example usage: obj._add_trace_with_history(stream_vis) without return types