r - Setting xlim for rbokeh plot inside shiny application -


i'm using rbokeh package r. i've been having results integrating shiny app. want integrate feature daterangeinput select date range chart(it time series data).

##necessary packages  install.packages("shiny") install.packages("devtools") install.packages("dplyr") library(devtools) devtools::install_github("ramnathv/htmlwidgets") devtools::install_github("bokeh/rbokeh") library(rbokeh) library(dplyr) library(shiny)  #example data set  james<-mtcars[c("mpg")] james$date<-seq(from=as.date("2013-05-16"),to=as.date("2013-06-16"),by="days") james$index<-1:4  #shiny app  shiny_example <- function(chart_data = james){    date_minmax <- range(chart_data$date)    shinyapp(     ui=fluidpage(       titlepanel("a plot"),       sidebarlayout(         sidebarpanel(           textinput("index","enter index 1 16",value=1),           uioutput("date_range")         ),         mainpanel(           rbokeh::rbokehoutput("plot_cars")         )       )     ),     server=function(input,output,session)     {       current_data <- reactive({         current_df <- subset(james,index==input$index)         return(current_df)       })       output$date_range <- renderui({         plot_data <- current_data()         current_id_range <- range(plot_data$date)         return(           daterangeinput("date_range",                          "date range(x axis",                          min=date_minmax[1],                          max=date_minmax[2],                          start=current_id_range[1],                          end=current_id_range[2])         )       })       output$plot_cars <- rbokeh::renderrbokeh({         plot_data <- current_data()         g<-rbokeh::figure(title="cars",                           width=800,                           heigh=400,                           xlab="date",                           ylab="mpg",                           xlim=input$date_range) %>%           rbokeh::ly_points(date,                             mpg,                             data=plot_data) %>%           rbokeh::ly_lines(date,                            mpg,                            data=plot_data,                            alpha=0.3)         return(g)       })     }    ) } ##run app  shiny_example() 

the above example data works without xlim argument in rbokeh::figure, in typing in number 1 4 in input subsets data accordingly , produces plot reactively. xlim argument seems produce errors in plot. perhaps point me in right direction in trying fix xlim issue?

let me know if need more details.

it seems date formatting issue in rbokeh: https://github.com/bokeh/rbokeh/issues/100 should fixed soon.


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -