From c8e985ca69989afc52005a64f14b0dc77773d5cc Mon Sep 17 00:00:00 2001 From: bracesproul Date: Thu, 6 Mar 2025 19:23:09 -0800 Subject: [PATCH] fix: improve stock price ui --- agent/uis/stockbroker/stock-price/index.tsx | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/agent/uis/stockbroker/stock-price/index.tsx b/agent/uis/stockbroker/stock-price/index.tsx index f4caae8..1c1ea52 100644 --- a/agent/uis/stockbroker/stock-price/index.tsx +++ b/agent/uis/stockbroker/stock-price/index.tsx @@ -138,6 +138,16 @@ export default function StockPrice(props: { }; }, [oneDayPrices, thirtyDayPrices, displayRange]); + const formatDateByDisplayRange = (value: string, isTooltip?: boolean) => { + if (displayRange === "1d") { + return format(value, "h:mm a"); + } + if (isTooltip) { + return format(value, "LLL do h:mm a"); + } + return format(value, "LLL do"); + }; + return (
@@ -180,7 +190,7 @@ export default function StockPrice(props: { tickLine={false} axisLine={false} tickMargin={8} - tickFormatter={(value) => format(value, "h:mm a")} + tickFormatter={(v) => formatDateByDisplayRange(v)} /> format(value, "h:mm a")} + labelFormatter={(v) => formatDateByDisplayRange(v, true)} /> } />