@@ -93,13 +93,15 @@ async function updateFrequency(selectedFrequency: string) {
93
93
const companyProblems = data . companyProblems [ companyName ] ;
94
94
if ( Array . isArray ( companyProblems ) ) {
95
95
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
+ }
103
105
} ) ;
104
106
}
105
107
@@ -258,7 +260,7 @@ function rebuildTable() {
258
260
const frequencyCell = row . insertCell ( 4 ) ;
259
261
const bar = document . createElement ( 'div' ) ;
260
262
const width = ( ( solution . frequency - minFrequency ) / ( maxFrequency - minFrequency ) ) * 100 ;
261
- bar . style . width = width + '%' ;
263
+ bar . style . width = Math . min ( width , 100 ) + '%' ;
262
264
bar . style . height = '10px' ;
263
265
bar . style . backgroundColor = 'lightgreen' ;
264
266
bar . style . borderRadius = '10px' ;
0 commit comments