You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
46 lines
1.6 KiB
TypeScript
46 lines
1.6 KiB
TypeScript
// frontend/components/research/ChartCard.tsx — 시각화 + 추세 예측 (예측 막대)
|
|
"use client";
|
|
import { Icon } from "@/components/Icon";
|
|
import { sanitizeHtml } from "@/lib/research/sanitize";
|
|
import type { ResearchChart } from "@/lib/types";
|
|
|
|
export function ChartCard({ chart }: { chart?: ResearchChart }) {
|
|
if (!chart || chart.bars.length === 0) return <div className="rs-card rs-skel" aria-busy="true" />;
|
|
const c = chart;
|
|
const max = Math.max(...c.bars.map((b) => b.v));
|
|
return (
|
|
<section className="rs-card">
|
|
<div className="rs-ch">
|
|
<span className="rs-ci tone-coral">
|
|
<Icon name="chart" />
|
|
</span>
|
|
<div className="rs-cht">
|
|
<span className="rs-k">시각화 & 추세 예측</span>
|
|
<h2>{c.title}</h2>
|
|
<span className="rs-sub">{c.asked}</span>
|
|
</div>
|
|
</div>
|
|
<div
|
|
className="rs-chart"
|
|
role="img"
|
|
aria-label="연도별 매출 막대 차트, 마지막 막대는 예측치"
|
|
>
|
|
{c.bars.map((b, i) => (
|
|
<div key={i} className={"rs-bar" + (b.forecast ? " forecast" : "")}>
|
|
<span className="rs-bv mono">{b.v}</span>
|
|
<div className="rs-bcol" style={{ height: Math.round((b.v / max) * 100) + "%" }}>
|
|
{b.forecast && <span className="rs-btag">예측</span>}
|
|
</div>
|
|
<span className="rs-by">{b.y}</span>
|
|
</div>
|
|
))}
|
|
</div>
|
|
<p className="rs-insight" dangerouslySetInnerHTML={{ __html: sanitizeHtml(c.insight) }} />
|
|
<div className="rs-note">
|
|
<Icon name="clock" />
|
|
{c.caution}
|
|
</div>
|
|
</section>
|
|
);
|
|
}
|