{"size": 2520, "ext": "js", "max_stars_repo_path": "Vue3-Admin/node_modules/echarts-gl/lib/chart/common/formatTooltip.js", "max_stars_repo_name": "wu-yiqiang/InformationSys", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Vue3-Admin/node_modules/echarts-gl/lib/chart/common/formatTooltip.js", "max_issues_repo_name": "wu-yiqiang/InformationSys", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Vue3-Admin/node_modules/echarts-gl/lib/chart/common/formatTooltip.js", "max_forks_repo_name": "wu-yiqiang/InformationSys", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 38.7692307692, "max_line_length": 258, "alphanum_fraction": 0.6607142857}
import * as echarts from 'echarts/lib/echarts';
import { getItemVisualColor } from '../../util/visual';

function otherDimToDataDim(data, otherDim) {
  var dataDim = [];
  echarts.util.each(data.dimensions, function (dimName) {
    var dimItem = data.getDimensionInfo(dimName);
    var otherDims = dimItem.otherDims;
    var dimIndex = otherDims[otherDim];

    if (dimIndex != null && dimIndex !== false) {
      dataDim[dimIndex] = dimItem.name;
    }
  });
  return dataDim;
}

export default function (seriesModel, dataIndex, multipleSeries) {
  function formatArrayValue(value) {
    var vertially = true;
    var result = [];
    var tooltipDims = otherDimToDataDim(data, 'tooltip');
    tooltipDims.length ? echarts.util.each(tooltipDims, function (dimIdx) {
      setEachItem(data.get(dimIdx, dataIndex), dimIdx);
    }) // By default, all dims is used on tooltip.
    : echarts.util.each(value, setEachItem);

    function setEachItem(val, dimIdx) {
      var dimInfo = data.getDimensionInfo(dimIdx); // If `dimInfo.tooltip` is not set, show tooltip.

      if (!dimInfo || dimInfo.otherDims.tooltip === false) {
        return;
      }

      var dimType = dimInfo.type;
      var valStr = (vertially ? '- ' + (dimInfo.tooltipName || dimInfo.name) + ': ' : '') + (dimType === 'ordinal' ? val + '' : dimType === 'time' ? multipleSeries ? '' : echarts.format.formatTime('yyyy/MM/dd hh:mm:ss', val) : echarts.format.addCommas(val));
      valStr && result.push(echarts.format.encodeHTML(valStr));
    }

    return (vertially ? '<br/>' : '') + result.join(vertially ? '<br/>' : ', ');
  }

  var data = seriesModel.getData();
  var value = seriesModel.getRawValue(dataIndex);
  var formattedValue = echarts.util.isArray(value) ? formatArrayValue(value) : echarts.format.encodeHTML(echarts.format.addCommas(value));
  var name = data.getName(dataIndex);
  var color = getItemVisualColor(data, dataIndex);

  if (echarts.util.isObject(color) && color.colorStops) {
    color = (color.colorStops[0] || {}).color;
  }

  color = color || 'transparent';
  var colorEl = echarts.format.getTooltipMarker(color);
  var seriesName = seriesModel.name; // FIXME

  if (seriesName === '\0-') {
    // Not show '-'
    seriesName = '';
  }

  seriesName = seriesName ? echarts.format.encodeHTML(seriesName) + (!multipleSeries ? '<br/>' : ': ') : '';
  return !multipleSeries ? seriesName + colorEl + (name ? echarts.format.encodeHTML(name) + ': ' + formattedValue : formattedValue) : colorEl + seriesName + formattedValue;
}
;