@@ -414,5 +414,31 @@ if (requireNamespace("ggiraph", quietly = TRUE) && requireNamespace("htmlwidgets
414414 # Save to standalone interactive HTML
415415 html_output_path <- file.path(output_dir , " data_availability.html" )
416416 htmlwidgets :: saveWidget(x , html_output_path , selfcontained = TRUE )
417+
418+ # Prevent scrollbars in iframes by forcing absolute responsive sizing on html, body, and svg
419+ if (file.exists(html_output_path )) {
420+ html_content <- readLines(html_output_path , warn = FALSE )
421+
422+ # Inject CSS styles in head
423+ css_styles <- paste0(
424+ " <head>\n <style>\n " ,
425+ " html, body {\n " ,
426+ " margin: 0 !important;\n " ,
427+ " padding: 0 !important;\n " ,
428+ " width: 100% !important;\n " ,
429+ " height: 100% !important;\n " ,
430+ " overflow: hidden !important;\n " ,
431+ " }\n " ,
432+ " svg {\n " ,
433+ " width: 100% !important;\n " ,
434+ " height: 100% !important;\n " ,
435+ " }\n " ,
436+ " </style>"
437+ )
438+
439+ html_content <- gsub(" <head>" , css_styles , html_content , fixed = TRUE )
440+ writeLines(html_content , html_output_path , useBytes = TRUE )
441+ }
442+
417443 cat(" Interactive plot saved to:" , html_output_path , " \n " )
418444}
0 commit comments