1- // @ts -nocheck
21/* eslint-disable no-param-reassign */
32import React , { useEffect } from 'react' ;
43import { BarStack } from '@visx/shape' ;
@@ -18,11 +17,11 @@ import {
1817} from '../../../actions/actions' ;
1918import { useStoreContext } from '../../../store' ;
2019import {
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} ;
2827const 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' ,
0 commit comments