From 8efb1bbb4d4c9b0f5fb74175ae17cac6f835a180 Mon Sep 17 00:00:00 2001 From: goodmice Date: Tue, 23 Nov 2021 15:58:10 +0500 Subject: [PATCH] =?UTF-8?q?=D0=A1=D0=BA=D0=BE=D0=BB=D0=BB=20=D0=B0=D1=80?= =?UTF-8?q?=D1=85=D0=B8=D0=B2=D0=B0=20=D0=B1=D0=BB=D0=BE=D0=BA=D0=B8=D1=80?= =?UTF-8?q?=D1=83=D0=B5=D1=82=D1=81=D1=8F,=20=D0=B5=D1=81=D0=BB=D0=B8=20?= =?UTF-8?q?=D0=B4=D0=B0=D0=BD=D0=BD=D1=8B=D1=85=20=D0=BD=D0=B5=D1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/charts/ChartTimeBase.tsx | 11 ++++------- src/pages/Archive/index.jsx | 13 +++++-------- 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/src/components/charts/ChartTimeBase.tsx b/src/components/charts/ChartTimeBase.tsx index 783aa77..596e6a1 100644 --- a/src/components/charts/ChartTimeBase.tsx +++ b/src/components/charts/ChartTimeBase.tsx @@ -215,15 +215,12 @@ export const ChartTimeBase: React.FC = ({options, dataParams if (!chart) return; chart.data = dataParams.data if(dataParams.yStart){ - const start = new Date(dataParams.yStart) - const end = new Date(dataParams.yStart) - const interval = Number(dataParams.yInterval ?? 600) - end.setSeconds(end.getSeconds() + interval) - const { unit, stepSize } = timeParamsByInterval(interval) + const interval = Number(dataParams.yInterval ?? 600_000) + const { unit, stepSize } = timeParamsByInterval(Number(interval / 1000)) if(chart.options.scales?.y){ - chart.options.scales.y.max = end.getTime() - chart.options.scales.y.min = start.getTime() + chart.options.scales.y.max = +dataParams.yStart + interval + chart.options.scales.y.min = +dataParams.yStart chart.options.scales.y.ticks.display = dataParams.displayLabels ?? true chart.options.scales.y.time.unit = unit chart.options.scales.y.time.stepSize = stepSize diff --git a/src/pages/Archive/index.jsx b/src/pages/Archive/index.jsx index 4cdc67b..4bac585 100644 --- a/src/pages/Archive/index.jsx +++ b/src/pages/Archive/index.jsx @@ -69,7 +69,7 @@ export default function Archive({idWell}) { const [loaded, setLoaded] = useState(null) const onGraphWheel = (e) => { - if (loaded) { + if (loaded && dateLimit.from && dateLimit.to) { setStartDate((prevStartDate) => { const offset = e.deltaY * chartInterval * WHEEL_SENSITIVITY const nextStartDate = +prevStartDate + offset @@ -105,13 +105,10 @@ export default function Archive({idWell}) { useEffect(() => invokeWebApiWrapperAsync( async () => { - let dates = await TelemetryDataSaubService.getDataDatesRange(idWell) - if (!dates) dates = {} - dates.from = new Date(dates.from ?? (Date.now() - chartInterval)) - dates.to = new Date(dates.to ?? Date.now()) - const startDate = new Date(Math.max(dates.from, +dates.to - chartInterval)) - setStartDate(new Date(startDate)) - setDateLimit(dates) + const dates = await TelemetryDataSaubService.getDataDatesRange(idWell) + const startDate = dates && Math.max(dates.from, +dates.to - chartInterval) + setDateLimit(dates ?? { from: 0, to: 0 }) + setStartDate(new Date(startDate || (Date.now() - chartInterval))) }, setShowLoader, `Не удалось загрузить диапозон телеметрии для скважины "${idWell}"`