fix: grafik bar

This commit is contained in:
2026-04-20 16:27:44 +08:00
parent 5dac451754
commit 8b8ea61a13
3 changed files with 72 additions and 42 deletions

View File

@@ -32,11 +32,6 @@ export default function ChartDokumenHome({ refreshing }: { refreshing: boolean }
frontColor: val > 0 ? (item.color || '#fac858') : 'transparent',
label: item.label,
value: val,
topLabelComponent: () => (
<View style={{ marginBottom: 5 }}>
<Text style={{ color: colors.text, fontSize: 12 }}>{val > 0 ? val : ""}</Text>
</View>
)
}
}) as Props
},
@@ -52,6 +47,17 @@ export default function ChartDokumenHome({ refreshing }: { refreshing: boolean }
if (maxVal < 5) return 5;
return Math.ceil(maxVal / 10) * 10;
}, [chartData]);
const barData = useMemo(() => {
return chartData.map(item => ({
...item,
topLabelComponent: () => (
<View style={{ marginBottom: 5 }}>
<Text style={{ color: colors.text, fontSize: 12 }}>{item.value > 0 ? item.value : ""}</Text>
</View>
)
}))
}, [chartData, colors.text]);
return (
<View style={[Styles.wrapPaper, Styles.contentItemCenter, Styles.mb15, { backgroundColor: colors.card, borderColor: colors.icon + '20' }]}>
@@ -65,7 +71,7 @@ export default function ChartDokumenHome({ refreshing }: { refreshing: boolean }
showYAxisIndices
noOfSections={maxValue < 5 ? (maxValue === 0 ? 4 : maxValue) : 4}
maxValue={maxValue}
data={chartData}
data={barData}
isAnimated
width={width - 140}
barWidth={width * 0.25}