Skip to content

Commit c1b8301

Browse files
committed
removed redundant code
1 parent 7af63fd commit c1b8301

2 files changed

Lines changed: 27 additions & 40 deletions

File tree

app/charts/AwsChart.tsx

Lines changed: 27 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,20 @@ import React, { useState } from 'react';
33
import Plot from 'react-plotly.js';
44
import { all, solo as soloStyle } from './sizeSwitch';
55

6-
// interface AwsCpuChartProps {
7-
// key: string;
8-
// renderService: string;
9-
// metric: string;
10-
// timeList: any;
11-
// valueList: any;
12-
// sizing: string;
13-
// colourGenerator: Function;
14-
// }
15-
166
interface SoloStyles {
177
height: number;
188
width: number;
199
}
2010

11+
interface IPlotlyData {
12+
name: any;
13+
x: any;
14+
y: any;
15+
type: any;
16+
mode: any;
17+
marker: { color: string };
18+
}
19+
2120
/**
2221
* @params props - the props object containing relevant data.
2322
* @desc Handles AWS Charts. Memoized component to generate an AWS chart with formatted data.
@@ -26,35 +25,31 @@ interface SoloStyles {
2625
const AwsChart: React.FC<any> = React.memo(props => {
2726
const { renderService, metric, timeList, valueList, colourGenerator, sizing } = props;
2827
const [solo, setSolo] = useState<SoloStyles | null>(null);
29-
28+
3029
setInterval(() => {
3130
if (solo !== soloStyle) {
3231
setSolo(soloStyle);
3332
}
3433
}, 20);
3534

36-
const createChart = () => {
37-
const timeArr = timeList?.map((el: any) => moment(el).format('kk:mm:ss'));
38-
// const hashedColour = colourGenerator(renderService);
39-
let plotlyData: {
40-
name: any;
41-
x: any;
42-
y: any;
43-
type: any;
44-
mode: any;
45-
marker: { color: string };
46-
};
47-
plotlyData = {
48-
name: metric,
49-
x: timeArr,
50-
y: valueList,
51-
type: 'scattergl',
52-
mode: 'lines',
53-
marker: { color: colourGenerator() },
54-
};
55-
const sizeSwitch = sizing === 'all' ? all : solo;
35+
const timeArr = timeList?.map((el: any) => moment(el).format('kk:mm:ss'));
36+
37+
let plotlyData:IPlotlyData= {
38+
name: metric,
39+
x: timeArr,
40+
y: valueList,
41+
type: 'scattergl',
42+
mode: 'lines',
43+
marker: { color: colourGenerator() },
44+
};
5645

57-
return (
46+
const sizeSwitch = sizing === 'all' ? all : solo;
47+
48+
return (
49+
<div
50+
className="chart"
51+
data-testid="Health Chart"
52+
>
5853
<Plot
5954
data={[plotlyData]}
6055
config={{ displayModeBar: false }}
@@ -91,12 +86,6 @@ const AwsChart: React.FC<any> = React.memo(props => {
9186
},
9287
}}
9388
/>
94-
);
95-
};
96-
97-
return (
98-
<div className="chart" data-testid="Health Chart">
99-
{createChart()}
10089
</div>
10190
);
10291
});

app/components/AwsEC2Graphs/AwsEC2Graphs.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ import AwsChart from '../../charts/AwsChart';
33
import { AwsContext } from '../../context/AwsContext';
44
import { stringToColor } from '../../utils';
55
import './styles.scss'
6-
import { CircularProgress } from '@mui/material';
7-
86

97
const AwsEC2Graphs: React.FC = React.memo(props => {
108
const { awsData, setAwsData, isLoading, setLoadingState } = useContext(AwsContext);

0 commit comments

Comments
 (0)