Forum Discussion
Need help with creating a Power BI Custom Visual HTML with Plotly
- Anonymous6 years ago
Have solved it
You first call the ggplot, then later the plotly plot. This is why you are seeing seperate graphs. If you need tooltips youll have to use Plotly, if not then ggplot will suffice.
g=ggplot(Values, aes(x=Values$AvgWeight, y=Values$Value,colour = "Red")) + geom_jitter(size=4)+geom_point(data=Othervaluestable,aes(x=Othervaluestable$AvgWeight, y=Values$Value))Something along those lines. Basically with ggplot (and plotly) you can add additional visuals like so. Let me know if this is what you were thinking. If this solution helped, I would appreciate kudos and if it gives you the solution I would appreciate if you "accepted as solution".
- Anonymous6 years agoNot applicable
Hi and thanks for fast response. Perhaps I was not clear enough. Below you see what I am looking for
Here you see a hardcoded version that works. I need to replace this code so it works with fields from Power BI when it uses the custom visual. It may be a challenge when I am using fields from two different tables, but perhaps not. I am sure there are solution for that. Hope you understand it better now
source('./r_files/flatten_HTML.r') ############### Library Declarations ############### libraryRequireInstall("ggplot2"); libraryRequireInstall("plotly") #################################################### ################### Actual code #################### # y <- c(Values$Value) # x <- c(Values$AvgWeight) trace_0 <- rnorm(100, mean = 5) x <- c(1:100) x2 <- c(1, 10, 20, 40, 60) y2 <- c(4, 2, 3, 5, 7) data <- data.frame(x, x2, trace_0, y2) g <- plot_ly(data, x = ~x) %>% add_trace(y = ~trace_0, name = 'trace 0',mode = 'lines', type = "scatter") %>% #add_trace(y = ~trace_1, name = 'trace 1', mode = 'lines+markers') %>% add_trace(x= ~x2, y = ~y2, name = 'trace 2', mode = 'markers', type = "scatter") #################################################### ############# Create and save widget ############### p = ggplotly(g); internalSaveWidget(p, 'out.html'); ####################################################- Anonymous6 years agoNot applicable
Have solved it
- Anonymous6 years agoNot applicable
Anonymous
This is not possible given the current functionality of the visual. It must be hardcoded.