Forum Discussion
R text sizing Bug
Hi BLPYPLAnonymous
In the meantime if this is causing issues, there is a workaround. You can add the following lines to the beginning of your R script:
if (exists("powerbi_rFontName")){
I created a PBIX with 2 R visuals, 1 without the fix and one with. I’ve pasted below 2 screenshots I took: one of the visuals in PBI Desktop, and another of the same pbix once published to service. Once the fix is deployed, these lines can be removed, but they should not cause any issues if you leave them.
Hi Maggie,
Unfortunately this work around does not work with both my production and test code.
Below you can find my test code:
if (exists("powerbi_rFontName")){
library("showtext")
showtext.opts(dpi = powerbi_rPngDeviceDpi)
showtext.auto()
}
library(grid)
library(gridExtra)
d <- head(iris, 3)
g <- tableGrob(d)
find_cell <- function(table, row, col, name="core-fg"){
l <- table$layout
which(l$t==row & l$l==col & l$name==name)
}
for(i in 2:4){
for(j in 2:6){
index_fg <- find_cell(g, i, j, "core-fg")
g$grobs[index_fg][[1]][["gp"]] <- gpar(cex = 4, col = "green")
}
}
grid.newpage()
grid.draw(g)
- LucasPritz8 years agoNew Member
Anonymous, your issue seems to be a separate problem than what other people are facing. Did this use to work in PBI Service? From my initial testing it doesn't seem to work in PBI Desktop either (though I see expected behavior in RStudio).
Edit: Anonymous actually it does work (:
In your first post you had the plotting with "cex = i*j"
And in your follow-up with our provided fix you have it with "cex = 4"
I copied one script into my local PBI Desktop and the other into my RStudio, thinking they were identical except for the workaround, and was very confused!
Please try in service with actual changing text size, you'll see it!
Thanks,
Lucas- Anonymous8 years agoNot applicable
Hi Lucas,
Thanks for your support.
While creating a reply to your request the work-around started to work.
To be honest, it is working only with the test code, not with the production one.
I'll let you know if I will be able to fix also the production environment.
Here below the working test code (same as yesterday...)
if (exists("powerbi_rFontName")){
library("showtext")
showtext.opts(dpi = powerbi_rPngDeviceDpi)
showtext.auto()
}library(grid)
library(gridExtra)d <- head(iris, 3)
g <- tableGrob(d)find_cell <- function(table, row, col, name="core-fg"){
l <- table$layout
which(l$t==row & l$l==col & l$name==name)
}
for(i in 2:4){
for(j in 2:6){
index_fg <- find_cell(g, i, j, "core-fg")
g$grobs[index_fg][[1]][["gp"]] <- gpar(cex = 4, col = "green")
}
}grid.newpage()
grid.draw(g)- Anonymous8 years agoNot applicable
Hi LucasPritz,
I've finally found the problem with my production code.While the test code I've shared contains the following command, it is missing in my production code.
grid.newpage()
I've added this command in my production code and now it correctly works.
I do not understand why the use of grid.newpage() is mandatory, but now the work-around works and it is the important thing!