forked from ddrilling/asb_cloud_front
CF2-7: Добавлены стрелки роста/убывания в компонент DisplayValue
This commit is contained in:
parent
0c351640cd
commit
3274fca6a8
@ -1,13 +1,25 @@
|
|||||||
export const ValueDisplay = ({prefix, value, suffix}) =>{
|
import { useState } from 'react';
|
||||||
let val = '---'
|
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(value)
|
||||||
if(Number.isFinite(+value))
|
if(Number.isFinite(+value)){
|
||||||
val = (+value).toPrecision(4)??'---'
|
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
|
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)=>{
|
export const Display = (props)=>{
|
||||||
|
@ -97,7 +97,7 @@ export const Column = ({ lineGroup, data, interval }) => {
|
|||||||
<Display
|
<Display
|
||||||
label={lineGroup.label}
|
label={lineGroup.label}
|
||||||
value={pv}
|
value={pv}
|
||||||
suffix={lineGroup.linePv?.units} />
|
suffix={lineGroup.linePv?.units} isArrowVisible={true}/>
|
||||||
<ChartTimeOnline
|
<ChartTimeOnline
|
||||||
data={data}
|
data={data}
|
||||||
yDisplay={lineGroup.yDisplay}
|
yDisplay={lineGroup.yDisplay}
|
||||||
|
Loading…
Reference in New Issue
Block a user