diff --git a/src/features/edge-detail/components/ArchiveView.tsx b/src/features/edge-detail/components/ArchiveView.tsx index 9c5909d..d19bfe6 100644 --- a/src/features/edge-detail/components/ArchiveView.tsx +++ b/src/features/edge-detail/components/ArchiveView.tsx @@ -4,8 +4,9 @@ import { useRef } from 'react'; import { CalendarDays, CalendarClock, Check, ChevronDown, Clock3, DatabaseZap, Search } from 'lucide-react'; import type { CurrentItem } from '../../../entities/current/types'; import { HistoryChart } from '../../../features/history-chart/HistoryChart'; +import type { HistoryZoomRange } from '../../../features/history-chart/chartTypes'; import { RANGE_PRESETS, createRange, type DateRangeState } from '../../../features/history/dateRange'; -import { toIsoFromInput } from '../../../utils/format'; +import { toInputDateTimeValue, toIsoFromInput } from '../../../utils/format'; import type { HistoryGranularity } from '../../../utils/historyGranularity'; type ArchiveViewProps = { @@ -108,6 +109,12 @@ export function ArchiveView({ [rangePart]: updateRangeInputPart(range[rangePart], inputPart, value), }); }; + const updateRangeFromZoom = (nextRange: HistoryZoomRange) => { + onRangeChange({ + from: toInputDateTimeValue(new Date(nextRange.from)), + to: toInputDateTimeValue(new Date(nextRange.to)), + }); + }; return (
@@ -263,6 +270,7 @@ export function ArchiveView({ labelFormat={historyAxis.labelFormat} tags={selectedTags} tagLabels={tagLabels} + onZoomRangeChange={updateRangeFromZoom} /> ) : (
Разверните список показателей и выберите серию для графика
diff --git a/src/features/history-chart/HistoryChart.tsx b/src/features/history-chart/HistoryChart.tsx index dd66c93..45b9e6c 100644 --- a/src/features/history-chart/HistoryChart.tsx +++ b/src/features/history-chart/HistoryChart.tsx @@ -15,6 +15,7 @@ type HistoryChartProps = { tickIntervalMs?: number; to: string; tagLabels?: Record; + onZoomRangeChange?: (range: HistoryZoomRange) => void; }; const ZOOM_REQUEST_DELAY_MS = 350; @@ -95,6 +96,7 @@ export function HistoryChart({ tickIntervalMs, to, tagLabels = {}, + onZoomRangeChange, }: HistoryChartProps) { const [zoomRange, setZoomRange] = useState(() => createInitialZoomRange({ from, granulate, labelFormat, tickIntervalMs, to }), @@ -167,8 +169,9 @@ export function HistoryChart({ zoomTimerRef.current = setTimeout(() => { zoomRangeRef.current = nextRange; setZoomRange(nextRange); + onZoomRangeChange?.(nextRange); }, ZOOM_REQUEST_DELAY_MS); - }, []); + }, [onZoomRangeChange]); return (