/**
 * 
 *     @dfsj/echarts： 专业的水文曲线组件或构造函数以及通用的echart二次封装图表
 *     版本: v3.7.0
 *     作者：yangbo <1747837358@qq.com>
 *     日期：2025-05-27 15:53:33
 *     
 *     
 */

function parsePercent(percent, max) {
  switch (percent) {
    case 'center':
    case 'middle':
      percent = '50%';
      break;
    case 'left':
    case 'top':
      percent = '0%';
      break;
    case 'right':
    case 'bottom':
      percent = '100%';
      break;
  }
  if (typeof percent === 'string') {
    if (percent.replace(/^\s+|\s+$/g, '').match(/%$/)) {
      return parseFloat(percent) / 100 * max;
    }
    return parseFloat(percent);
  }
  return percent == null ? NaN : +percent;
}

export { parsePercent };
