Skip to content

Commit 75146d1

Browse files
committed
corrected and added typescript checks that broke code for currentSeriesBarStacks to enforce accuracy
1 parent b5d9206 commit 75146d1

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

src/app/components/FrontendTypes.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ export interface Series {
1010
}
1111

1212
interface ActionObj {
13-
name: unknown,
14-
seriesName: unknown,
13+
name: string,
14+
seriesName: string,
1515
}
1616

1717
export interface PerfData {

src/app/components/StateRoute/PerformanceVisx/BarGraphComparison.tsx

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,13 @@ import { makeStyles } from '@material-ui/core/styles';
1212
import Select from '@material-ui/core/Select';
1313
import MenuItem from '@material-ui/core/MenuItem';
1414
import FormControl from '@material-ui/core/FormControl';
15-
import { onHover, onHoverExit, deleteSeries, setCurrentTabInApp } from '../../../actions/actions';
15+
import {
16+
onHover, onHoverExit, deleteSeries, setCurrentTabInApp,
17+
} from '../../../actions/actions';
1618
import { useStoreContext } from '../../../store';
17-
import { snapshot, TooltipData, margin, BarGraphComparisonProps } from '../../FrontendTypes';
19+
import {
20+
snapshot, TooltipData, margin, BarGraphComparisonProps,
21+
} from '../../FrontendTypes';
1822

1923
/* DEFAULTS */
2024
const margin = {
@@ -78,15 +82,15 @@ const BarGraphComparison = (props: BarGraphComparisonProps): JSX.Element => {
7882
// We'll then use it in the renderingScale function and compare
7983
// with the render time of the current tab.
8084
// The max render time will determine the Y-axis's highest number.
81-
const calculateMaxTotalRender = serie => {
82-
const currentSeriesBarStacks = !comparison[serie]
85+
const calculateMaxTotalRender = (serie: string) => {
86+
const currentSeriesBarStacks: number[] = !comparison[serie]
8387
? []
8488
: comparison[serie].data.barStack;
8589
if (currentSeriesBarStacks.length === 0) return 0;
8690
let currentMax = -Infinity;
8791
for (let i = 0; i < currentSeriesBarStacks.length; i += 1) {
8892
const renderTimes = Object.values(currentSeriesBarStacks[i]).slice(1);
89-
const renderTotal = renderTimes.reduce((acc, curr) => acc + curr);
93+
const renderTotal: number = renderTimes.reduce((acc, curr) => acc + curr);
9094
if (renderTotal > currentMax) currentMax = renderTotal;
9195
}
9296
return currentMax;

0 commit comments

Comments
 (0)