Skip to content

Commit 3904546

Browse files
Samuel  TranSamuel  Tran
authored andcommitted
Merge branch 'dev' into samtran/feature
2 parents 81d8c8c + 6a2c367 commit 3904546

File tree

4 files changed

+26
-24
lines changed

4 files changed

+26
-24
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: string | 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 & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ import { Text } from '@visx/text';
1010
import { schemeSet3 } from 'd3-scale-chromatic';
1111
import { onHover, onHoverExit, save } from '../../../actions/actions';
1212
import { useStoreContext } from '../../../store';
13-
import { snapshot, TooltipData, margin, BarGraphProps } from '../../FrontendTypes';
13+
import {
14+
snapshot, TooltipData, margin, BarGraphProps,
15+
} from '../../FrontendTypes';
1416

1517
/* DEFAULTS */
1618
const margin = {
@@ -59,10 +61,8 @@ const BarGraph = (props: BarGraphProps): JSX.Element => {
5961
const keys = Object.keys(data.componentData);
6062

6163
// 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-
};
64+
// d coming from data.barstack post filtered data
65+
const getSnapshotId = (d: snapshot) => d.snapshotId;
6666

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

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

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ import {
1818
} from '../../../actions/actions';
1919
import { useStoreContext } from '../../../store';
2020
import {
21-
snapshot, TooltipData, margin, BarGraphComparisonProps,
21+
snapshot, TooltipData, margin, BarGraphComparisonProps, ActionObj,
2222
} from '../../FrontendTypes';
2323

2424
/* DEFAULTS */
25-
const margin = {
25+
const margin: margin = {
2626
top: 30, right: 30, bottom: 0, left: 50,
2727
};
2828
const axisColor = '#62d6fb';
@@ -47,9 +47,9 @@ const BarGraphComparison = (props: BarGraphComparisonProps): JSX.Element => {
4747
const [picOpen, setPicOpen] = React.useState(false);
4848
useEffect(() => {
4949
dispatch(setCurrentTabInApp('performance-comparison'));
50-
}, []);
50+
}, [dispatch]);
5151

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

5454
const {
5555
tooltipOpen,
@@ -63,17 +63,17 @@ const BarGraphComparison = (props: BarGraphComparisonProps): JSX.Element => {
6363

6464
const { containerRef, TooltipInPortal } = useTooltipInPortal();
6565

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

6868
// data accessor (used to generate scales) and formatter (add units for on hover box)
6969
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;
70+
const formatSnapshotId = (id: string): string => `Snapshot ID: ${id}`;
71+
const formatRenderTime = (time: string): string => `${time} ms `;
72+
const getCurrentTab = (storedSeries: Record<string, unknown>) => storedSeries.currentTab;
7373

7474
// create visualization SCALES with cleaned data
7575
// the domain array/xAxisPoints elements will place the bars along the x-axis
76-
const xAxisPoints = ['currentTab', 'comparison'];
76+
const xAxisPoints: string[] = ['currentTab', 'comparison'];
7777
const snapshotIdScale = scaleBand<string>({
7878
domain: xAxisPoints,
7979
padding: 0.2,
@@ -84,7 +84,7 @@ const BarGraphComparison = (props: BarGraphComparisonProps): JSX.Element => {
8484
// with the render time of the current tab.
8585
// The max render time will determine the Y-axis's highest number.
8686
const calculateMaxTotalRender = (serie: number): number => {
87-
const currentSeriesBarStacks: number[] = !comparison[serie]
87+
const currentSeriesBarStacks: ActionObj[] = !comparison[serie]
8888
? []
8989
: comparison[serie].data.barStack;
9090
if (currentSeriesBarStacks.length === 0) return 0;
@@ -104,9 +104,10 @@ const BarGraphComparison = (props: BarGraphComparisonProps): JSX.Element => {
104104
});
105105
// the domain array will assign each key a different color to make rectangle boxes
106106
// and use range to set the color scheme each bar
107-
const colorScale = scaleOrdinal<string>({
107+
const duplicate = schemeSet3.slice();
108+
const colorScale = scaleOrdinal<string, string>({
108109
domain: keys,
109-
range: schemeSet3,
110+
range: duplicate,
110111
});
111112

112113
// setting max dimensions and scale ranges
@@ -125,7 +126,7 @@ const BarGraphComparison = (props: BarGraphComparisonProps): JSX.Element => {
125126
select: {
126127
minWidth: 80,
127128
fontSize: '.75rem',
128-
fontWeight: '200',
129+
fontWeight: 200,
129130
border: '1px solid grey',
130131
borderRadius: 4,
131132
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)