@@ -290,13 +290,15 @@ const CostAccuracy = new Component('#cost-accuracy', {
290290 // - We make a broken line to show the real Pareto frontier
291291 let line = [ ]
292292 let last = null ;
293- for ( let pt of rest_pts ) {
293+ rest_pts . forEach ( ( pt , i ) => {
294+ let target = "alternative" + ( i + 1 ) ;
295+ if ( ! document . getElementById ( target ) ) return ;
294296 if ( ! last || pt [ 1 ] > last [ 1 ] ) {
295297 if ( last ) line . push ( [ pt [ 0 ] , last [ 1 ] ] ) ;
296298 line . push ( [ pt [ 0 ] , pt [ 1 ] ] ) ;
297299 last = pt ;
298300 }
299- }
301+ } )
300302
301303 const out = Plot . plot ( {
302304 marks : [
@@ -336,23 +338,23 @@ const CostAccuracy = new Component('#cost-accuracy', {
336338 const bits = benchmark [ "bits" ] ;
337339 const initial_accuracy = 100 * ( 1 - initial_pt [ 1 ] / bits ) ;
338340
341+ let alt_number = 0 ;
339342 return Element ( "tbody" , [
340343 Element ( "tr" , [
341344 Element ( "th" , "Initial program" ) ,
342345 Element ( "td" , initial_accuracy . toFixed ( 1 ) + "%" ) ,
343346 Element ( "td" , "1.0×" )
344347 ] ) ,
345348 rest_pts . map ( ( d , i ) => {
349+ let target = "alternative" + ( i + 1 ) ;
350+ if ( ! document . getElementById ( target ) ) return ;
346351 let accuracy = 100 * ( 1 - d [ 1 ] / bits ) ;
347352 let speedup = initial_pt [ 0 ] / d [ 0 ] ;
353+ alt_number ++ ;
348354 return Element ( "tr" , [
349- Element ( "th" ,
350- rest_pts . length > 1 ?
351- Element ( "a" , { href : "#alternative" + ( i + 1 ) } ,
352- "Alternative " + ( i + 1 ) )
353- // else
354- : "Alternative " + ( i + 1 )
355- ) ,
355+ Element ( "th" , [
356+ Element ( "a" , { href : "#" + target } , "Alternative " + alt_number )
357+ ] ) ,
356358 Element ( "td" , { className : accuracy >= initial_accuracy ? "better" : "" } ,
357359 accuracy . toFixed ( 1 ) + "%" ) ,
358360 Element ( "td" , { className : speedup >= 1 ? "better" : "" } ,
0 commit comments