Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

119
Views
Bokeh how to change image_url on figure from javascript

I m using bokeh to plot my chart. So I need to have an Image as background, and I need to make http request every X second, and in base of response of http request I will change the figure image background.

So this is the code:

img_yellow = "http://localhost:8000/static/images/semaforo_yellow.png"
img_green = "http://localhost:8000/static/images/semaforo_verde.png"
img_red = "http://localhost:8000/static/images/semaforo_rosso.png"
p = figure(x_range=(0, 1), y_range=(0, 1))
p.image_url(url=[img_yellow], x=0, y=1)
source = AjaxDataSource(data_url="http://localhost:8000/rt/semaforo",
                            polling_interval=50000)
p.circle('x', 'y', source=source)
print_button = Button(label="Print")
    print_button.js_on_click(CustomJS(args=dict(source=ecg_source, plot=p), code="""
                    console.log("pippoprint");
                    plot.url = "http://localhost:8000/static/images/semaforo_rosso.png";
                    plot.image_url = "http://localhost:8000/static/images/semaforo_rosso.png";
                    console.log(plot);
                    plot.change.emit();
                """))

For the moment to test the application, I used a BUTTON and if I click on this button I should to change the image, but not are working now.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

this is not youre looking for but with server side

img_yellow = "http://localhost:8000/static/images/semaforo_yellow.png"
img_green = "http://localhost:8000/static/images/semaforo_verde.png"
img_red = "http://localhost:8000/static/images/semaforo_rosso.png"

def change_img(attr, old, new):
    p.image_url.url = img_yellow

p = figure(x_range=(0, 1), y_range=(0, 1))
p.image_url(url=[img_yellow], x=0, y=1)
source = AjaxDataSource(data_url="http://localhost:8000/rt/semaforo",
                            polling_interval=50000)
p.circle('x', 'y', source=source)
print_button = Button(label="Print")
    print_button.on_click(change_img)
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!