I would think you need to wrap the js_code part in IPython,display
’s Javascript, like here and here and not wrap it in like you have; however, I couldn’t find a more complex example involving a function to point out. Here has a function defined there but it is using an ipywidget library.