diff --git a/frontend/src/pages/CompanyDetail.tsx b/frontend/src/pages/CompanyDetail.tsx index 5c043dd..f6c1093 100644 --- a/frontend/src/pages/CompanyDetail.tsx +++ b/frontend/src/pages/CompanyDetail.tsx @@ -602,13 +602,46 @@ interface ChartPoint { price?: number; } +function ChartXTick({ x, y, payload }: { x?: number; y?: number; payload?: { value: number } }) { + if (!payload || !x || !y) return null; + const d = new Date(payload.value); + const hour = d.getHours(); + const minute = d.getMinutes(); + const isNewDay = hour === 0 && minute < 30; + const isHourMark = minute < 15; // Show only on-the-hour ticks + + // For date labels (new day boundary) + if (isNewDay) { + const label = d.toLocaleDateString('en-US', { month: 'short', day: 'numeric' }); + return ( + + + {label} + + + ); + } + + // For time labels — show rounded hours at an angle + if (!isHourMark) return null; + const timeStr = d.toLocaleTimeString('en-US', { hour: 'numeric', minute: '2-digit' }); + return ( + + + {timeStr} + + + ); +} + function TrendTooltip({ active, payload, label }: Record) { if (!active) return null; const items = payload as Array<{ name: string; value: number; color: string; dataKey: string }> | undefined; if (!items?.length) return null; + const ts = typeof label === 'number' ? new Date(label).toLocaleString('en-US', { month: 'short', day: 'numeric', hour: 'numeric', minute: '2-digit' }) : String(label ?? ''); return (
-
{String(label ?? '')}
+
{ts}
{items.map((item, i) => (
{item.name}: @@ -709,7 +742,7 @@ function TrendHistoryChart({ trends, latestTrends, ticker, marketPrices, selecte const trendTs = new Date(t.generated_at).getTime(); const price = findClosestPrice(trendTs); return { - time: new Date(t.generated_at).toLocaleDateString('en-US', { month: 'short', day: 'numeric', hour: '2-digit', minute: '2-digit' }), + time: String(trendTs), timestamp: trendTs, strength: +(t.trend_strength * 100).toFixed(1), confidence: +(t.confidence * 100).toFixed(1), @@ -766,12 +799,16 @@ function TrendHistoryChart({ trends, latestTrends, ticker, marketPrices, selecte Trend Strength & Confidence — {ticker} / {selectedWindow} - + } tickLine={{ stroke: '#475569' }} + interval="preserveStartEnd" /> +
{i % Math.max(1, Math.floor(chartData.length / 8)) === 0 && ( - {pt.time} + {new Date(pt.timestamp).toLocaleTimeString('en-US', { hour: 'numeric', minute: '2-digit' })} )}
);