fix: 修复利润瀑布图柱子高度 - cost项base改为扣除后位置,value为减少量
This commit is contained in:
@@ -102,12 +102,15 @@ export function BossPage() {
|
||||
// 瀑布图累计计算
|
||||
let cumulative = 0
|
||||
const waterfallChart = waterfallSteps.map((step) => {
|
||||
if (step.type === 'total' || step.type === 'profit') {
|
||||
if (step.type === 'total') {
|
||||
cumulative = step.value
|
||||
return { name: step.name, base: 0, value: step.value, fill: step.type === 'profit' ? '#22c55e' : '#3b82f6' }
|
||||
return { name: step.name, base: 0, value: step.value, fill: '#3b82f6' }
|
||||
} else if (step.type === 'profit') {
|
||||
return { name: step.name, base: 0, value: step.value, fill: '#22c55e' }
|
||||
} else {
|
||||
const base = cumulative + step.value
|
||||
const result = { name: step.name, base, value: -step.value, fill: '#ef4444' }
|
||||
const decrease = Math.abs(step.value)
|
||||
const base = cumulative - decrease
|
||||
const result = { name: step.name, base, value: decrease, fill: '#ef4444' }
|
||||
cumulative = base
|
||||
return result
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user