docs: function completeDimensions(sysDims, source, opt) {
      if (!Source.isInstance(source)) {
          source = Source.seriesDataToSource(source);
      }
  
      opt = opt || {};
      sysDims = (sysDims || []).slice();
      var dimsDef = (opt.dimsDef || []).slice();
      var encodeDef = createHashMap(opt.encodeDef);
      var dataDimNameMap = createHashMap();
      var coordDimNameMap = createHashMap();
      // var valueCandidate;
      var result = [];
  
      var dimCount = getDimCount(source, sysDims, dimsDef, opt.dimCount);
  
      // Apply user defined dims (`name` and `type`) and init result.
      for (var i = 0; i < dimCount; i++) {
          var dimDefItem = dimsDef[i] = extend(
              {}, isObject(dimsDef[i]) ? dimsDef[i] : {name: dimsDef[i]}
          );
          var userDimName = dimDefItem.name;
          var resultItem = result[i] = {otherDims: {}};
          // Name will be applied later for avoiding duplication.
          if (userDimName != null && dataDimNameMap.get(userDimName) == null) {
              // Only if `series.dimensions` is defined in option
              // displayName, will be set, and dimension will be diplayed vertically in
              // tooltip by default.
              resultItem.name = resultItem.displayName = userDimName;
              dataDimNameMap.set(userDimName, i);
          }
          dimDefItem.type != null && (resultItem.type = dimDefItem.type);
          dimDefItem.displayName != null && (resultItem.displayName = dimDefItem.displayName);
      }
  
      // Set `coordDim` and `coordDimIndex` by `encodeDef` and normalize `encodeDef`.
      encodeDef.each(function (dataDims, coordDim) {
          dataDims = normalizeToArray(dataDims).slice();
  
          // Note: It is allowed that `dataDims.length` is `0`, e.g., options is
          // `{encode: {x: -1, y: 1}}`. Should not filter anything in
          // this case.
          if (dataDims.length === 1 && !isString(dataDims[0]) && dataDims[0] < 0) {
              encodeDef.set(coordDim, false);
              return;
          }
  
          var validDataDims = encodeDef.set(coordDim, []);
          each(dataDims, function (resultDimIdx, idx) {
              // The input resultDimIdx can be dim name or index.
              isString(resultDimIdx) && (resultDimIdx = dataDimNameMap.get(resultDimIdx));
              if (resultDimIdx != null && resultDimIdx < dimCount) {
                  validDataDims[idx] = resultDimIdx;
                  applyDim(result[resultDimIdx], coordDim, idx);
              }
          });
      });
  
      // Apply templetes and default order from `sysDims`.
      var availDimIdx = 0;
      each(sysDims, function (sysDimItem, sysDimIndex) {
          var coordDim;
          var sysDimItem;
          var sysDimItemDimsDef;
          var sysDimItemOtherDims;
          if (isString(sysDimItem)) {
              coordDim = sysDimItem;
              sysDimItem = {};
          }
          else {
              coordDim = sysDimItem.name;
              var ordinalMeta = sysDimItem.ordinalMeta;
              sysDimItem.ordinalMeta = null;
              sysDimItem = clone(sysDimItem);
              sysDimItem.ordinalMeta = ordinalMeta;
              // `coordDimIndex` should not be set directly.
              sysDimItemDimsDef = sysDimItem.dimsDef;
              sysDimItemOtherDims = sysDimItem.otherDims;
              sysDimItem.name = sysDimItem.coordDim = sysDimItem.coordDimIndex
                  = sysDimItem.dimsDef = sysDimItem.otherDims = null;
          }
  
          var dataDims = encodeDef.get(coordDim);
  
          // negative resultDimIdx means no need to mapping.
          if (dataDims === false) {
              return;
          }
  
          var dataDims = normalizeToArray(dataDims);
  
          // dimensions provides default dim sequences.
          if (!dataDims.length) {
              for (var i = 0; i < (sysDimItemDimsDef && sysDimItemDimsDef.length || 1); i++) {
                  while (availDimIdx < result.length && result[availDimIdx].coordDim != null) {
                      availDimIdx++;
                  }
                  availDimIdx < result.length && dataDims.push(availDimIdx++);
              }
          }
  
          // Apply templates.
          each(dataDims, function (resultDimIdx, coordDimIndex) {
              var resultItem = result[resultDimIdx];
              applyDim(defaults(resultItem, sysDimItem), coordDim, coordDimIndex);
              if (resultItem.name == null && sysDimItemDimsDef) {
                  var sysDimItemDimsDefItem = sysDimItemDimsDef[coordDimIndex];
                  !isObject(sysDimItemDimsDefItem) && (sysDimItemDimsDefItem = {name: sysDimItemDimsDefItem});
                  resultItem.name = resultItem.displayName = sysDimItemDimsDefItem.name;
                  resultItem.defaultTooltip = sysDimItemDimsDefItem.defaultTooltip;
              }
              // FIXME refactor, currently only used in case: {otherDims: {tooltip: false}}
              sysDimItemOtherDims && defaults(resultItem.otherDims, sysDimItemOtherDims);
          });
      });
  
      function applyDim(resultItem, coordDim, coordDimIndex) {
          if (OTHER_DIMENSIONS.get(coordDim) != null) {
              resultItem.otherDims[coordDim] = coordDimIndex;
          }
          else {
              resultItem.coordDim = coordDim;
              resultItem.coordDimIndex = coordDimIndex;
              coordDimNameMap.set(coordDim, true);
          }
      }
  
      // Make sure the first extra dim is 'value'.
      var generateCoord = opt.generateCoord;
      var generateCoordCount = opt.generateCoordCount;
      var fromZero = generateCoordCount != null;
      generateCoordCount = generateCoord ? (generateCoordCount || 1) : 0;
      var extra = generateCoord || 'value';
  
      // Set dim `name` and other `coordDim` and other props.
      for (var resultDimIdx = 0; resultDimIdx < dimCount; resultDimIdx++) {
          var resultItem = result[resultDimIdx] = result[resultDimIdx] || {};
          var coordDim = resultItem.coordDim;
  
          if (coordDim == null) {
              resultItem.coordDim = genName(
                  extra, coordDimNameMap, fromZero
              );
              resultItem.coordDimIndex = 0;
              if (!generateCoord || generateCoordCount <= 0) {
                  resultItem.isExtraCoord = true;
              }
              generateCoordCount--;
          }
  
          resultItem.name == null && (resultItem.name = genName(
              resultItem.coordDim,
              dataDimNameMap
          ));
  
          if (resultItem.type == null && guessOrdinal(source, resultDimIdx, resultItem.name)) {
              resultItem.type = 'ordinal';
          }
      }
  
      return result;
  }