Оптимизировано задание линий архива

This commit is contained in:
goodmice 2021-11-12 16:22:53 +05:00
parent 809dbb42fb
commit f9d019ffda

View File

@ -1,14 +1,20 @@
import { useEffect, useState } from 'react'
import { Grid, GridItem } from '../../components/Grid'
import { Column } from '../../components/charts/Column'
export const ArchiveColumn = ({ lineGroup, data, interval, style, headerHeight, yStart }) => {
const dataLast = data?.[data.length - 1]
const pv = lineGroup.filter(line => line.showLabels).map(line => ({
color: line.color,
label: line.label,
unit: line.units,
value: dataLast?.[line.xAccessorName]
}))
const [lineGroupWithoutShapes, setLineGroupWithoutShapes] = useState([])
const [pv, setPV] = useState([])
useEffect(() => {
const lgws = lineGroup.filter(cfg => !cfg.isShape)
setLineGroupWithoutShapes(lgws)
setPV(lgws.filter(line => line.showLabels).map(line => ({
color: line.color,
label: line.label
})))
}, [lineGroup])
return (
<div style={style}>
@ -19,7 +25,7 @@ export const ArchiveColumn = ({ lineGroup, data, interval, style, headerHeight,
</Grid>
<Column
data={data}
lineGroup={lineGroup}
lineGroup={lineGroupWithoutShapes}
interval={interval}
yDisplay={false}
yStart={yStart}