ggplot2 - R: Shiny ggplot renders upside down online, but not offline -
i made small shiny app visualizes simple data in set of barplots. 1 of charts barplot showing time intervals plotted against date. renders expected when running app offline in r, when publish shinyapps.io, bars oddly inverted , run top of plot down towards x-axis. examples:
i have set of similar barplots not based on time-data seem work fine both published , unpublished. app entangled in reactive elements, i'm not sure how provide minimal reproducible example, on server side, plot rendered using:
output$dayplot <- renderplot({ p <- ggplot(myplotdata(), aes(day, var, fill=state, color=state)) + geom_bar(stat="identity") + xlab("day") + ylab(input$yvar) + scale_x_continuous(breaks=pretty_breaks(10)) + scale_y_datetime(breaks = date_breaks("1 hour"), labels = date_format("%h:%m")) + coord_cartesian(ylim = c(as.posixct("0:0:0", tz = "gmt", format="%h:%m:%s"), as.posixct("12:00:00", tz = "gmt", format="%h:%m:%s"))) + scale_fill_brewer(palette="paired", type="qual") + scale_color_brewer(palette="paired", type="qual") print(p) })
i've read through code multiple times, cannot comprehend how phenomenon arise online while working fine offline, i'm not entirely sure looking for. first shiny app, ideas , input might have caused welcome!
edit: i've since gone through of code, reducing bare minimums. while couldn't pinpoint triggered problem complete certainity, seems have been related time variable taking on sys.date time when formatted posixct. worked fine in preview, not on shiny server. however, manually setting date 1970-01-01 pasting onto character time-variable before converting posix seems have resolved issue on end. if other future readers come upon funky problem, perhaps suggestion can of help.
Comments
Post a Comment