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)} /> } />