@@ -93,13 +93,15 @@ async function updateFrequency(selectedFrequency: string) {
9393 const companyProblems = data . companyProblems [ companyName ] ;
9494 if ( Array . isArray ( companyProblems ) ) {
9595 solutions . forEach ( ( solution , index ) => {
96- // Update the frequency based on the selected option
97- const freqValue = companyProblems [ index ] [ selectedFrequency ] ;
98- solution [ 'frequency' ] = freqValue ;
99-
100- // Update min and max frequency for the selected range
101- if ( freqValue < minFrequency ) minFrequency = freqValue ;
102- if ( freqValue > maxFrequency ) maxFrequency = freqValue ;
96+ // Check if the selected frequency value exists for the problem
97+ if ( companyProblems [ index ] . hasOwnProperty ( selectedFrequency ) ) {
98+ const freqValue = companyProblems [ index ] [ selectedFrequency ] ;
99+ solution [ 'frequency' ] = freqValue ;
100+
101+ // Update min and max frequency for the selected range
102+ if ( freqValue < minFrequency ) minFrequency = freqValue ;
103+ if ( freqValue > maxFrequency ) maxFrequency = freqValue ;
104+ }
103105 } ) ;
104106 }
105107
@@ -258,7 +260,7 @@ function rebuildTable() {
258260 const frequencyCell = row . insertCell ( 4 ) ;
259261 const bar = document . createElement ( 'div' ) ;
260262 const width = ( ( solution . frequency - minFrequency ) / ( maxFrequency - minFrequency ) ) * 100 ;
261- bar . style . width = width + '%' ;
263+ bar . style . width = Math . min ( width , 100 ) + '%' ;
262264 bar . style . height = '10px' ;
263265 bar . style . backgroundColor = 'lightgreen' ;
264266 bar . style . borderRadius = '10px' ;
0 commit comments