title: How to autoupadate a shiny app with new data?
body: <p>I want to force a highcharter chart, inside shiny app to plot new data from Mysql database. I've tried different approaches but none seems to work.
  At first my connection to sql through library(RMySQL) &amp; library(pool) in globalR</p>
  
  <pre><code>#--------Connect to SQL----------#
  
  pool &lt;- dbPool(
    drv = RMySQL::MySQL(),
    dbname = "xxx",
    host = "x.x.x.x",
    username = 'xxxx',
    password = 'xxxx'
  )
  
  sql1 &lt;- 'SELECT * FROM `results` WHERE `datetime` &gt;= NOW() - INTERVAL 1 DAY'
  
  query1 &lt;- sqlInterpolate(pool, sql1)
  
  notifier1 &lt;- dbGetQuery(pool, sqlInterpolate(pool,'SELECT * FROM `results` WHERE `datetime` &gt;= NOW() - INTERVAL 1 DAY' ))
  
  lapply(dbListConnections( dbDriver( drv = "MySQL")), dbDisconnect)
  </code></pre>
  
  <p>then I create 2 dataframes</p>
  
  <pre><code>all1 &lt;- as.data.frame(notifier1%&gt;% group_by(datetime, customer) %&gt;% count(ping) %&gt;% filter(datetime &gt; Sys.time()-14400) %&gt;%
               mutate(percent = (round(100 * n/sum(n), 1))) %&gt;% filter(ping=='1') %&gt;% arrange(desc(datetime)))
  
  
   all1_new &lt;- transform(all1,datetime=as.numeric(as.POSIXct(datetime))*1000)
  </code></pre>
  
  <p>In server I've tried:</p>
  
  <pre><code>server &lt;- function(input, output, session) {  
  
       observeEvent(invalidateLater(60000, session),{
               notifier1 &lt;- dbGetQuery(pool, sqlInterpolate(pool,'SELECT * FROM `results` WHERE `datetime` &gt;= NOW() - INTERVAL 1 DAY' ))
  
               all1 &lt;- as.data.frame(notifier1%&gt;% group_by(datetime, customer) %&gt;% count(ping) %&gt;% filter(datetime &gt; Sys.time()-14400) %&gt;% 
                                          mutate(percent = (round(100 * n/sum(n), 1))) %&gt;% filter(ping=='1') %&gt;% arrange(desc(datetime)))
  
  
               all1_new &lt;- transform(all1,datetime= as.numeric(as.POSIXct(datetime))*1000)
       })
  </code></pre>
  
  <p>and the highchart code that I need to display new data every e.g 1 min:</p>
  
  <pre><code>output$Plot1 &lt;- renderHighchart ({
  
          # invalidateLater(60000,session)
  
  
  
      highchart() %&gt;%
           hc_chart(type = "container",
                    zoomType= "x"
           ) %&gt;%
           #axis
           hc_xAxis(type='datetime',
                    # categories=c(min2$datetime),
                    labels = list(rotation = 90,
                                  format = '{value:%e-%b %H:%M}'),
                    showLastLabel = TRUE
           ) %&gt;% 
           hc_yAxis(opposite = FALSE, 
                    title = list(text = "Call Success"),
                    labels = list(format = "{value}%", style=list(fontSize='13px')), max = 100) %&gt;% 
           hc_add_series(all1_new, "spline", hcaes(x=datetime, y=percent, group=customer)
           )%&gt;%
        })
  </code></pre>