docstr: Make adjustments to plot extents by computing
  stacked bar heights, adjusting the bar baseline
  and forcing the x-axis to be categorical.
docstr_tok: ["Make","adjustments","to","plot","extents","by","computing","stacked","bar","heights",",","adjusting","the","bar","baseline","and","forcing","the","x-axis","to","be","categorical","."]
code: def get_extents(
      self, element, ranges, range_type="combined", **kwargs
  ):
      """
      Make adjustments to plot extents by computing
      stacked bar heights, adjusting the bar baseline
      and forcing the x-axis to be categorical.
      """
      if self.batched:
          overlay = self.current_frame
          element = Bars(
              overlay.table(),
              kdims=element.kdims + overlay.kdims,
              vdims=element.vdims,
          )
          for kd in overlay.kdims:
              ranges[kd.name]["combined"] = overlay.range(kd)
  
      vdim = element.vdims[0].name
      s0, s1 = ranges[vdim]["soft"]
      s0 = min(s0, 0) if util.isfinite(s0) else 0
      s1 = max(s1, 0) if util.isfinite(s1) else 0
      ranges[vdim]["soft"] = (s0, s1)
      if range_type not in ("combined", "data"):
          return super().get_extents(
              element, ranges, range_type, ydim=element.vdims[0]
          )
  
      # Compute stack heights
      xdim = element.kdims[0]
      if self.stacked:
          ds = Dataset(element)
          pos_range = (
              ds.select(**{vdim: (0, None)})
              .aggregate(xdim, function=np.sum)
              .range(vdim)
          )
          neg_range = (
              ds.select(**{vdim: (None, 0)})
              .aggregate(xdim, function=np.sum)
              .range(vdim)
          )
          y0, y1 = util.max_range([pos_range, neg_range])
      else:
          y0, y1 = ranges[vdim]["combined"]
  
      if range_type == "data":
          return ("", y0, "", y1)
  
      padding = 0 if self.overlaid else self.padding
      _, ypad, _ = get_axis_padding(padding)
      y0, y1 = util.dimension_range(
          y0,
          y1,
          ranges[vdim]["hard"],
          ranges[vdim]["soft"],
          ypad,
          self.logy,
      )
      y0, y1 = util.dimension_range(y0, y1, self.ylim, (None, None))
      return ("", y0, "", y1)
  
imports: import numpy
  from ..core import Dataset, Dimension, util
  from ..element import Bars, Graph
  from ..element.util import categorical_aggregate2d
  from .util import get_axis_padding
label_desc: Use image node_id 2 for calling the BarsMixin obj's underlying member method code with example usage: obj.get_extents(element, ranges, range_type) and returns: str,  y0,  str,  y1, super, str,  y0,  str,  y1