Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

124
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda