Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in BI by (17.6k points)

Has anyone tried using Plotly or Highchart in R Script Visual of Power BI, when I try this in R script editor and Run:

library(ggplot2)

library(plotly)

x <- 1:5

y <- c(1, 3, 2, 3, 1)

plot_ly(x = dataset$period, y = dataset$mean, name = "spline", line = list(shape = "spline"))

Error Message:

No image was created. The R code did not result in creation of any visuals. Make sure your R script results in a plot to the R default device. 

But runs perfectly on my R desktop. Any thought? 

1 Answer

0 votes
by (47.2k points)
  • In R packages, which are currently supported by previous version of Power BI, "plotly" is not listed  - For more details, you can refer this documentation.

https://docs.microsoft.com/en-us/power-bi/visuals/service-r-visuals#supported-packages

  • For newer versions of PowerBI, it's also possible to produce Plotly charts using, R and ggplot as custom PowerBI visualizations. With the approach described below, you can produce a density plot from a PowerBI table like this:

############### Library Declarations ###############

libraryRequireInstall("ggplot2");

libraryRequireInstall("plotly")

library("plotly")

library("ggplot2")

library("htmlwidgets")

####################################################

#g = plot_ly(mpg, x = mpg$cty, y = mpg$hwy, text = paste("Clarity: ", mpg$cyl),

#mode = "markers", color = mpg$cty, size = mpg$cty)

#library(plotly)

 

# Get Manufacturer

g <- mpg %>%

  group_by(fl) %>%

  summarise(count = n()) %>%

  plot_ly(labels = ~fl, values = ~count) %>%

  add_pie(hole = 0.6) 

  ############# Create and save widget ###############

p = ggplotly(g);

internalSaveWidget(p, 'out.html');

Check out the Power BI Certification training provided by Intellipaat to learn and master this tool. 

Related questions

0 votes
1 answer
0 votes
1 answer
asked Feb 19, 2021 in BI by dev_sk2311 (45k points)
0 votes
1 answer
0 votes
1 answer
asked Feb 28, 2021 in BI by dev_sk2311 (45k points)

Browse Categories

...