# How can I correctly obtain the updated x\_range after dragging in Jupyter?

**URL:** <https://discourse.bokeh.org/t/how-can-i-correctly-obtain-the-updated-x-range-after-dragging-in-jupyter/11107>\
**Category:** Community Support\
**Tags:** jupyter, bokehjs, bokeh\
**Created:** [December 13, 2023, 5:41pm UTC](https://discourse.bokeh.org/t/how-can-i-correctly-obtain-the-updated-x-range-after-dragging-in-jupyter/11107 "2023-12-13T17:41:25Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![Bryan](https://discourse.bokeh.org/user_avatar/discourse.bokeh.org/bryan/32/3625_2.png) [@Bryan](https://discourse.bokeh.org/u/Bryan)\
**Post date:** [December 13, 2023, 10:46pm UTC](https://discourse.bokeh.org/t/how-can-i-correctly-obtain-the-updated-x-range-after-dragging-in-jupyter/11107/4 "2023-12-13T22:46:27Z")

</div>

Just a note: in the notebook you really want to have new Bokeh objects created for every (re-)evaluation of the cell with `show`. Each new invocations results in a new session, and sessions are not designed to share objects. Typically all the “app” code is encapsulated entirely in a function like `my_app`, not just the `add_root` part. This is how things are demonstrated in the example I linked.

Alternatively, a small class can be defined for the app, which may be preferable for code organization. There was an example of that discussed here:

> [@Live plot with interactivity](https://discourse.bokeh.org/t/live-plot-with-interactivity/10890/6):
>
> Yes, here is an updated version from that example: class bkapp: df = sea\_surface\_temperature.copy() def \_\_init\_\_(self): self.\_theme\_json = """ attrs: figure: background\_fill\_color: "#DDDDDD" outline\_line\_color: white toolbar\_location: above height: 500 width: 800 Grid: grid\_line\_dash: [6, 4] grid…

---

_[View the full topic](https://discourse.bokeh.org/t/how-can-i-correctly-obtain-the-updated-x-range-after-dragging-in-jupyter/11107)._
