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

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