fix: grafik bar
This commit is contained in:
@@ -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}
|
||||
|
||||
Reference in New Issue
Block a user