From c9f28a45aff443c42061183997f2b00e37974814 Mon Sep 17 00:00:00 2001 From: goodmice Date: Tue, 19 Jul 2022 15:01:20 +0500 Subject: [PATCH] =?UTF-8?q?=D0=90=D1=80=D1=85=D0=B8=D0=B2:=20*=20=D0=98?= =?UTF-8?q?=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=D0=B0=20=D0=BE?= =?UTF-8?q?=D1=88=D0=B8=D0=B1=D0=BA=D0=B0=20=D0=BF=D1=80=D0=B8=20=D0=BF?= =?UTF-8?q?=D0=B5=D1=80=D0=B5=D0=BA=D0=BB=D1=8E=D1=87=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D0=B8=20=D0=BF=D0=B5=D1=80=D0=B8=D0=BE=D0=B4=D0=B0=20*=20?= =?UTF-8?q?=D0=9F=D0=BE=D0=B4=D0=BA=D0=BE=D1=80=D1=80=D0=B5=D0=BA=D1=82?= =?UTF-8?q?=D0=B8=D1=80=D0=BE=D0=B2=D0=B0=D0=BD=D0=B0=20=D1=80=D0=B0=D0=B1?= =?UTF-8?q?=D0=BE=D1=82=D0=B0=20=D0=B8=D0=BD=D1=82=D0=B5=D1=80=D0=BF=D0=BE?= =?UTF-8?q?=D0=BB=D1=8F=D1=86=D0=B8=D0=BE=D0=BD=D0=BD=D0=BE=D0=B3=D0=BE=20?= =?UTF-8?q?=D0=BF=D0=BE=D0=B8=D1=81=D0=BA=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/Telemetry/Archive/index.jsx | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) 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])