_getStackIndex(datasetIndex, name, dataIndex) {
    const stacks = this._getStacks(datasetIndex, dataIndex);
    const index = (name !== undefined)
      ? stacks.indexOf(name)
      : -1; // indexOf returns -1 if element is not present

    return (index === -1)
      ? stacks.length - 1
      : index;
  }
Returns the stack index for the given dataset based on groups and bar visibility.
@param {number} [datasetIndex] - The dataset index
@param {string} [name] - The stack name to find
@param {number} [dataIndex]
@returns {number} The stack index
@private