cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
BLPYPL Frequent Visitor
Frequent Visitor

R text sizing Bug

Hi, 

The text sizing in R seems to incorrect recently. Can anyone help?

 

I'm using custom R visuals. I simply use "plot" and "text" to plot some text. I use parameter "cex" in "text". It works in Power BI desktop and R studio, but the text shows really small in Power BI service.

10 REPLIES 10
BLPYPL Frequent Visitor
Frequent Visitor

R Text Size Bug

We are using some of the custom R visuals in Power BI. The text size in R seems to not working since today. The size become really small and you can hardly see it. It works fine on both Power BI desktop and my R studio. It didn't turn out to be this way sometime ago. Can someone tell me how to work around this issue?

 

I simply use plot function and text function. I use CEX to set the text sizing.

BLPYPL Frequent Visitor
Frequent Visitor

Re: R text sizing Bug

Here is the code to reproduce the bug:

1. Create a Power BI report and R visual

2. paste following code:

.text="testing%"
par(mar = c(0,0,0,0),bg=NA,cex=3.5)
plot(c(0, 1), c(0, 1),ann = F,asp=1, bty = 'n', type = 'n', xaxt = 'n', yaxt = 'n')

text(x = 0.5, y = 0.2, .text,
col = "red")

3. Publish it to Power BI service

4.Compare the desktop and service version. You will see the text sizing is not correct in the service

 

I've tried serveral parameters, such as cex, ps, but none seems to work. Can anyone help?

Community Support Team
Community Support Team

Re: R text sizing Bug

Hi @BLPYPL

Thank you for such detailed information, I can reproduce the issue and I am checking with engineer whether it is a bug and when and how to fix it.

I will come back to tell you if there is any update.

 

Best Reagrds

Maggie

FP Frequent Visitor
Frequent Visitor

Re: R text sizing Bug

Hi,
Same issue here.

We have first noticed the problem on 26 june.

I attach a sample code to reproduce the issue; a curious fact is that the problem does not affect the text colour!

 

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 = i*j, col = "green")
}
}

grid.newpage()
grid.draw(g)

Community Support Team
Community Support Team

Re: R text sizing Bug

Hi @BLPYPL@FP

There was a bug fix a little while ago that appears to have unintentionally led to this regression. We already know the fix, we can start right away on getting it deployed, though it may take a little while.

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")){
  library("showtext")
  showtext.opts(dpi = powerbi_rPngDeviceDpi)
  showtext.auto()
}

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.
 
Best Regards
Maggie
FP Frequent Visitor
Frequent Visitor

Re: R text sizing Bug

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)

LucasPritz Frequent Visitor
Frequent Visitor

Re: R text sizing Bug

@FP, 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: @FP 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

BLPYPL Frequent Visitor
Frequent Visitor

Re: R text sizing Bug

Hi Maggie,

 

I tried this solution and it works for me. Please keep me updated when the bug is fixed.

FP Frequent Visitor
Frequent Visitor

Re: R text sizing Bug

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)

Helpful resources

Announcements
October 2019 Community Highlights

October 2019 Community Highlights

October was a busy month in the community. Read the recap article to learn about some of the events and content.

New Badges

Incoming: New and Improved Badges

Exciting news: We've given our badges an overhaul and added brand news ones.

Ask Amir Anything

Exclusive LIVE Community Event No. 2 – Ask Amir Anything

Next in our Triple A series: Ask Amir Netz questions about the latest updates, features and future.

Analytics in Azure virtual event

Analytics in Azure virtual event

Experience a limitless analytics service built to ingest, prep, manage, and serve data for immediate use in Power BI.

Top Kudoed Authors
Users Online
Currently online: 178 members 1,800 guests
Please welcome our newest community members: