title: Interactive Plotly Int Slider
body: <p>Hi I'm fairly new to Python, Plotly and Jupyter Notebook. I would like to use a slider to select the number of days as the range in a query to which a graph is created from. My only issue is that I want the graph to automatically update on interaction with the slider, without having to re-run the query and graph creation. My code is below:</p>
  
  <pre><code>slider = widgets.IntSlider()
  display(slider)
  sliderVal = slider.value
  
  df = pd.read_sql(f"""
  SELECT CASE WHEN SiteID LIKE 3 THEN 'BLAH' 
          WHEN SiteID LIKE 4 THEN 'BLAHBLAH' 
          END AS Website, 
          COUNT(1) AS Count
  FROM            viewName
  WHERE        (TimeStamp &gt; DATEADD(DAY, -{sliderVal}, GETDATE()))
  GROUP BY SiteId
  ORDER BY Count DESC
             """, conn)
  
  data = [go.Bar(x=df.Website, y=df.Count)]
  layout = go.Layout(
      xaxis=dict(
          title='Website'),
      yaxis=dict(
          title='Exception count'),
      title=f'Number of exceptions per user in the last {sliderVal} days')
  chart = go.Figure(data=data, layout=layout, )
  py.iplot(chart, filename='WebExceptions')
  </code></pre>
  
  <p>Thanks in advance!</p>