Forum Discussion
[SOLVED] R plotly custom visualization margin padding
- 7 years ago
Good morning,
I have finally managed to get rid of the extra padding introduced in the visualization. I appears the bug is with htmlWidgets, that introduces padding into the html file.
A simple R function can get rid of the padding, such as the one below:
ReadFullFileReplaceString <- function(fnameIn, fnameOut, sourceString,targetString) { if(!file.exists(fnameIn)) return(NULL) tx <- readLines(fnameIn,encoding = "UTF-8") tx2 <- gsub(pattern = sourceString, replace = targetString, x = tx) writeLines(tx2, con = fnameOut) }The calling the function like so:
ReadFullFileReplaceString('out.html', 'out.html', ',"padding":[0-9]*,', ',"padding":0,')Credit goes to MS, as the solution was found in one of their R visualizations, PowerBI-visuals-forcasting-exp
in their script.r file: https://github.com/microsoft/PowerBI-visuals-forcasting-exp/blob/master/script.r
I am unable to get this to work and really need to get around this. I am not a developer or at least I am only just starting out so any help would be gratefully received. If you can point me in the direction of where to get the help that would be amazing.