Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

125
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda