diff --git a/src/pages/Telemetry/Archive/index.jsx b/src/pages/Telemetry/Archive/index.jsx index 3e874e2..10cc15d 100755 --- a/src/pages/Telemetry/Archive/index.jsx +++ b/src/pages/Telemetry/Archive/index.jsx @@ -86,8 +86,8 @@ const interpolationSearch = (data, begin, end, accessor) => { } return x } - let x0 = findIdx(begin, 0, 5) - let x1 = findIdx(end, x0, 3) + let x0 = findIdx(begin, 0, 100) + let x1 = findIdx(end, x0, 100) return { start: x0, end: x1, count: x1 - x0 } } @@ -109,12 +109,12 @@ const Archive = memo(() => { const idWell = useIdWell() const [search, setSearchParams] = useSearchParams() - + const getInitialRange = useCallback(() => parseInt(search.get('range') ?? defaultPeriod) * 1000, [search]) - const getInitialDate = useCallback(() => new Date(search.get('start') ?? (Date.now() - chartInterval)), [search]) const [scrollPercent, setScrollPercent] = useState(0.15) const [chartInterval, setChartInterval] = useState(getInitialRange) + const getInitialDate = useCallback(() => new Date(search.get('start') ?? (Date.now() - chartInterval)), [search, chartInterval]) const [startDate, setStartDate] = useState(getInitialDate) const onGraphWheel = useCallback((e) => { @@ -133,7 +133,7 @@ const Archive = memo(() => { if (!date) return false const dt = new Date(date).setHours(0, 0, 0, 0) return dt < dateLimit.from || dt > +dateLimit.to - chartInterval - }, [dateLimit]) + }, [dateLimit, chartInterval]) const isDateTimeDisabled = useCallback((date) => ({ disabledHours: () => range(24).filter(h => { @@ -151,7 +151,7 @@ const Archive = memo(() => { const dt = +new Date(date).setSeconds(s) return dt < dateLimit.from || dt > +dateLimit.to - chartInterval }) - }), [dateLimit]) + }), [dateLimit, chartInterval]) useEffect(() => { const params = {} @@ -189,11 +189,11 @@ const Archive = memo(() => { invokeWebApiWrapperAsync( async () => { const data = await TelemetryDataSaubService.getData(idWell, loadingStartDate.toISOString(), loadingInterval, DATA_COUNT) - + const loadedStartDate = new Date(Math.max(+newLoaded.start, +startDate - chartInterval * ADDITIVE_PAGES)) const loadedEndDate = new Date(Math.min(+newLoaded.end, +startDate + chartInterval * (ADDITIVE_PAGES + 1))) setLoaded({ start: loadedStartDate, end: loadedEndDate }) - + if (data) { data.forEach(elm => elm.date = new Date(elm.date)) setDataSaub((prevDataSaub) => { @@ -202,7 +202,7 @@ const Archive = memo(() => { return cutData(newData, loadedStartDate, loadedEndDate) }) } - + }, setShowLoader, `Не удалось загрузить данные по скважине "${idWell}" c ${startDate.toISOString()} по ${new Date(+startDate + chartInterval).toISOString()}`, @@ -213,6 +213,7 @@ const Archive = memo(() => { const onRangeChange = useCallback((value) => { setChartInterval(value * 1000) setDataSaub([]) + setLoaded(null) }, []) const domain = useMemo(() => ({ min: startDate, max: new Date(+startDate + chartInterval)}), [startDate, chartInterval])