/**
 * 计算趋势方向
 * 
 * @param comparison 环比数值
 * @returns 'up' | 'down' | 'neutral'
 * 
 * @example
 * calculateTrend(120) // 'up'
 * calculateTrend(-230) // 'down'
 * calculateTrend(0) // 'neutral'
 * calculateTrend(null) // 'neutral'
 */
export function calculateTrend(comparison) {
  // 处理空值
  if (comparison === null || comparison === undefined) {
    return 'neutral';
  }

  // 转换为数字
  var numComparison = typeof comparison === 'string' ? parseFloat(comparison) : comparison;

  // 处理非数字或零值
  if (isNaN(numComparison) || numComparison === 0) {
    return 'neutral';
  }

  // 判断正负
  return numComparison > 0 ? 'up' : 'down';
}