From 83e41b214867dc8b7fa12f54b9b26633ad965d20 Mon Sep 17 00:00:00 2001 From: Hristo Nedelkov Date: Fri, 11 Aug 2023 13:34:18 +0300 Subject: [PATCH] Use double chart and remove stream --- src/components/DeviceNetworkHealth.tsx | 19 ++++++++--- src/components/LandingPage.tsx | 5 ++- src/components/StandardLineChart.tsx | 6 ++-- src/components/StandartStream.tsx | 44 +++----------------------- 4 files changed, 26 insertions(+), 48 deletions(-) diff --git a/src/components/DeviceNetworkHealth.tsx b/src/components/DeviceNetworkHealth.tsx index d1c4f229..0c808a88 100644 --- a/src/components/DeviceNetworkHealth.tsx +++ b/src/components/DeviceNetworkHealth.tsx @@ -16,14 +16,23 @@ type ChartData = { } type DeviceNetworkHealthProps = { - load: number[] + uploadRate: number[] + downloadRate: number[] } -const DeviceNetworkHealth: React.FC = ({ load }) => { +const DeviceNetworkHealth: React.FC = ({ uploadRate, downloadRate }) => { const chartData: ChartData[] = [ { - id: 'cpu', + id: 'uploadRate', color: '#8DC6BC', - data: load.map((yValue, index: number) => ({ + data: uploadRate.map((yValue, index: number) => ({ + x: index + 1, + y: yValue, + })), + }, + { + id: 'downloadRate', + color: '#D92344', + data: downloadRate.map((yValue, index: number) => ({ x: index + 1, y: yValue, })), @@ -45,7 +54,7 @@ const DeviceNetworkHealth: React.FC = ({ load }) => { }} >
- +
diff --git a/src/components/LandingPage.tsx b/src/components/LandingPage.tsx index bdfe9e89..5dee6841 100644 --- a/src/components/LandingPage.tsx +++ b/src/components/LandingPage.tsx @@ -96,7 +96,10 @@ function Content() { Discover Nodes - + ) } diff --git a/src/components/StandardLineChart.tsx b/src/components/StandardLineChart.tsx index 43aee4ee..7de2199b 100644 --- a/src/components/StandardLineChart.tsx +++ b/src/components/StandardLineChart.tsx @@ -6,6 +6,7 @@ interface DataPoint { interface ChartData { id: string + color: string data: DataPoint[] } @@ -13,6 +14,8 @@ interface StandartLineChartProps { data: ChartData[] } const StandartLineChart = ({ data }: StandartLineChartProps) => { + const colors = data.map(dataset => dataset.color) + return ( { pointSize={1} pointColor={{ theme: 'background' }} pointBorderWidth={2} - pointBorderColor={{ from: 'serieColor' }} pointLabelYOffset={-12} useMesh={true} legends={[]} - colors={['#8DC6BC']} + colors={colors} /> ) } diff --git a/src/components/StandartStream.tsx b/src/components/StandartStream.tsx index 9130d659..606276ba 100644 --- a/src/components/StandartStream.tsx +++ b/src/components/StandartStream.tsx @@ -57,29 +57,15 @@ const MyResponsiveStream = () => { Jacques: 167, }, { - Raoul: 60, + Raoul: 800, Josiane: 67, Marcel: 23, René: 174, Paul: 190, Jacques: 86, }, - { - Raoul: 53, - Josiane: 168, - Marcel: 76, - René: 128, - Paul: 118, - Jacques: 43, - }, - { - Raoul: 159, - Josiane: 22, - Marcel: 192, - René: 60, - Paul: 99, - Jacques: 135, - }, + + ] return ( { axisLeft={null} enableGridY={false} offsetType="silhouette" - colors={{ scheme: 'purple_orange' }} - borderColor={{ theme: 'background' }} - defs={[ - { - id: 'dots', - type: 'patternDots', - background: 'inherit', - color: '#2c998f', - size: 4, - padding: 2, - stagger: true, - }, - { - id: 'squares', - type: 'patternSquares', - background: 'inherit', - color: '#e4c912', - size: 6, - padding: 2, - stagger: true, - }, - ]} dotSize={8} dotColor={{ from: 'color' }} dotBorderWidth={2} dotBorderColor={{ from: 'color', - modifiers: [['darker', 0.7]], + modifiers: [['darker', 1]], }} isInteractive={false} enableStackTooltip={false}