Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bokeh Sliders cause JS errors in browser console #7171

Closed
4 tasks done
aviverma01 opened this issue Aug 15, 2023 · 3 comments · Fixed by #7441
Closed
4 tasks done

Bokeh Sliders cause JS errors in browser console #7171

aviverma01 opened this issue Aug 15, 2023 · 3 comments · Fixed by #7441
Assignees
Labels
feature:st.bokeh_chart priority:P2 status:confirmed Bug has been confirmed by the Streamlit team type:bug Something isn't working

Comments

@aviverma01
Copy link

aviverma01 commented Aug 15, 2023

Checklist

  • I have searched the existing issues for similar issues.
  • I added a very descriptive title to this issue.
  • I have provided sufficient information below to help reproduce this issue.

Summary

Hi there, I'm trying to use bokeh sliders with streamlit, but they do not show up on the screen and there are error messages in the console that say:

6737.20dd8dd6.chunk.js:2 Uncaught (in promise) Error: Model 'Slider' does not exist. This could be due to a widget or a custom model not being registered before first usage.
    at e.value (6737.20dd8dd6.chunk.js:2:29524)
    at Function.value (6737.20dd8dd6.chunk.js:2:22967)
    at Function.value (6737.20dd8dd6.chunk.js:2:23199)
    at Function.value (6737.20dd8dd6.chunk.js:2:27837)
    at 6737.20dd8dd6.chunk.js:2:10184
    at d (main.dccfd6b5.js:2:3574479)
    at Generator.<anonymous> (main.dccfd6b5.js:2:3575822)
    at Generator.next (main.dccfd6b5.js:2:3574842)
    at r (main.dccfd6b5.js:2:3567770)
    at u (main.dccfd6b5.js:2:3567973)

Reproducible Code Example

import numpy as np
import streamlit as st

from bokeh.layouts import column, row
from bokeh.models import ColumnDataSource, CustomJS, Slider
from bokeh.plotting import figure, show

x = np.linspace(0, 10, 500)
y = np.sin(x)

source = ColumnDataSource(data=dict(x=x, y=y))

plot = figure(y_range=(-10, 10), width=400, height=400)

plot.line('x', 'y', source=source, line_width=3, line_alpha=0.6)

amp = Slider(start=0.1, end=10, value=1, step=.1, title="Amplitude")
freq = Slider(start=0.1, end=10, value=1, step=.1, title="Frequency")
phase = Slider(start=-6.4, end=6.4, value=0, step=.1, title="Phase")
offset = Slider(start=-9, end=9, value=0, step=.1, title="Offset")

callback = CustomJS(args=dict(source=source, amp=amp, freq=freq, phase=phase, offset=offset),
                    code="""
    const A = amp.value
    const k = freq.value
    const phi = phase.value
    const B = offset.value

    const x = source.data.x
    const y = Array.from(x, (x) => B + A*Math.sin(k*x+phi))
    source.data = { x, y }
""")

amp.js_on_change('value', callback)
freq.js_on_change('value', callback)
phase.js_on_change('value', callback)
offset.js_on_change('value', callback)

st.bokeh_chart(row(plot, column(amp, freq, phase, offset)))

Steps To Reproduce

streamlit run test.py

Expected Behavior

Something like this shows up https://docs.bokeh.org/en/3.1.0/docs/examples/interaction/js_callbacks/slider.html

Current Behavior

"Error: Model 'Slider' does not exist. This could be due to a widget or a custom model not being registered before first usage."

Is this a regression?

  • Yes, this used to work in version 1.23.0

Debug info

  • Streamlit version: 1.25.0
  • Python version: 3.9.13
  • Operating System: MacOS
  • Browser: Chrome

Additional Information

No response

@aviverma01 aviverma01 added status:needs-triage Has not been triaged by the Streamlit team type:bug Something isn't working labels Aug 15, 2023
@carolinedlu
Copy link
Collaborator

I was able to reproduce this with Bokeh version 2.4.3 and Streamlit version 1.25.0

@willhuang1997 willhuang1997 added status:confirmed Bug has been confirmed by the Streamlit team priority:P2 and removed status:needs-triage Has not been triaged by the Streamlit team labels Aug 21, 2023
@willhuang1997
Copy link
Collaborator

Adding confirmation label to this but I did not reproduce this myself.

@mayagbarnes
Copy link
Collaborator

Reproduced & isolated error to Feature/st lib commit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature:st.bokeh_chart priority:P2 status:confirmed Bug has been confirmed by the Streamlit team type:bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants