fix: 순자산 차트 고/저점 — 장중가(마지막 점)가 극값일 때도 표시

기존엔 극값이 마지막 점이면 생략 → 저점이 현재값인 차트(가희 등)에서 저점 안 보임.
마지막 점 제외 조건 제거 → 장중가가 고/저점이어도 표시. 단 마지막 점이 신고가(ATH)면
신고가 링이 '고'를 대신(중복 방지).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
hyowons
2026-06-11 09:21:22 +09:00
parent 1c03a1a6af
commit bfb518307f
+8 -6
View File
@@ -3722,9 +3722,12 @@ def _render_net_worth_chart(series: list[tuple[str, int]], current_net: int | No
svg_parts.append( svg_parts.append(
f'<circle class="{last_dot_class}" cx="{last_x:.2f}" cy="{last_y:.2f}" r="3.6" fill="{line_color}"/>' f'<circle class="{last_dot_class}" cx="{last_x:.2f}" cy="{last_y:.2f}" r="3.6" fill="{line_color}"/>'
) )
# 고점 dot — 그려진 라인(plot_values) 의 max 시점에 노란 마커. 마지막 포인트와 같으면 last_dot 으로 충분해 생략. # 고/저점 dot — 장중가(마지막 점)가 극값일 때도 표시. last_dot 위에 색 점이 덮인다.
peak_i = max(range(len(plot_values)), key=lambda i: plot_values[i]) peak_i = max(range(len(plot_values)), key=lambda i: plot_values[i])
if peak_i != n - 1: low_i = min(range(len(plot_values)), key=lambda i: plot_values[i])
_is_ath = n >= 2 and plot_values[-1] > max(plot_values[:-1])
# 고점 — 단, 마지막 점이 신고가(ATH)면 신고가 링/라벨이 대신하므로 '고' 생략.
if not (peak_i == n - 1 and _is_ath):
peak_x, peak_y = pts[peak_i] peak_x, peak_y = pts[peak_i]
svg_parts.append( svg_parts.append(
f'<circle class="peak-dot" cx="{peak_x:.2f}" cy="{peak_y:.2f}" r="3.6" fill="#fbbf24"/>' f'<circle class="peak-dot" cx="{peak_x:.2f}" cy="{peak_y:.2f}" r="3.6" fill="#fbbf24"/>'
@@ -3732,9 +3735,8 @@ def _render_net_worth_chart(series: list[tuple[str, int]], current_net: int | No
svg_parts.append( svg_parts.append(
f'<text class="hl-label" x="{peak_x:.2f}" y="{max(peak_y - 10, T + 12):.2f}" text-anchor="middle" fill="#fbbf24" font-size="20" font-weight="700">고</text>' f'<text class="hl-label" x="{peak_x:.2f}" y="{max(peak_y - 10, T + 12):.2f}" text-anchor="middle" fill="#fbbf24" font-size="20" font-weight="700">고</text>'
) )
# 저점 dot — min 시점에 파란 마커 + '저' 라벨. 마지막/고점과 겹치면 생략. # 저점 — 고점과 다른 점일 때 (장중가가 저점이어도 표시).
low_i = min(range(len(plot_values)), key=lambda i: plot_values[i]) if low_i != peak_i:
if low_i != n - 1 and low_i != peak_i:
low_x, low_y = pts[low_i] low_x, low_y = pts[low_i]
svg_parts.append( svg_parts.append(
f'<circle class="low-dot" cx="{low_x:.2f}" cy="{low_y:.2f}" r="3.6" fill="#4a8cf0"/>' f'<circle class="low-dot" cx="{low_x:.2f}" cy="{low_y:.2f}" r="3.6" fill="#4a8cf0"/>'
@@ -3744,7 +3746,7 @@ def _render_net_worth_chart(series: list[tuple[str, int]], current_net: int | No
) )
# 신고가 마커 — 오늘(마지막) 그려진 값이 이전 모든 포인트를 strict 하게 초과하면 last dot 위에 금색 ring + 라벨. # 신고가 마커 — 오늘(마지막) 그려진 값이 이전 모든 포인트를 strict 하게 초과하면 last dot 위에 금색 ring + 라벨.
# per_period면 '역대 최고 기간 손익', 아니면 누적/순자산 신고가. # per_period면 '역대 최고 기간 손익', 아니면 누적/순자산 신고가.
if n >= 2 and plot_values[-1] > max(plot_values[:-1]): if _is_ath:
svg_parts.append( svg_parts.append(
f'<circle class="ath-ring" cx="{last_x:.2f}" cy="{last_y:.2f}" r="7" fill="none" ' f'<circle class="ath-ring" cx="{last_x:.2f}" cy="{last_y:.2f}" r="7" fill="none" '
f'stroke="#fbbf24" stroke-width="1.6"/>' f'stroke="#fbbf24" stroke-width="1.6"/>'