сортировка по дате теперь используется из фабрики

This commit is contained in:
goodmice 2021-11-15 16:13:12 +05:00
parent 95cfc93048
commit c5c134071f
3 changed files with 6 additions and 5 deletions

View File

@ -55,7 +55,7 @@ export const ArchiveDisplay = ({data, startDate, interval, onWheel}) => {
style={{ width: '15vw' }}
data={chartData}
lineGroup={group}
interval={interval / 1000}
interval={Math.round(interval / 1000)}
headerHeight={'50px'}
yStart={startDate}
/>

View File

@ -7,7 +7,8 @@ import LoaderPortal from '../../components/LoaderPortal'
import { Flex } from '../../components/Grid'
import { PeriodPicker, defaultPeriod } from '../../components/PeriodPicker'
import { ArchiveDisplay, cutData } from './ArchiveDisplay'
import { normalizeData, sortByDate } from '../TelemetryView'
import { normalizeData } from '../TelemetryView'
import { makeDateSorter } from '../../components/Table'
const DATA_COUNT = 2048 // Колличество точек на подгрузку графика
const ADDITIVE_PAGES = 2 // Дополнительные данные для графиков
@ -105,7 +106,7 @@ export default function Archive({idWell}) {
data.forEach(elm => elm.date = new Date(elm.date))
setDataSaub((prevDataSaub) => {
const newData = [...prevDataSaub, ...normalizeData(data)]
newData.sort(sortByDate)
newData.sort(makeDateSorter('date'))
return cutData(newData, loadedStartDate, loadedEndDate)
})
}

View File

@ -25,6 +25,7 @@ import SpinPicDisabled from '../../images/SpinDisabled.png'
import { PeriodPicker, defaultPeriod } from '../../components/PeriodPicker'
import '../../styles/message.css'
import { makeDateSorter } from '../../components/Table'
const { Option } = Select
@ -290,7 +291,6 @@ const getIndexOfDrillingBy = (dataSaub) => {
return order[idFeedRegulator] ?? -1
}
export const sortByDate = (a, b) => a.date > b.date ? 1 : -1
export const normalizeData = (data) => data?.map(item => ({
...item,
rotorSpeed: item.rotorSpeed < 1 ? 0 : item.rotorSpeed,
@ -309,7 +309,7 @@ export default function TelemetryView({ idWell }) {
const handleDataSaub = (data) => {
if (data) {
const dataSaub = normalizeData(data)
dataSaub.sort(sortByDate)
dataSaub.sort(makeDateSorter('date'))
setDataSaub(dataSaub)
}
}