From 3274fca6a8cc30f8dc0db6be457cb124fa974349 Mon Sep 17 00:00:00 2001 From: KharchenkoVV Date: Mon, 24 May 2021 15:19:38 +0500 Subject: [PATCH] =?UTF-8?q?CF2-7:=20=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D1=8B=20=D1=81=D1=82=D1=80=D0=B5=D0=BB=D0=BA=D0=B8?= =?UTF-8?q?=20=D1=80=D0=BE=D1=81=D1=82=D0=B0/=D1=83=D0=B1=D1=8B=D0=B2?= =?UTF-8?q?=D0=B0=D0=BD=D0=B8=D1=8F=20=D0=B2=20=D0=BA=D0=BE=D0=BC=D0=BF?= =?UTF-8?q?=D0=BE=D0=BD=D0=B5=D0=BD=D1=82=20DisplayValue?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Display.jsx | 22 +++++++++++++++++----- src/pages/TelemetryView.jsx | 2 +- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/components/Display.jsx b/src/components/Display.jsx index e575953..d021b81 100644 --- a/src/components/Display.jsx +++ b/src/components/Display.jsx @@ -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 + ? + : + setOldVal(value) + } + } else val = value - return({prefix} {val} {suffix}) + return({prefix} {val} {suffix}{arrow}) } export const Display = (props)=>{ diff --git a/src/pages/TelemetryView.jsx b/src/pages/TelemetryView.jsx index 8dcb0aa..5e6e321 100644 --- a/src/pages/TelemetryView.jsx +++ b/src/pages/TelemetryView.jsx @@ -97,7 +97,7 @@ export const Column = ({ lineGroup, data, interval }) => { + suffix={lineGroup.linePv?.units} isArrowVisible={true}/>