const fmt = value => new Intl.NumberFormat('zh-CN', {maximumFractionDigits: 2}).format(value); // Both series use the same annual rows as the retained table, in 亿元. export function buildDCFCashflowOption({rows, colors, width, reducedMotion = false}) { const compact = width < 520; return { animation: !reducedMotion, animationDuration: 0, animationDurationUpdate: 200, color: [colors.secondary, colors.accent], legend: {top: 0, left: 'center', itemWidth: 12, itemHeight: 8, textStyle: {color: colors.muted, fontSize: 11}, data: ['自由现金流', '折现后现值']}, grid: {left: compact ? 8 : 12, right: 12, top: 58, bottom: rows.length > 15 ? 70 : 16, containLabel: true}, tooltip: {trigger: 'axis', confine: true, backgroundColor: colors.paper, borderColor: colors.line, textStyle: {color: colors.ink, fontSize: 12}, axisPointer: {type: 'shadow'}, formatter: params => { const row = rows[params[0].dataIndex]; return `${row.year} 年 · 阶段 ${row.stage}
自由现金流:${fmt(row.cash)} 亿元
折现后现值:${fmt(row.presentValue)} 亿元
折现因子:${row.factor.toFixed(4)}
现金流增长率:${fmt(row.growth * 100)}%`; }}, xAxis: {type: 'category', data: rows.map(row => String(row.year)), axisLine: {lineStyle: {color: colors.line}}, axisTick: {show: false}, axisLabel: {color: colors.muted, fontSize: 11, hideOverlap: true}}, yAxis: {type: 'value', name: '亿元', nameTextStyle: {color: colors.muted, fontSize: 11}, axisLabel: {color: colors.muted, fontSize: 11}, splitLine: {lineStyle: {color: colors.line, type: 'dashed'}}}, dataZoom: rows.length > 15 ? [{type: 'slider', height: 18, bottom: 8, startValue: 0, endValue: 14, borderColor: colors.line, textStyle: {color: colors.muted, fontSize: 10}}] : [], series: [ {name: '自由现金流', type: 'bar', data: rows.map(row => row.cash), barMaxWidth: 24, itemStyle: {borderRadius: [3, 3, 0, 0]}}, {name: '折现后现值', type: 'bar', data: rows.map(row => row.presentValue), barMaxWidth: 24, itemStyle: {borderRadius: [3, 3, 0, 0]}}, ], }; }