Reputation: 41
I have one plotly plot and I want to display plot on other UI such as angular, using R Plumber.
Upvotes: 4
Views: 1131
Reputation: 4763
Here is how you do it:
# API for experimenting with html widgets
library(plumber)
library(ggplot2)
library(plotly)
#* @apiTitle HTML widgets API
#* Return interactive plot using plotly
#* @serializer htmlwidget
#* @get /plotly
function() {
p <- ggplot(data = diamonds,
aes(x = cut, fill = clarity)) +
geom_bar(position = "dodge")
ggplotly(p)
}
Hope this helps.
Source - https://github.com/blairj09/plumber-playground/blob/master/experiments/htmlwidgets-exp/plumber.R
Upvotes: 5