I’m experimenting a little bit with glyphs and wanted to inherit from Scatter to see what kinds of things I can do.
This is my code
p = figure(title="Click to add points. Spline will update.",
tools="pan,wheel_zoom,box_zoom,tap,reset",
width=1024, height=1024
)
p_vertices_glyph = Vertices(x='x', y='y')
p_points = p.add_glyph(points_source, p_vertices_glyph)
p_points.selection_glyph = p_vertices_glyph.clone()
p_points.selection_glyph.size = 16
### vertices.py
from typing import Any
from bokeh.models import Scatter
from bokeh.util.compiler import JavaScript
class Vertices(Scatter):
__implementation__ = JavaScript("""
import {Scatter, ScatterView} from "models/glyphs/scatter";
export class VerticesView extends ScatterView {
initialize() {
super.initialize();
console.log("[Bokeh] VerticesView loaded and initialized");
}
}
export class Vertices extends Scatter {
static __module__ = "Vertices";
static __view_type__ = VerticesView;
}
""")
def __init__(self, *args: Any, **kwargs: Any) -> None:
super().__init__(*args, **kwargs)
When starting the sample I get in the browser in the console the following error: y: could not resolve type 'Vertices', which could be due to a widget or a custom model not being registered before first usage
`
Complete error message:
bokeh.min.js?v=5b74dbd22e38c51171f871973702aa79f54ff23ea2f60323446d118e71a0b292cc81d26415b4248908d4788b79b741b805ccbd6c9639e8a4921454cb1b44d480:186 [bokeh 3.7.2] setting log level to: 'info'
bokeh.min.js?v=5b74dbd22e38c51171f871973702aa79f54ff23ea2f60323446d118e71a0b292cc81d26415b4248908d4788b79b741b805ccbd6c9639e8a4921454cb1b44d480:234 [bokeh 3.7.2] Websocket connection 0 is now open
bokeh.min.js?v=5b74dbd22e38c51171f871973702aa79f54ff23ea2f60323446d118e71a0b292cc81d26415b4248908d4788b79b741b805ccbd6c9639e8a4921454cb1b44d480:234 y: could not resolve type 'Vertices', which could be due to a widget or a custom model not being registered before first usage
at p.error (http://localhost:5006/static/js/bokeh.min.js?v=5b74dbd22e38c51171f871973702aa79f54ff23ea2f60323446d118e71a0b292cc81d26415b4248908d4788b79b741b805ccbd6c9639e8a4921454cb1b44d480:213:4858)
at p._resolve_type (http://localhost:5006/static/js/bokeh.min.js?v=5b74dbd22e38c51171f871973702aa79f54ff23ea2f60323446d118e71a0b292cc81d26415b4248908d4788b79b741b805ccbd6c9639e8a4921454cb1b44d480:213:4966)
at p._decode_object_ref (http://localhost:5006/static/js/bokeh.min.js?v=5b74dbd22e38c51171f871973702aa79f54ff23ea2f60323446d118e71a0b292cc81d26415b4248908d4788b79b741b805ccbd6c9639e8a4921454cb1b44d480:213:4559)
at p._decode (http://localhost:5006/static/js/bokeh.min.js?v=5b74dbd22e38c51171f871973702aa79f54ff23ea2f60323446d118e71a0b292cc81d26415b4248908d4788b79b741b805ccbd6c9639e8a4921454cb1b44d480:213:1739)
at p._decode_plain_object (http://localhost:5006/static/js/bokeh.min.js?v=5b74dbd22e38c51171f871973702aa79f54ff23ea2f60323446d118e71a0b292cc81d26415b4248908d4788b79b741b805ccbd6c9639e8a4921454cb1b44d480:213:2300)
at p._decode (http://localhost:5006/static/js/bokeh.min.js?v=5b74dbd22e38c51171f871973702aa79f54ff23ea2f60323446d118e71a0b292cc81d26415b4248908d4788b79b741b805ccbd6c9639e8a4921454cb1b44d480:213:1026)
at p._decode_object_ref (http://localhost:5006/static/js/bokeh.min.js?v=5b74dbd22e38c51171f871973702aa79f54ff23ea2f60323446d118e71a0b292cc81d26415b4248908d4788b79b741b805ccbd6c9639e8a4921454cb1b44d480:213:4623)
at p._decode (http://localhost:5006/static/js/bokeh.min.js?v=5b74dbd22e38c51171f871973702aa79f54ff23ea2f60323446d118e71a0b292cc81d26415b4248908d4788b79b741b805ccbd6c9639e8a4921454cb1b44d480:213:1739)
at http://localhost:5006/static/js/bokeh.min.js?v=5b74dbd22e38c51171f871973702aa79f54ff23ea2f60323446d118e71a0b292cc81d26415b4248908d4788b79b741b805ccbd6c9639e8a4921454cb1b44d480:213:2209
at d (http://localhost:5006/static/js/bokeh.min.js?v=5b74dbd22e38c51171f871973702aa79f54ff23ea2f60323446d118e71a0b292cc81d26415b4248908d4788b79b741b805ccbd6c9639e8a4921454cb1b44d480:179:3619)
_repull_session_doc @ bokeh.min.js?v=5b74dbd22e38c51171f871973702aa79f54ff23ea2f60323446d118e71a0b292cc81d26415b4248908d4788b79b741b805ccbd6c9639e8a4921454cb1b44d480:234
await in _repull_session_doc
_awaiting_ack_handler @ bokeh.min.js?v=5b74dbd22e38c51171f871973702aa79f54ff23ea2f60323446d118e71a0b292cc81d26415b4248908d4788b79b741b805ccbd6c9639e8a4921454cb1b44d480:234
_current_handler @ bokeh.min.js?v=5b74dbd22e38c51171f871973702aa79f54ff23ea2f60323446d118e71a0b292cc81d26415b4248908d4788b79b741b805ccbd6c9639e8a4921454cb1b44d480:234
_on_message @ bokeh.min.js?v=5b74dbd22e38c51171f871973702aa79f54ff23ea2f60323446d118e71a0b292cc81d26415b4248908d4788b79b741b805ccbd6c9639e8a4921454cb1b44d480:234
Promise.socket.onmessage @ bokeh.min.js?v=5b74dbd22e38c51171f871973702aa79f54ff23ea2f60323446d118e71a0b292cc81d26415b4248908d4788b79b741b805ccbd6c9639e8a4921454cb1b44d480:234
bokeh.min.js?v=5b74dbd22e38c51171f871973702aa79f54ff23ea2f60323446d118e71a0b292cc81d26415b4248908d4788b79b741b805ccbd6c9639e8a4921454cb1b44d480:234 [bokeh 3.7.2] Failed to repull session Error: could not resolve type 'Vertices', which could be due to a widget or a custom model not being registered before first usage
_repull_session_doc @ bokeh.min.js?v=5b74dbd22e38c51171f871973702aa79f54ff23ea2f60323446d118e71a0b292cc81d26415b4248908d4788b79b741b805ccbd6c9639e8a4921454cb1b44d480:234
await in _repull_session_doc
_awaiting_ack_handler @ bokeh.min.js?v=5b74dbd22e38c51171f871973702aa79f54ff23ea2f60323446d118e71a0b292cc81d26415b4248908d4788b79b741b805ccbd6c9639e8a4921454cb1b44d480:234
_current_handler @ bokeh.min.js?v=5b74dbd22e38c51171f871973702aa79f54ff23ea2f60323446d118e71a0b292cc81d26415b4248908d4788b79b741b805ccbd6c9639e8a4921454cb1b44d480:234
_on_message @ bokeh.min.js?v=5b74dbd22e38c51171f871973702aa79f54ff23ea2f60323446d118e71a0b292cc81d26415b4248908d4788b79b741b805ccbd6c9639e8a4921454cb1b44d480:234
Promise.socket.onmessage @ bokeh.min.js?v=5b74dbd22e38c51171f871973702aa79f54ff23ea2f60323446d118e71a0b292cc81d26415b4248908d4788b79b741b805ccbd6c9639e8a4921454cb1b44d480:234
[NEW] Explain Console errors by using Copilot in Edge: click
to explain an error.
Learn more
Don't show again
bokeh.min.js?v=5b74dbd22e38c51171f871973702aa79f54ff23ea2f60323446d118e71a0b292cc81d26415b4248908d4788b79b741b805ccbd6c9639e8a4921454cb1b44d480:233 [bokeh 3.7.2] Failed to load Bokeh session Cmxe0Ag4cLSXJ6mnA6Km0yzQEryNzd7P03xREgHzklQN: Error: could not resolve type 'Vertices', which could be due to a widget or a custom model not being registered before first usage
n.add_document_from_session @ bokeh.min.js?v=5b74dbd22e38c51171f871973702aa79f54ff23ea2f60323446d118e71a0b292cc81d26415b4248908d4788b79b741b805ccbd6c9639e8a4921454cb1b44d480:233
await in n.add_document_from_session
k @ bokeh.min.js?v=5b74dbd22e38c51171f871973702aa79f54ff23ea2f60323446d118e71a0b292cc81d26415b4248908d4788b79b741b805ccbd6c9639e8a4921454cb1b44d480:164
t.embed_items @ bokeh.min.js?v=5b74dbd22e38c51171f871973702aa79f54ff23ea2f60323446d118e71a0b292cc81d26415b4248908d4788b79b741b805ccbd6c9639e8a4921454cb1b44d480:164
await in t.embed_items
embed_document @ sample_spline:82
(anonymous) @ sample_spline:85
(anonymous) @ sample_spline:101
o.safely @ bokeh.min.js?v=5b74dbd22e38c51171f871973702aa79f54ff23ea2f60323446d118e71a0b292cc81d26415b4248908d4788b79b741b805ccbd6c9639e8a4921454cb1b44d480:241
fn @ sample_spline:77
bokeh.min.js?v=5b74dbd22e38c51171f871973702aa79f54ff23ea2f60323446d118e71a0b292cc81d26415b4248908d4788b79b741b805ccbd6c9639e8a4921454cb1b44d480:164 Error rendering Bokeh items: y: could not resolve type 'Vertices', which could be due to a widget or a custom model not being registered before first usage
at p.error (http://localhost:5006/static/js/bokeh.min.js?v=5b74dbd22e38c51171f871973702aa79f54ff23ea2f60323446d118e71a0b292cc81d26415b4248908d4788b79b741b805ccbd6c9639e8a4921454cb1b44d480:213:4858)
at p._resolve_type (http://localhost:5006/static/js/bokeh.min.js?v=5b74dbd22e38c51171f871973702aa79f54ff23ea2f60323446d118e71a0b292cc81d26415b4248908d4788b79b741b805ccbd6c9639e8a4921454cb1b44d480:213:4966)
at p._decode_object_ref (http://localhost:5006/static/js/bokeh.min.js?v=5b74dbd22e38c51171f871973702aa79f54ff23ea2f60323446d118e71a0b292cc81d26415b4248908d4788b79b741b805ccbd6c9639e8a4921454cb1b44d480:213:4559)
at p._decode (http://localhost:5006/static/js/bokeh.min.js?v=5b74dbd22e38c51171f871973702aa79f54ff23ea2f60323446d118e71a0b292cc81d26415b4248908d4788b79b741b805ccbd6c9639e8a4921454cb1b44d480:213:1739)
at p._decode_plain_object (http://localhost:5006/static/js/bokeh.min.js?v=5b74dbd22e38c51171f871973702aa79f54ff23ea2f60323446d118e71a0b292cc81d26415b4248908d4788b79b741b805ccbd6c9639e8a4921454cb1b44d480:213:2300)
at p._decode (http://localhost:5006/static/js/bokeh.min.js?v=5b74dbd22e38c51171f871973702aa79f54ff23ea2f60323446d118e71a0b292cc81d26415b4248908d4788b79b741b805ccbd6c9639e8a4921454cb1b44d480:213:1026)
at p._decode_object_ref (http://localhost:5006/static/js/bokeh.min.js?v=5b74dbd22e38c51171f871973702aa79f54ff23ea2f60323446d118e71a0b292cc81d26415b4248908d4788b79b741b805ccbd6c9639e8a4921454cb1b44d480:213:4623)
at p._decode (http://localhost:5006/static/js/bokeh.min.js?v=5b74dbd22e38c51171f871973702aa79f54ff23ea2f60323446d118e71a0b292cc81d26415b4248908d4788b79b741b805ccbd6c9639e8a4921454cb1b44d480:213:1739)
at http://localhost:5006/static/js/bokeh.min.js?v=5b74dbd22e38c51171f871973702aa79f54ff23ea2f60323446d118e71a0b292cc81d26415b4248908d4788b79b741b805ccbd6c9639e8a4921454cb1b44d480:213:2209
at d (http://localhost:5006/static/js/bokeh.min.js?v=5b74dbd22e38c51171f871973702aa79f54ff23ea2f60323446d118e71a0b292cc81d26415b4248908d4788b79b741b805ccbd6c9639e8a4921454cb1b44d480:179:3619)
k @ bokeh.min.js?v=5b74dbd22e38c51171f871973702aa79f54ff23ea2f60323446d118e71a0b292cc81d26415b4248908d4788b79b741b805ccbd6c9639e8a4921454cb1b44d480:164
await in k
t.embed_items @ bokeh.min.js?v=5b74dbd22e38c51171f871973702aa79f54ff23ea2f60323446d118e71a0b292cc81d26415b4248908d4788b79b741b805ccbd6c9639e8a4921454cb1b44d480:164
await in t.embed_items
embed_document @ sample_spline:82
(anonymous) @ sample_spline:85
(anonymous) @ sample_spline:101
o.safely @ bokeh.min.js?v=5b74dbd22e38c51171f871973702aa79f54ff23ea2f60323446d118e71a0b292cc81d26415b4248908d4788b79b741b805ccbd6c9639e8a4921454cb1b44d480:241
fn @ sample_spline:77
I found a similar question but could not reply to it since its already closed.
Bokeh custom model registration - Community Support - Bokeh Discourse
Does anybody know how to register the vertice class such that the type can be resolved?