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}"`