This commit is contained in:
Hristo Nedelkov 2023-08-10 09:07:24 +03:00
parent f2cb3eaa7e
commit 4065c125b0
2 changed files with 11 additions and 10 deletions

View File

@ -9,10 +9,10 @@ interface Serie {
data: DataPoint[] data: DataPoint[]
} }
interface MyResponsiveLineProps { interface StandartLineChartProps {
data: Serie[] data: Serie[]
} }
const MyResponsiveLine = ({ data }: MyResponsiveLineProps) => { const StandartLineChart = ({ data }: StandartLineChartProps) => {
return ( return (
<ResponsiveLine <ResponsiveLine
data={data} data={data}
@ -43,4 +43,4 @@ const MyResponsiveLine = ({ data }: MyResponsiveLineProps) => {
/> />
) )
} }
export default MyResponsiveLine export default StandartLineChart

View File

@ -1,6 +1,6 @@
import { useState, useEffect } from 'react' import { useState, useEffect } from 'react'
import MyResponsiveLine from './StandardLineChart' import StandartLineChart from './StandardLineChart'
import ShadowBox from './ShadowBox' import ShadowBox from './ShadowBox'
import IconText from './IconText' import IconText from './IconText'
import { Paragraph, Separator, XStack, YStack } from 'tamagui' import { Paragraph, Separator, XStack, YStack } from 'tamagui'
@ -56,17 +56,18 @@ const data = [
}, },
{ {
x: '12', x: '12',
y: 5, y: 132,
}, },
], ],
}, },
] ]
const DeviceCPULoad = () => { const DeviceCPULoad = () => {
const [message, setMessage] = useState('') const [message, setMessage] = useState('')
const currentLoad = { y: 9 } const currentLoad = data[0].data[data[0].data.length - 1].y
console.log(currentLoad)
useEffect(() => { useEffect(() => {
currentLoad.y > 80 ? setMessage('Good') : setMessage('Poor') currentLoad < 80 ? setMessage('Good') : setMessage('Poor')
}, [currentLoad]) }, [currentLoad])
console.log(currentLoad) console.log(currentLoad)
@ -81,7 +82,7 @@ const DeviceCPULoad = () => {
}} }}
> >
<div style={{ position: 'absolute', top: 0, left: 0, right: 0, bottom: 0 }}> <div style={{ position: 'absolute', top: 0, left: 0, right: 0, bottom: 0 }}>
<MyResponsiveLine data={data} /> <StandartLineChart data={data} />
</div> </div>
<YStack space={'$3'}> <YStack space={'$3'}>
@ -89,7 +90,7 @@ const DeviceCPULoad = () => {
CPU CPU
</Paragraph> </Paragraph>
<Paragraph color={'#09101C'} size={'$8'} fontWeight={'700'}> <Paragraph color={'#09101C'} size={'$8'} fontWeight={'700'}>
{currentLoad.y} GB {currentLoad} GB
</Paragraph> </Paragraph>
</YStack> </YStack>
{message} {message}
@ -97,7 +98,7 @@ const DeviceCPULoad = () => {
<Separator borderColor={'#e3e3e3'} /> <Separator borderColor={'#e3e3e3'} />
<XStack space={'$4'} style={{ padding: '10px 16px 10px 16px' }}> <XStack space={'$4'} style={{ padding: '10px 16px 10px 16px' }}>
<IconText icon={message === 'Good' ? '/icons/check-circle.png' : '/icons/alert.png'}> <IconText icon={message === 'Good' ? '/icons/check-circle.png' : '/icons/alert.png'}>
{'Good'} {message}
</IconText> </IconText>
{/*THIS IS USED FOR ADDITIONAL TEXT <Text color={'#E95460'}>{'GOod'}</Text> */} {/*THIS IS USED FOR ADDITIONAL TEXT <Text color={'#E95460'}>{'GOod'}</Text> */}
</XStack> </XStack>