Using GoogleVis in R inside Power BI

299 Views Asked by At

I am trying to replicate these:

https://radacad.com/interactive-map-using-r-and-power-bi-create-custom-visual-part-1

Is it possible to use R Plotly library in R Script Visual of Power BI?

The issue with Plotly is that for my dataset it is so slow even when I am compiling that in R. takes several minutes. So, I have decided to replace it with googleVis which is really fast (I am open any other interactive Gantt Chart in R).

Here is my code in R:

 df <- data.frame(Values)
library("googleVis")

 #df$Project.Name <- toString(df$Project.Name)
df$Processed_start_date_cut <- as.Date(df$Processed_start_date_cut)
df$Processed_End_date <- as.Date(df$Processed_End_date)
#df$Milestone <- toString(df$Milestone)

 g <- gvisTimeline(data=df, 
              rowlabel="Project.Name",
              barlabel="Milestones",
              start="Processed_start_date_cut", 
              end="Processed_End_date",
              options=list(timeline="{rowLabelStyle:{fontName:'Helvetica', 
                           fontSize:10, color:'#603913'},
                           barLabelStyle:{fontName:'Garamond', 
                           fontSize:12}}",
                           backgroundColor='#ffd', 
                           height=350 ))
 cat(g$html$chart, file="out.html")

I have tried it in R and it works great. In BI this works for the first time, but when I change any filters, nothing shows up in this newly developed pbivis item unless I go to another tab of my report and then come back to this tab which has this newly developed pbivis (this was the reason I thought it is not working at first, sorry).

See the screenshot

enter image description here

I have also noticed that if I maximize this item (pbivis), then the chart disappears (i.e. shows nothing).

I guess I need a kind of code for refreshing the visuals which possibly can come before df <- data.frame(Values), maybe something like F5 in IE.

Also tried this and did not work:

if (file.exists("out.html")) 
   #Delete file if it exists
   file.remove("out.html")
1

There are 1 best solutions below

0
Mohsen Sichani On

As user3867743 suggested, the issue is related to

cat(g$html$chart, file="out.html")

After replacing it by

print(g, file="out.html")

It has started working fine.