-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FE] feat#254 그래프 hover시에 툴팁으로 커밋 정보 안내, UX 개선 #294
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
수고하셨습니다!! 그래프에서 이제 해시도 볼 수 있네요ㅎㅎ
툴팁, circle에서 툴팁으로 가는 경로에 hover하면 꺼지지 않도록, 그리고 요소에 mouseout되면 꺼지도록 구현
이게 가장 큰 어려움이였는데, 툴팁으로 가는 경로에 투명한 rect svg 요소를 넣어서 해결할 수 있었습니다!
자세히 설명해주셔서 이해하기 편했습니다👍
툴팁이 한번 렌더링되고 나서 update 함수로 다시 렌더링 되지 않고 내용만 바뀌도록 구현하고 싶은데 당장 코앞이 데모라 구현하지 못했습니다🥲
이렇게 쌓여가는 기술 부채..끝나고 하나씩 상환합시다! D3 쪽은 할 게 많네요..ㅎㅎ
노드에 호버되었냐는 불리언 변수인데 더 좋은거 없을까요..ㅠㅠ
음 결국 노드랑 툴팁에서 mouseout 되었는지 판별하는 것 같아서 mouseoutNode
는 어떤가요 ? 아니면 아래처럼 ?!
const hoverTooltip = event.relatedTarget.nodeName === "rect" || event.relatedTarget.nodeName === "tspan";
if (!hoverTooltip)
} | ||
|
||
export default function renderTooltip( | ||
svg: d3.Selection<SVGGElement | null, unknown, null, undefined>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
renderTooltip
을 호출하는 쪽에서 타입 가드하면 여기 타입을 좁힐 수 있을 거 같지만..아직 D3 타입이 익숙하지 않아서 모르겠네요. 나중에 개선하면 좋을 것 같아요!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
맞아요ㅠㅠ 저도 이걸로 고민했는데 당장은 떠오르지 않아서 우선 IDE에 뜨는 타입대로 작성하였습니다! 추후에 수정해볼게요!
// 투명한 네모를 위에 위치시키기 | ||
tooltip | ||
.append("rect") | ||
.attr("width", 30) | ||
.attr("height", 30) | ||
// 요기 바꿔보심 돼여 | ||
.attr("fill", "transparent") | ||
.style("cursor", "pointer") | ||
.attr("transform", transparentRectPosition); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이런 방법도 있네요 굿굿!👍👍👍👍
|
||
let start = 0; | ||
let end = tspanMaxWidth; | ||
let mid; | ||
while (start < end) { | ||
mid = Math.floor((start + end) / 2); | ||
const truncatedText = `${originalText.slice(0, mid)}...`; | ||
currentValueNode.text(truncatedText); // Set text here for width calculation | ||
const textWidth = | ||
currentValueNode?.node()?.getComputedTextLength() || 0; | ||
if (textWidth > tspanMaxWidth) { | ||
end = mid; | ||
} else { | ||
start = mid + 1; | ||
} | ||
} | ||
const truncatedText = `${originalText.slice(0, start - 1)}...`; | ||
currentValueNode.text(truncatedText); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
말줄임에 이분 탐색이 사용되다니 신기해요!!
tspan 너비를 안 넘어갈 때까지 반복하면서 텍스트를 자르는 건가요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
네 맞습니다!!🤩
tspan의 너비를 잴 수 있는 방법이나 메서드가 뚜렷하지 않아 추가하게 되었습니다!
const tooltipDataFormat = [ | ||
{ | ||
text: "Commit Hash: ", | ||
value: d.data.id.slice(0, 7), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
해시 7자리만 보여주는 거 너무 좋아요!
09db8f1✨ |
a7851f4
to
64f816c
Compare
close #254
✅ 작업 내용
기존 텍스트 노드 삭제 후 툴팁 추가
툴팁, circle에서 툴팁으로 가는 경로에 hover하면 꺼지지 않도록, 그리고 요소에 mouseout되면 꺼지도록 구현
이게 가장 큰 어려움이였는데, 툴팁으로 가는 경로에 투명한 rect svg 요소를 넣어서 해결할 수 있었습니다!
(테스트용으로 border 처리해놓은 rect입니다)
그리고 노드 자체에 mouseout 이벤트를 넣어 노드가 호버된게 아니라면 툴팁을 지우도록 구현하였습니다!
📸 스크린샷(FE만)
📌 이슈 사항
🟢 완료 조건
✍ 궁금한 점