From caf44695565481877f7e74c1ae13d4fc8ebd7c14 Mon Sep 17 00:00:00 2001 From: Hristo Nedelkov Date: Fri, 11 Aug 2023 14:16:20 +0300 Subject: [PATCH] Add maxMemory argument --- src/components/DeviceMemoryHealth.tsx | 9 ++++++--- src/components/LandingPage.tsx | 2 +- src/components/StandardLineChart.tsx | 7 +++++-- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/components/DeviceMemoryHealth.tsx b/src/components/DeviceMemoryHealth.tsx index b5857e22..c1cd0f22 100644 --- a/src/components/DeviceMemoryHealth.tsx +++ b/src/components/DeviceMemoryHealth.tsx @@ -12,20 +12,23 @@ type ChartData = { id: string color: string data: DataPoint[] + maxMemory?: number } type DeviceMemoryProps = { - load: number[] + currentMemory: number[] + maxMemory?: number } -const DeviceMemory: React.FC = ({ load }) => { +const DeviceMemory = ({ currentMemory, maxMemory }: DeviceMemoryProps) => { const chartData: ChartData[] = [ { id: 'cpu', color: '#8DC6BC', - data: load.map((yValue, index: number) => ({ + data: currentMemory.map((yValue, index: number) => ({ x: index + 1, y: yValue, })), + maxMemory: maxMemory, }, ] const currentLoad = diff --git a/src/components/LandingPage.tsx b/src/components/LandingPage.tsx index 25286f31..dd750b00 100644 --- a/src/components/LandingPage.tsx +++ b/src/components/LandingPage.tsx @@ -96,7 +96,7 @@ function Content() { Discover Nodes - + ) } diff --git a/src/components/StandardLineChart.tsx b/src/components/StandardLineChart.tsx index 43aee4ee..5662bee6 100644 --- a/src/components/StandardLineChart.tsx +++ b/src/components/StandardLineChart.tsx @@ -7,12 +7,15 @@ interface DataPoint { interface ChartData { id: string data: DataPoint[] + maxMemory?: number } interface StandartLineChartProps { data: ChartData[] } const StandartLineChart = ({ data }: StandartLineChartProps) => { + const maxMemory = data[0].maxMemory || 'auto' + return ( { xScale={{ type: 'linear', min: 0, max: data[0].data.length }} yScale={{ type: 'linear', - min: 'auto', - max: 'auto', + min: 0, + max: maxMemory, stacked: true, reverse: false, }}