1

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")
Mohsen Sichani
  • 1,002
  • 12
  • 33
  • 1
    will you please clarify --> _nothing shows up in this item_ --? also, have you checked the browser's console for errors? – WhiteHat Jan 23 '20 at 12:15
  • Thanks WhiteHat, Clarified the first part, but not sure how to check the console in Power BI desktop. I guess there should not be error as it looks fine and it shows the chart but it does not show it at the right time – Mohsen Sichani Jan 23 '20 at 19:50
  • thanks, was thinking this was running in a browser, in which case you would normally press F12 to get to the console. once again, not familiar with the tools you're using, only google charts... – WhiteHat Jan 23 '20 at 20:02
  • 1
    have you tried print() or other commands mentioned in https://cran.r-project.org/web/packages/googleVis/vignettes/googleVis.pdf – user3867743 Jan 26 '20 at 22:15
  • Perfect, this was the issue. By replacing print with cut it worked. Can u post it as the answer – Mohsen Sichani Jan 27 '20 at 06:12
  • Great, do it yourself. it was a simple replacement – user3867743 Jan 27 '20 at 06:14

1 Answers1

1

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.

Mohsen Sichani
  • 1,002
  • 12
  • 33