Skip to content

Commit 9c67088

Browse files
committed
refactor: 차트 사이즈 수정
issues: #33
1 parent 65c31a2 commit 9c67088

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
export const Intervals = [
1+
export const INTERVALS = [
22
{ interval: 1, text: '1분' },
33
{ interval: 3, text: '3분' },
44
{ interval: 5, text: '5분' },
55
{ interval: 15, text: '15분' },
66
{ interval: 30, text: '30분' },
77
];
8+
9+
export const INTERVAL_SELECTOR_HEIGHT = 26;

src/features/tradeview/ui/StockChart/ChartContainer.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {
1717
useRef,
1818
} from 'react';
1919

20+
import { INTERVAL_SELECTOR_HEIGHT } from '../../const/chart.const';
2021
import { useChartRoot } from './ChartRoot';
2122

2223
type ChartContainerProps = PropsWithChildren<{
@@ -57,7 +58,7 @@ export default function ChartContainer({
5758
...chartOption,
5859
layout,
5960
width: root.clientWidth,
60-
height: root.clientHeight,
61+
height: root.clientHeight - INTERVAL_SELECTOR_HEIGHT,
6162
});
6263
this._instance.timeScale().fitContent();
6364
}
@@ -76,10 +77,11 @@ export default function ChartContainer({
7677
const chart = chartApi.getInstance();
7778

7879
const handleResize = () => {
80+
if (!root) return;
7981
chart.applyOptions({
8082
...chartOption,
81-
width: root?.clientWidth,
82-
height: root?.clientHeight,
83+
width: root.clientWidth,
84+
height: root.clientHeight - INTERVAL_SELECTOR_HEIGHT,
8385
});
8486
};
8587

src/features/tradeview/ui/StockChart/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import Series from './Series';
2121
import ToolTip from './ToolTip';
2222

2323
import api from '../../api/tradeview.endpoints';
24-
import { Intervals } from '../../const/chart.const';
24+
import { INTERVALS } from '../../const/chart.const';
2525
import usePastTimeData from '../../hooks/usePastTimeData';
2626
import useRealTimeData from '../../hooks/useRealTimeData';
2727
import { extractCandlestickData, timestampToISOString } from '../../utils';
@@ -148,7 +148,7 @@ export default function Chart({ ticker = 'BTC', count = 30 }: ChartProps) {
148148
return (
149149
<ChartRoot>
150150
<IntervalSelector
151-
intervals={Intervals}
151+
intervals={INTERVALS}
152152
onSelectInterval={handleSelectInterval}
153153
selectedInterval={selectedInterval}
154154
/>

0 commit comments

Comments
 (0)