class_docstr: BarPlot allows generating single- or multi-category
  bar Charts, by selecting which key dimensions are
  mapped onto separate groups, categories and stacks.
class_docstr_tok: ["BarPlot","allows","generating","single-","or","multi-category","bar","Charts",",","by","selecting","which","key","dimensions","are","mapped","onto","separate","groups",",","categories","and","stacks","."]
code: def get_data(self, element, ranges, style):
      # Get x, y, group, stack and color dimensions
      group_dim, stack_dim = None, None
      if element.ndims == 1:
          grouping = None
      elif self.stacked:
          grouping = "stacked"
          stack_dim = element.get_dimension(1)
          if stack_dim.values:
              stack_order = stack_dim.values
          elif stack_dim in ranges and ranges[stack_dim.name].get(
              "factors"
          ):
              stack_order = ranges[stack_dim]["factors"]
          else:
              stack_order = element.dimension_values(1, False)
          stack_order = list(stack_order)
      else:
          grouping = "grouped"
          group_dim = element.get_dimension(1)
  
      xdim = element.get_dimension(0)
      ydim = element.vdims[0]
      no_cidx = self.color_index is None
      color_index = (
          (group_dim or stack_dim) if no_cidx else self.color_index
      )
      color_dim = element.get_dimension(color_index)
      if color_dim:
          self.color_index = color_dim.name
  
      # Define style information
      width = style.get("bar_width", style.get("width", 1))
      if "width" in style:
          self.param.warning(
              "BarPlot width option is deprecated "
              "use 'bar_width' instead."
          )
      cmap = style.get("cmap")
      hover = "hover" in self.handles
  
      # Group by stack or group dim if necessary
      if group_dim is None:
          grouped = {0: element}
      else:
          grouped = element.groupby(
              group_dim,
              group_type=Dataset,
              container_type=dict,
              datatype=["dataframe", "dictionary"],
          )
  
      y0, y1 = ranges.get(ydim.name, {"combined": (None, None)})[
          "combined"
      ]
      if self.logy:
          bottom = ydim.range[0] or (
              0.01 if y1 > 0.01 else 10 ** (np.log10(y1) - 2)
          )
      else:
          bottom = 0
      # Map attributes to data
      if grouping == "stacked":
          mapping = {
              "x": xdim.name,
              "top": "top",
              "bottom": "bottom",
              "width": width,
          }
      elif grouping == "grouped":
          mapping = {
              "x": "xoffsets",
              "top": ydim.name,
              "bottom": bottom,
              "width": width,
          }
      else:
          mapping = {
              "x": xdim.name,
              "top": ydim.name,
              "bottom": bottom,
              "width": width,
          }
  
      # Get colors
      cdim = color_dim or group_dim
      style_mapping = [
          v
          for k, v in style.items()
          if "color" in k and (isinstance(v, dim) or v in element)
      ]
      if style_mapping and not no_cidx and self.color_index is not None:
          self.param.warning(
              "Cannot declare style mapping for '%s' option "
              "and declare a color_index; ignoring the color_index."
              % style_mapping[0]
          )
          cdim = None
  
      cvals = (
          element.dimension_values(cdim, expanded=False)
          if cdim
          else None
      )
      if cvals is not None:
          if cvals.dtype.kind in "uif" and no_cidx:
              cvals = categorize_array(cvals, color_dim)
  
          factors = None if cvals.dtype.kind in "uif" else list(cvals)
          if cdim is xdim and factors:
              factors = list(categorize_array(factors, xdim))
          if cmap is None and factors:
              styles = self.style.max_cycles(len(factors))
              colors = [styles[i]["color"] for i in range(len(factors))]
              colors = [
                  rgb2hex(c) if isinstance(c, tuple) else c
                  for c in colors
              ]
          else:
              colors = None
      else:
          factors, colors = None, None
  
      # Iterate over stacks and groups and accumulate data
      data = defaultdict(list)
      baselines = defaultdict(
          lambda: {"positive": bottom, "negative": 0}
      )
      for k, ds in grouped.items():
          k = k[0] if isinstance(k, tuple) else k
          if group_dim:
              gval = (
                  k if isinstance(k, str) else group_dim.pprint_value(k)
              )
          # Apply stacking or grouping
          if grouping == "stacked":
              for sign, slc in [
                  ("negative", (None, 0)),
                  ("positive", (0, None)),
              ]:
                  slc_ds = ds.select(**{ds.vdims[0].name: slc})
                  stack_inds = [
                      stack_order.index(v) if v in stack_order else -1
                      for v in slc_ds[stack_dim.name]
                  ]
                  slc_ds = slc_ds.add_dimension(
                      "_stack_order", 0, stack_inds
                  ).sort("_stack_order")
                  xs = slc_ds.dimension_values(xdim)
                  ys = slc_ds.dimension_values(ydim)
                  bs, ts = self.get_stack(xs, ys, baselines, sign)
                  data["bottom"].append(bs)
                  data["top"].append(ts)
                  data[xdim.name].append(xs)
                  data[stack_dim.name].append(
                      slc_ds.dimension_values(stack_dim)
                  )
                  if hover:
                      data[ydim.name].append(ys)
                      for vd in slc_ds.vdims[1:]:
                          data[vd.name].append(
                              slc_ds.dimension_values(vd)
                          )
                  if not style_mapping:
                      self._add_color_data(
                          slc_ds,
                          ranges,
                          style,
                          cdim,
                          data,
                          mapping,
                          factors,
                          colors,
                      )
          elif grouping == "grouped":
              xs = ds.dimension_values(xdim)
              ys = ds.dimension_values(ydim)
              xoffsets = [
                  (
                      x
                      if xs.dtype.kind in "SU"
                      else xdim.pprint_value(x),
                      gval,
                  )
                  for x in xs
              ]
              data["xoffsets"].append(xoffsets)
              data[ydim.name].append(ys)
              if hover:
                  data[xdim.name].append(xs)
              if group_dim not in ds.dimensions():
                  ds = ds.add_dimension(group_dim, ds.ndims, gval)
              data[group_dim.name].append(
                  ds.dimension_values(group_dim)
              )
          else:
              data[xdim.name].append(ds.dimension_values(xdim))
              data[ydim.name].append(ds.dimension_values(ydim))
  
          if hover and grouping != "stacked":
              for vd in ds.vdims[1:]:
                  data[vd.name].append(ds.dimension_values(vd))
  
          if grouping != "stacked" and not style_mapping:
              self._add_color_data(
                  ds,
                  ranges,
                  style,
                  cdim,
                  data,
                  mapping,
                  factors,
                  colors,
              )
  
      # Concatenate the stacks or groups
      sanitized_data = {}
      for col, vals in data.items():
          if len(vals) == 1:
              sanitized_data[dimension_sanitizer(col)] = vals[0]
          elif vals:
              sanitized_data[dimension_sanitizer(col)] = np.concatenate(
                  vals
              )
  
      for name, val in mapping.items():
          sanitized = None
          if isinstance(val, str):
              sanitized = dimension_sanitizer(mapping[name])
              mapping[name] = sanitized
          elif isinstance(val, dict) and "field" in val:
              sanitized = dimension_sanitizer(val["field"])
              val["field"] = sanitized
          if sanitized is not None and sanitized not in sanitized_data:
              sanitized_data[sanitized] = []
  
      # Ensure x-values are categorical
      xname = dimension_sanitizer(xdim.name)
      if xname in sanitized_data:
          sanitized_data[xname] = categorize_array(
              sanitized_data[xname], xdim
          )
  
      # If axes inverted change mapping to match hbar signature
      if self.invert_axes:
          mapping.update(
              {
                  "y": mapping.pop("x"),
                  "left": mapping.pop("bottom"),
                  "right": mapping.pop("top"),
                  "height": mapping.pop("width"),
              }
          )
  
      return sanitized_data, mapping, style
  
imports: from collections import defaultdict
  import numpy
  import param
  from bokeh.models import CategoricalColorMapper, CustomJS, FactorRange, Range1d, Whisker
  from bokeh.models.tools import BoxSelectTool
  from bokeh.transform import jitter
  from ...core.data import Dataset
  from ...core.dimension import dimension_name
  from ...core.util import dimension_sanitizer, isfinite
  from ...operation import interpolate_curve
  from ...util.transform import dim
  from ..mixins import AreaMixin, BarsMixin, SpikesMixin
  from ..util import compute_sizes, get_min_distance
  from .element import ColorbarPlot, ElementPlot, LegendPlot, OverlayPlot
  from .selection import BokehOverlaySelectionDisplay
  from .styles import base_properties, expand_batched_style, fill_properties, line_properties, mpl_to_bokeh, rgb2hex
  from .util import categorize_array
label_desc: Use image node_id 6 for calling the BarPlot obj's underlying member method code with example usage: obj.get_data(element, ranges, style) and returns: sanitized_data,  mapping,  style