From 34458c1676cde08149894aa4768e7df358a7d019 Mon Sep 17 00:00:00 2001 From: Gabe Kangas Date: Wed, 28 Oct 2020 19:28:52 -0700 Subject: [PATCH] Combine hardware graphs into a single graph --- web/pages/components/chart.tsx | 26 ++++++++++++++++++++++++-- web/pages/hardware-info.tsx | 26 ++++++++++++++++++++------ 2 files changed, 44 insertions(+), 8 deletions(-) diff --git a/web/pages/components/chart.tsx b/web/pages/components/chart.tsx index 89b5dff2b..f7d1a6d83 100644 --- a/web/pages/components/chart.tsx +++ b/web/pages/components/chart.tsx @@ -14,6 +14,7 @@ interface ChartProps { data: number, color: string, unit: string, + dataCollections?: [], } function CustomizedTooltip(props: ToolTipProps) { @@ -32,21 +33,30 @@ function CustomizedTooltip(props: ToolTipProps) { } CustomizedTooltip.defaultProps = defaultProps; -export default function Chart({ data, color, unit }: ChartProps) { +export default function Chart({ data, color, unit, dataCollections }: ChartProps) { const timeFormatter = (tick: string) => { return timeFormat("%I:%M")(new Date(tick)); }; + if (dataCollections) { + var ticks = dataCollections[0]?.data.map(function (collection) { + return collection?.time; + }) + } else { + var ticks = data.map(function (item) { + return item?.time; + }); + } return ( + {dataCollections?.map((s) => ( + + ))} ); } diff --git a/web/pages/hardware-info.tsx b/web/pages/hardware-info.tsx index de348933d..3ffb151d0 100644 --- a/web/pages/hardware-info.tsx +++ b/web/pages/hardware-info.tsx @@ -45,6 +45,25 @@ export default function HardwareInfo() { hardwareStatus.memory[hardwareStatus.memory.length - 1]?.value; const currentDiskUsage = hardwareStatus.disk[hardwareStatus.disk.length - 1]?.value; + +const series = [ + { + name: "CPU", + color: "#FF7700", + data: hardwareStatus.cpu, + }, + { + name: "Memory", + color: "#004777", + data: hardwareStatus.memory, + }, + { + name: "Disk", + color: "#A9E190", + data: hardwareStatus.disk, + }, +]; + return (
@@ -68,12 +87,7 @@ export default function HardwareInfo() {
-

CPU

- -

Memory

- -

Disk

- +

cpu:[], disk: [], memory: []; value = %age.