File tree Expand file tree Collapse file tree 2 files changed +24
-6
lines changed
Expand file tree Collapse file tree 2 files changed +24
-6
lines changed Original file line number Diff line number Diff line change @@ -14,9 +14,12 @@ type AssetInfoGraphicProps = {
1414export default function AssetInfoGraphic ( { userInfo } : AssetInfoGraphicProps ) {
1515 const assetTableRef = useRef < HTMLDivElement > ( null ) ;
1616 const { wallets, totalAssetAmount } = userInfo ;
17- const coinData = generateCoinPieChartData ( wallets ) ;
17+ const assetData = generateCoinPieChartData ( userInfo ) ;
18+ const coinData = assetData . filter ( ( item ) => item . ticker !== 'KRW' ) ;
1819 const roiAverage =
19- wallets . reduce ( ( acc , item ) => acc + item . roi , 0 ) / wallets . length ;
20+ wallets . length > 0
21+ ? wallets . reduce ( ( acc , item ) => acc + item . roi , 0 ) / wallets . length
22+ : 0 ;
2023
2124 const handleClickChart = ( data : CoinPieChartData ) => {
2225 if ( ! assetTableRef . current ) return ;
@@ -37,7 +40,7 @@ export default function AssetInfoGraphic({ userInfo }: AssetInfoGraphicProps) {
3740 < >
3841 < div className = "flex h-100 w-180 shrink-0 items-center justify-center gap-6 " >
3942 < div className = "h-full flex-1/5" >
40- < CoinPieChart coinData = { coinData } onClick = { handleClickChart } />
43+ < CoinPieChart coinData = { assetData } onClick = { handleClickChart } />
4144 </ div >
4245 < div className = "flex flex-1/5 justify-center gap-10" >
4346 < div className = "flex flex-1 flex-col gap-6" >
Original file line number Diff line number Diff line change 1- import type { Wallet } from '~/entities/user' ;
1+ import type { UserInfoResponseData } from '~/entities/user' ;
22import type { CoinPieChartData } from '../types/chart.type' ;
33
4- export function generateCoinPieChartData ( data : Wallet [ ] ) : CoinPieChartData [ ] {
5- return data
4+ export function generateCoinPieChartData (
5+ data : UserInfoResponseData ,
6+ ) : CoinPieChartData [ ] {
7+ const pieChartData = data . wallets
68 . map ( ( item ) => ( {
79 name : item . name ,
810 ticker : item . ticker ,
@@ -14,4 +16,17 @@ export function generateCoinPieChartData(data: Wallet[]): CoinPieChartData[] {
1416 currentPrice : item . currentPrice ,
1517 } ) )
1618 . sort ( ( a , b ) => b . totalPrice - a . totalPrice ) ;
19+
20+ pieChartData . push ( {
21+ name : '원화' ,
22+ ticker : 'KRW' ,
23+ accountId : 0 ,
24+ totalPrice : data . cash ,
25+ averagePrice : data . cash ,
26+ quantity : 0 ,
27+ roi : 0 ,
28+ currentPrice : data . cash ,
29+ } ) ;
30+
31+ return pieChartData ;
1732}
You can’t perform that action at this time.
0 commit comments