rstudio / plumber

Turn your R code into a web API.
https://www.rplumber.io
Other
1.4k stars 256 forks source link

Error using Plumber + Plotly #241

Closed ar0ra1 closed 6 years ago

ar0ra1 commented 6 years ago
#' Function to display complete bitcoin stats on chart
#' @get /bitcoin_chart_complete
#' @png (width = 550, height = 600)
function(){
plot_ly(bitCoin, x= ~date, y = ~open, type="bar", name="Open")%>%
  add_trace(y = ~close, name="Close")%>%
  add_trace(y = ~high, name="High")%>%
  add_trace(y = ~low, name="Low")%>%
  layout(xaxis = list(title = "", tickangle = -45),
         yaxis = list(title = ""),
         margin = list(b = 100),
         barmode = 'group')
}

I get the error -

Warning in file(data$file, "rb") :
  cannot open file '/tmp/RtmpXNjQMr/file26f070115c73': No such file or directory
<simpleError in file(data$file, "rb"): cannot open the connection>

Edit - i know i'm missing something related to could you please possibly help out ?

trestletech commented 6 years ago

You don't want to use the @png serializer since it's an htmlwidget. Take a look at the @serializer htmlwidget annotation: https://www.rplumber.io/docs/rendering-and-output.html#serializers