Colorize graph lines red if above "bad" threshold in Memory Card
This commit is contained in:
parent
46f297e060
commit
76a279b3dd
|
@ -22,21 +22,23 @@ type DeviceMemoryHealthProps = {
|
||||||
maxMemory: number
|
maxMemory: number
|
||||||
}
|
}
|
||||||
const DeviceMemoryHealth = ({ currentMemory, maxMemory }: DeviceMemoryHealthProps) => {
|
const DeviceMemoryHealth = ({ currentMemory, maxMemory }: DeviceMemoryHealthProps) => {
|
||||||
|
const dataObj = currentMemory.map((yValue, index: number) => ({
|
||||||
|
x: index + 1,
|
||||||
|
y: yValue,
|
||||||
|
}))
|
||||||
|
const currentLoad =
|
||||||
|
dataObj.length > 0 ? dataObj[dataObj.length - 1].y : 0
|
||||||
|
|
||||||
|
const message = currentLoad < maxMemory ? 'Good' : 'Poor'
|
||||||
|
|
||||||
const chartData: ChartData[] = [
|
const chartData: ChartData[] = [
|
||||||
{
|
{
|
||||||
id: 'cpu',
|
id: 'cpu',
|
||||||
color: '#8DC6BC',
|
color: message == 'Good' ? '#8DC6BC' : '#e95460',
|
||||||
data: currentMemory.map((yValue, index: number) => ({
|
data: dataObj,
|
||||||
x: index + 1,
|
|
||||||
y: yValue,
|
|
||||||
})),
|
|
||||||
maxValue: maxMemory,
|
maxValue: maxMemory,
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
const currentLoad =
|
|
||||||
chartData[0].data.length > 0 ? chartData[0].data[chartData[0].data.length - 1].y : 0
|
|
||||||
|
|
||||||
const message = currentLoad < maxMemory ? 'Good' : 'Poor'
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ShadowBox
|
<ShadowBox
|
||||||
|
|
Loading…
Reference in New Issue