Enter code here...minx <- min(movies$rating)
maxx <- max(movies$rating)
shinyServer(function(input, output) {
output$trendPlot <- renderPlotly({
# size of the bins depend on the input 'bins'
size <- (maxx - minx) / input$bins
# a simple histogram of movie ratings
p <- plot_ly(movies, x = rating, autobinx = F, type = "histogram",
xbins = list(start = minx, end = maxx, size = size))
# style the xaxis
layout(p, xaxis = list(title = "Ratings", range = c(minx, maxx), autorange = F,
autotick = F, tick0 = minx, dtick = size))
})
output$myImage <- renderImage({
# A temp file to save the output.
# This file will be removed later by renderImage
outfile <- 'output.png'
# a simple histogram of movie ratings
size <- (maxx - minx) / input$bins
p <- plot_ly(movies, x = rating, autobinx = F, type = "histogram",
xbins = list(start = minx, end = maxx, size = size))
# style the xaxis
layout(p, xaxis = list(title = "Ratings", range = c(minx, maxx), autorange = F,
autotick = F, tick0 = minx, dtick = size))
# Return a list containing the filename
list(src = outfile,
contentType = 'image/png',
width = 400,
height = 300,
alt = "This is alternate text")
}, deleteFile = FALSE)
})