// 动画进度全局变量
declare const process: number;

/**
 * 漏斗图数据项接口
 */
export interface FunnelDataItem {
  data: number;
  radius?: number;
  _proportion_?: number;
  [key: string]: any;
}

/**
 * 漏斗图配置选项
 */
export interface FunnelOption {
  type?: string;
  [key: string]: any;
}

/**
 * 获取漏斗图数据点
 * 计算漏斗图和金字塔图的半径和比例
 * @param series - 漏斗图数据项数组
 * @param radius - 漏斗图最大半径
 * @param option - 漏斗图配置选项（type: 'funnel' 或 'pyramid'）
 * @param eachSpacing - 每项之间的间距
 * @returns 包含计算后半径和比例的漏斗图数据项数组
 */
export function getFunnelDataPoints(
  series: FunnelDataItem[],
  radius: number,
  option: FunnelOption,
  eachSpacing: number
): FunnelDataItem[] {
  for (let i = 0; i < series.length; i++) {
    if(option.type == 'funnel'){
      series[i].radius = series[i].data / series[0].data * radius * process;
    }else{
      series[i].radius = (eachSpacing * (series.length - i)) / (eachSpacing * series.length) * radius * process;
    }
    series[i]._proportion_ = series[i].data / series[0].data;
  }
  return series;
}
