1
- // @ts -nocheck
2
1
/* eslint-disable no-param-reassign */
3
2
import React , { useEffect } from 'react' ;
4
3
import { BarStack } from '@visx/shape' ;
@@ -18,11 +17,11 @@ import {
18
17
} from '../../../actions/actions' ;
19
18
import { useStoreContext } from '../../../store' ;
20
19
import {
21
- snapshot , TooltipData , margin , BarGraphComparisonProps ,
20
+ snapshot , TooltipData , margin , BarGraphComparisonProps , ActionObj ,
22
21
} from '../../FrontendTypes' ;
23
22
24
23
/* DEFAULTS */
25
- const margin = {
24
+ const margin : margin = {
26
25
top : 30 , right : 30 , bottom : 0 , left : 50 ,
27
26
} ;
28
27
const axisColor = '#62d6fb' ;
@@ -47,9 +46,9 @@ const BarGraphComparison = (props: BarGraphComparisonProps): JSX.Element => {
47
46
const [ picOpen , setPicOpen ] = React . useState ( false ) ;
48
47
useEffect ( ( ) => {
49
48
dispatch ( setCurrentTabInApp ( 'performance-comparison' ) ) ;
50
- } , [ ] ) ;
49
+ } , [ dispatch ] ) ;
51
50
52
- const currentIndex = tabs [ currentTab ] . sliderIndex ;
51
+ const currentIndex : number = tabs [ currentTab ] . sliderIndex ;
53
52
54
53
const {
55
54
tooltipOpen,
@@ -63,17 +62,17 @@ const BarGraphComparison = (props: BarGraphComparisonProps): JSX.Element => {
63
62
64
63
const { containerRef, TooltipInPortal } = useTooltipInPortal ( ) ;
65
64
66
- const keys = Object . keys ( data . componentData ) ;
65
+ const keys : string [ ] = Object . keys ( data . componentData ) ;
67
66
68
67
// data accessor (used to generate scales) and formatter (add units for on hover box)
69
68
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 ;
73
72
74
73
// create visualization SCALES with cleaned data
75
74
// the domain array/xAxisPoints elements will place the bars along the x-axis
76
- const xAxisPoints = [ 'currentTab' , 'comparison' ] ;
75
+ const xAxisPoints : string [ ] = [ 'currentTab' , 'comparison' ] ;
77
76
const snapshotIdScale = scaleBand < string > ( {
78
77
domain : xAxisPoints ,
79
78
padding : 0.2 ,
@@ -84,7 +83,7 @@ const BarGraphComparison = (props: BarGraphComparisonProps): JSX.Element => {
84
83
// with the render time of the current tab.
85
84
// The max render time will determine the Y-axis's highest number.
86
85
const calculateMaxTotalRender = ( serie : number ) : number => {
87
- const currentSeriesBarStacks : number [ ] = ! comparison [ serie ]
86
+ const currentSeriesBarStacks : ActionObj [ ] = ! comparison [ serie ]
88
87
? [ ]
89
88
: comparison [ serie ] . data . barStack ;
90
89
if ( currentSeriesBarStacks . length === 0 ) return 0 ;
@@ -104,9 +103,10 @@ const BarGraphComparison = (props: BarGraphComparisonProps): JSX.Element => {
104
103
} ) ;
105
104
// the domain array will assign each key a different color to make rectangle boxes
106
105
// 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 > ( {
108
108
domain : keys ,
109
- range : schemeSet3 ,
109
+ range : duplicate ,
110
110
} ) ;
111
111
112
112
// setting max dimensions and scale ranges
@@ -125,7 +125,7 @@ const BarGraphComparison = (props: BarGraphComparisonProps): JSX.Element => {
125
125
select : {
126
126
minWidth : 80 ,
127
127
fontSize : '.75rem' ,
128
- fontWeight : ' 200' ,
128
+ fontWeight : 200 ,
129
129
border : '1px solid grey' ,
130
130
borderRadius : 4 ,
131
131
color : 'grey' ,
0 commit comments