diff --git a/frontend/src/components/LmeView.tsx b/frontend/src/components/LmeView.tsx index a26c11a..0f5a283 100644 --- a/frontend/src/components/LmeView.tsx +++ b/frontend/src/components/LmeView.tsx @@ -123,7 +123,6 @@ export function LmeView() { const [diagramData, setDiagramData] = useState(null); const [diagramLoading, setDiagramLoading] = useState(false); const [timeframe, setTimeframe] = useState("ENTIRE"); - const [offsetIndex, setOffsetIndex] = useState(0); // Visibility toggles for dual-series charts const [showPrice, setShowPrice] = useState(true); @@ -157,7 +156,6 @@ export function LmeView() { let alive = true; setDiagramLoading(true); - setOffsetIndex(0); setShowPrice(true); setShowStocks(true); @@ -199,7 +197,7 @@ export function LmeView() { return diagramData?.lines?.find((l) => l.series_type === "stocks"); }, [diagramData]); - // Filter main series by timeframe & offset + // Filter main series by timeframe const chartData = useMemo(() => { if (!diagramData?.lines?.length) return []; const baseLine = priceLine || diagramData.lines[0]; @@ -213,12 +211,8 @@ export function LmeView() { else if (timeframe === "2Y") sliceCount = 520; else if (timeframe === "ENTIRE") sliceCount = total; - const maxOffset = Math.max(0, total - sliceCount); - const effectiveOffset = Math.min(offsetIndex, maxOffset); - const end = total - effectiveOffset; - const start = Math.max(0, end - sliceCount); - - const windowPoints = baseLine.points.slice(start, end); + const start = Math.max(0, total - sliceCount); + const windowPoints = baseLine.points.slice(start); if (stockLine) { const stockMap = new Map(stockLine.points.map((p) => [p.x, p.y])); @@ -235,7 +229,7 @@ export function LmeView() { date_display: p.date_display, priceVal: p.y, })); - }, [diagramData, priceLine, stockLine, timeframe, offsetIndex]); + }, [diagramData, priceLine, stockLine, timeframe]); // Statistics calculation for the active window const stats = useMemo(() => { @@ -256,26 +250,6 @@ export function LmeView() { return { max, min, avg, diff, pct, first, last }; }, [chartData]); - const canStepPrev = useMemo(() => { - if (timeframe === "ENTIRE") return false; - const total = (priceLine || diagramData?.lines?.[0])?.points?.length || 0; - const count = timeframe === "3M" ? 65 : timeframe === "6M" ? 130 : timeframe === "1Y" ? 260 : 520; - return offsetIndex + count < total; - }, [timeframe, priceLine, diagramData, offsetIndex]); - - const canStepNext = useMemo(() => { - return offsetIndex > 0 && timeframe !== "ENTIRE"; - }, [offsetIndex, timeframe]); - - const stepWindow = (dir: "prev" | "next") => { - const step = timeframe === "3M" ? 22 : timeframe === "6M" ? 45 : timeframe === "1Y" ? 65 : 130; - if (dir === "prev") { - setOffsetIndex((prev) => prev + step); - } else { - setOffsetIndex((prev) => Math.max(0, prev - step)); - } - }; - const filteredMetals = useMemo(() => { if (!data?.metals) return []; if (!search.trim()) return data.metals; @@ -569,7 +543,9 @@ export function LmeView() { {/* Header */}
-
+
@@ -636,7 +612,7 @@ export function LmeView() {
راهنمای رنگ‌ها: - + {/* Price Line Toggle */} {priceLine && ( - {/* 3 months */} - - {/* Step Forwards */} -