CF2-7: Добавлены стрелки роста/убывания в компонент DisplayValue

This commit is contained in:
KharchenkoVV 2021-05-24 15:19:38 +05:00
parent 0c351640cd
commit 3274fca6a8
2 changed files with 18 additions and 6 deletions

View File

@ -1,13 +1,25 @@
export const ValueDisplay = ({prefix, value, suffix}) =>{
let val = '---'
import { useState } from 'react';
import {CaretUpOutlined, CaretDownOutlined} from '@ant-design/icons'
export const ValueDisplay = ({prefix, value, suffix, isArrowVisible}) =>{
const [oldVal, setOldVal] = useState(NaN)
let val = '---'
let arrow = null
if(value)
if(Number.isFinite(+value))
if(Number.isFinite(+value)){
val = (+value).toPrecision(4)??'---'
else
if (isArrowVisible)
{
arrow = value > oldVal
? <CaretUpOutlined style={{color:"red"}} onClick={!isArrowVisible} />
: <CaretDownOutlined style={{color:"red"}} onClick={!isArrowVisible} />
setOldVal(value)
}
} else
val = value
return(<span className='display_value'>{prefix} {val} {suffix}</span>)
return(<span className='display_value'>{prefix} {val} {suffix}{arrow}</span>)
}
export const Display = (props)=>{

View File

@ -97,7 +97,7 @@ export const Column = ({ lineGroup, data, interval }) => {
<Display
label={lineGroup.label}
value={pv}
suffix={lineGroup.linePv?.units} />
suffix={lineGroup.linePv?.units} isArrowVisible={true}/>
<ChartTimeOnline
data={data}
yDisplay={lineGroup.yDisplay}