import React from 'react';
import { View, Text, StyleSheet, Dimensions } from 'react-native';
import { BarChart } from "react-native-chart-kit";
import { Button } from 'react-native-elements';
import Ionicons from 'react-native-vector-icons/Ionicons';
const screenWidth = Dimensions.get("window").width;
const screenHeight = Dimensions.get("window").height;
const ChartY = ({ resDataY, year, setYear }) => {
const chartConfig = {
backgroundGradientFrom: "#ffffff", //좌측 색
backgroundGradientFromOpacity: 1,
backgroundGradientTo: "#ffffff", // 우측 색
backgroundGradientToOpacity: 1,
color: (opacity = 1) => `rgba(48, 48, 48, ${opacity})`,
strokeWidth: 2, // optional, default 3
barPercentage: 0.5, // 그래프 width
useShadowColorFromDataset: false,// optional, default is false
fillShadowGradientOpacity: 1, // 좀 더 진하게만 할 뿐 단색 설정은 못하는 것 같음
};
const prevBtn = () => {
setYear(year - 1)
};
const nextBtn = () => {
setYear(year + 1)
}
const convertY = (y) => {
console.log('convert y=====', y)
let res = '';
if (y >= 1000000000) {
res = (y / 1000000000).toFixed(2) + "B"
console.log('단위변환중', res)
} else if (y >= 1000000) {
res = (y / 1000000).toFixed(2) + "M"
console.log('단위변환중', res)
} else if (y >= 1000) {
res = (y / 1000).toFixed(2) + "K"
console.log('단위변환중', res)
}
return res
}
console.log('잠만확인', resDataY.temp1[0].datasets[0].data, '|', resDataY.temp2[0].datasets[0].data)
let totalYI = (resDataY.temp1[0].datasets[0].data).reduce((acc, curr) => acc + curr, 0);
let totalYO = (resDataY.temp2[0].datasets[0].data).reduce((acc, curr) => acc + curr, 0);
console.log('합산 확인', totalYI, '|', totalYO)
return (
<>
} type='clear' />
{year}년
} type='clear' />
수입: {(totalYI).toLocaleString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")}원
지출: {(totalYO).toLocaleString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")}원
>
)
}
const style = StyleSheet.create({
Font: {
textAlign: "center",
fontSize: 20,
fontFamily: 'GowunDodum-Regular'
},
});
export default ChartY;