Skip to content

Commit 6e41f04

Browse files
committed
updated currentSeriesBarStacks typescript in BarGraphComparison as well as debugging several other files
1 parent 33ca0d4 commit 6e41f04

File tree

4 files changed

+26
-26
lines changed

4 files changed

+26
-26
lines changed

src/app/components/FrontendTypes.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export interface Series {
99
name: string
1010
}
1111

12-
interface ActionObj {
12+
export interface ActionObj {
1313
name: string,
1414
seriesName: string,
1515
}
@@ -20,7 +20,7 @@ export interface PerfData {
2020
maxTotalRender: number,
2121
}
2222

23-
interface BarStackProp {
23+
export interface BarStackProp {
2424
snapshotId: string,
2525
route: string,
2626
currentTab?: string,
@@ -53,15 +53,15 @@ export interface margin {
5353
left: number;
5454
}
5555

56-
interface BarGraphBase {
56+
export interface BarGraphBase {
5757
width: number,
5858
height: number,
5959
data: PerfData,
60-
comparison: string | Series | [],
60+
comparison: Series[],
6161
}
6262

6363
export interface BarGraphComparisonProps extends BarGraphBase {
64-
setSeries: () => void,
64+
setSeries: (e: boolean) => void,
6565
series: number,
6666
setAction: () => void,
6767
}

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

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// @ts-nocheck
21
import React, { useEffect, useState } from 'react';
32
import { BarStack } from '@visx/shape';
43
import { Group } from '@visx/group';
@@ -10,7 +9,9 @@ import { Text } from '@visx/text';
109
import { schemeSet3 } from 'd3-scale-chromatic';
1110
import { onHover, onHoverExit, save } from '../../../actions/actions';
1211
import { useStoreContext } from '../../../store';
13-
import { snapshot, TooltipData, margin, BarGraphProps } from '../../FrontendTypes';
12+
import {
13+
snapshot, TooltipData, margin, BarGraphProps,
14+
} from '../../FrontendTypes';
1415

1516
/* DEFAULTS */
1617
const margin = {
@@ -59,10 +60,8 @@ const BarGraph = (props: BarGraphProps): JSX.Element => {
5960
const keys = Object.keys(data.componentData);
6061

6162
// data accessor (used to generate scales) and formatter (add units for on hover box)
62-
const getSnapshotId = (d: snapshot) => {
63-
// d coming from data.barstack post filtered data
64-
return d.snapshotId;
65-
};
63+
// d coming from data.barstack post filtered data
64+
const getSnapshotId = (d: snapshot) => d.snapshotId;
6665

6766
// returns snapshot id when invoked in tooltip section
6867
const formatSnapshotId = id => `Snapshot ID: ${id}`;

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

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// @ts-nocheck
21
/* eslint-disable no-param-reassign */
32
import React, { useEffect } from 'react';
43
import { BarStack } from '@visx/shape';
@@ -18,11 +17,11 @@ import {
1817
} from '../../../actions/actions';
1918
import { useStoreContext } from '../../../store';
2019
import {
21-
snapshot, TooltipData, margin, BarGraphComparisonProps,
20+
snapshot, TooltipData, margin, BarGraphComparisonProps, ActionObj,
2221
} from '../../FrontendTypes';
2322

2423
/* DEFAULTS */
25-
const margin = {
24+
const margin: margin = {
2625
top: 30, right: 30, bottom: 0, left: 50,
2726
};
2827
const axisColor = '#62d6fb';
@@ -47,9 +46,9 @@ const BarGraphComparison = (props: BarGraphComparisonProps): JSX.Element => {
4746
const [picOpen, setPicOpen] = React.useState(false);
4847
useEffect(() => {
4948
dispatch(setCurrentTabInApp('performance-comparison'));
50-
}, []);
49+
}, [dispatch]);
5150

52-
const currentIndex = tabs[currentTab].sliderIndex;
51+
const currentIndex: number = tabs[currentTab].sliderIndex;
5352

5453
const {
5554
tooltipOpen,
@@ -63,17 +62,17 @@ const BarGraphComparison = (props: BarGraphComparisonProps): JSX.Element => {
6362

6463
const { containerRef, TooltipInPortal } = useTooltipInPortal();
6564

66-
const keys = Object.keys(data.componentData);
65+
const keys: string[] = Object.keys(data.componentData);
6766

6867
// data accessor (used to generate scales) and formatter (add units for on hover box)
6968
const getSnapshotId = (d: snapshot) => d.snapshotId;
70-
const formatSnapshotId = id => `Snapshot ID: ${id}`;
71-
const formatRenderTime = time => `${time} ms `;
72-
const getCurrentTab = storedSeries => storedSeries.currentTab;
69+
const formatSnapshotId = (id: string): string => `Snapshot ID: ${id}`;
70+
const formatRenderTime = (time: string): string => `${time} ms `;
71+
const getCurrentTab = (storedSeries: Record<string, unknown>) => storedSeries.currentTab;
7372

7473
// create visualization SCALES with cleaned data
7574
// the domain array/xAxisPoints elements will place the bars along the x-axis
76-
const xAxisPoints = ['currentTab', 'comparison'];
75+
const xAxisPoints: string[] = ['currentTab', 'comparison'];
7776
const snapshotIdScale = scaleBand<string>({
7877
domain: xAxisPoints,
7978
padding: 0.2,
@@ -84,7 +83,7 @@ const BarGraphComparison = (props: BarGraphComparisonProps): JSX.Element => {
8483
// with the render time of the current tab.
8584
// The max render time will determine the Y-axis's highest number.
8685
const calculateMaxTotalRender = (serie: number): number => {
87-
const currentSeriesBarStacks: number[] = !comparison[serie]
86+
const currentSeriesBarStacks: ActionObj[] = !comparison[serie]
8887
? []
8988
: comparison[serie].data.barStack;
9089
if (currentSeriesBarStacks.length === 0) return 0;
@@ -104,9 +103,10 @@ const BarGraphComparison = (props: BarGraphComparisonProps): JSX.Element => {
104103
});
105104
// the domain array will assign each key a different color to make rectangle boxes
106105
// and use range to set the color scheme each bar
107-
const colorScale = scaleOrdinal<string>({
106+
const duplicate = schemeSet3.slice();
107+
const colorScale = scaleOrdinal<string, string>({
108108
domain: keys,
109-
range: schemeSet3,
109+
range: duplicate,
110110
});
111111

112112
// setting max dimensions and scale ranges
@@ -125,7 +125,7 @@ const BarGraphComparison = (props: BarGraphComparisonProps): JSX.Element => {
125125
select: {
126126
minWidth: 80,
127127
fontSize: '.75rem',
128-
fontWeight: '200',
128+
fontWeight: 200,
129129
border: '1px solid grey',
130130
borderRadius: 4,
131131
color: 'grey',

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ const PerformanceVisx = (props: PerformanceVisxProps): JSX.Element => {
271271
if (holdData) data.barStack = holdData;
272272
}
273273

274-
const renderBargraph = () => {
274+
const renderBargraph = (): JSX.Element | null => {
275275
if (hierarchy) {
276276
return (
277277
<div>
@@ -289,6 +289,7 @@ const PerformanceVisx = (props: PerformanceVisxProps): JSX.Element => {
289289
</div>
290290
);
291291
}
292+
return null;
292293
};
293294

294295
const renderComponentDetailsView = () => {

0 commit comments

Comments
 (0)