Skip to content

Commit ebdf0e3

Browse files
authored
Merge pull request #146 from InserToken/feat/35-pracMain/minseon
[modify] 툴팁 다시 수정
2 parents 00969ce + 5140746 commit ebdf0e3

File tree

1 file changed

+42
-37
lines changed

1 file changed

+42
-37
lines changed

src/components/charts/InvestCandleChart.tsx

Lines changed: 42 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1067,15 +1067,13 @@ export default function InvestCandleChart({
10671067
</div>
10681068
{/* 일반 candle 값 or dot 전용 candle 값 구분 */}
10691069
{(() => {
1070-
// dotData도 있는 날짜면
10711070
const dot = dotData?.find((d) =>
10721071
dayjs(d.date).isSame(tooltip.data!.date, "day")
10731072
);
1074-
// "오늘" 날짜인지 확인
10751073
const isToday = dayjs(tooltip.data!.date).isSame(dayjs(), "day");
10761074

1077-
// 오늘이고 todayPrice가 있을 때 (실시간)
1078-
if (isToday && todayPrice && dot && dot.close) {
1075+
// 실시간 시세 + 예측값만 있는 경우 (오늘)
1076+
if (isToday && todayPrice && dot?.close) {
10791077
return (
10801078
<>
10811079
<div>
@@ -1086,7 +1084,6 @@ export default function InvestCandleChart({
10861084
</div>
10871085
<div style={{ marginTop: 4 }}>
10881086
<span style={{ color: "#C9DF00", fontWeight: 600 }}>
1089-
10901087
예측값
10911088
</span>
10921089
: {dot.close.toLocaleString()}
@@ -1095,47 +1092,55 @@ export default function InvestCandleChart({
10951092
);
10961093
}
10971094

1098-
// dotData(예측값)가 있는 경우
1099-
if (dot) {
1095+
// 예측값만 있는 경우
1096+
if (
1097+
dot?.close &&
1098+
(!tooltip.data?.open || tooltip.data.volume === 0)
1099+
) {
11001100
return (
11011101
<div>
11021102
<span style={{ color: "#C9DF00", fontWeight: 600 }}>
11031103
예측값
1104-
</span>{" "}
1104+
</span>
11051105
: {dot.close.toLocaleString()}
11061106
</div>
11071107
);
11081108
}
1109-
// 일반 candle 값 표기
1110-
return (
1111-
<>
1112-
<div>시: {tooltip.data.open.toLocaleString()}</div>
1113-
<div>고: {tooltip.data.high.toLocaleString()}</div>
1114-
<div>저: {tooltip.data.low.toLocaleString()}</div>
1115-
<div>종: {tooltip.data.close.toLocaleString()}</div>
1116-
<div>거래량: {tooltip.data.volume.toLocaleString()}</div>
1117-
<div>
1118-
{/* RSI:{" "}
1119-
{typeof rsi_visible[tooltip.idx] === "number"
1120-
? rsi_visible[tooltip.idx].toFixed(2)
1121-
: "-"} */}
1122-
RSI: {rsi}
1123-
</div>
1124-
{/* dot값이 겹치는 경우 오차 등도 표시 */}
1125-
{dot && (dot as any).close !== undefined && (
1126-
<div className="text-[#e75480] font-bold">
1127-
오차: {((dot as any).close - tooltip.data.close).toFixed(2)}{" "}
1128-
(
1129-
{(
1130-
(((dot as any).close - tooltip.data.close) /
1131-
tooltip.data.close) *
1132-
100
1133-
).toFixed(2)}
1134-
%)
1135-
</div>
1136-
)}
1137-
</>
1109+
1110+
// 일반 캔들값 (or 예측값도 있는 경우 같이 표시)
1111+
const rows = [];
1112+
1113+
rows.push(
1114+
<div key="open">시: {tooltip.data.open.toLocaleString()}</div>,
1115+
<div key="high">고: {tooltip.data.high.toLocaleString()}</div>,
1116+
<div key="low">저: {tooltip.data.low.toLocaleString()}</div>,
1117+
<div key="close">종: {tooltip.data.close.toLocaleString()}</div>,
1118+
<div key="vol">
1119+
거래량: {tooltip.data.volume.toLocaleString()}
1120+
</div>,
1121+
<div key="rsi">RSI: {rsi}</div>
11381122
);
1123+
1124+
if (dot?.close) {
1125+
rows.push(
1126+
<div key="pred" style={{ marginTop: 6 }}>
1127+
<span style={{ color: "#C9DF00", fontWeight: 600 }}>
1128+
예측값
1129+
</span>
1130+
: {dot.close.toLocaleString()}
1131+
</div>,
1132+
<div key="diff" className="text-[#e75480] font-bold">
1133+
오차: {(dot.close - tooltip.data.close).toFixed(2)} (
1134+
{(
1135+
((dot.close - tooltip.data.close) / tooltip.data.close) *
1136+
100
1137+
).toFixed(2)}
1138+
%)
1139+
</div>
1140+
);
1141+
}
1142+
1143+
return rows;
11391144
})()}
11401145
{/* 뉴스 영역 그대로 */}
11411146
{tooltipNews.length > 0 && (

0 commit comments

Comments
 (0)