I want to subclass ColumnDataSource. However, when trying to use this source for plotting (in a jupyter notebook), I get
Javascript error adding output!
Error:
Model `NbColumnDataSource’ does not exist. This could be due to a widget or a custom model not being registered before first usage.
See your browser Javascript console for more details.
The subclass definition is as simple as possible (for now),
class NbColumnDataSource(bokeh.models.ColumnDataSource):
pass
Is there a trick to subclassing? When looking at the source code for the source included in bokeh I colud not see one…
every model in bokeh has to have a corresponding model implementation in bokehjs. You can override this behavior by implementing NbColumnDataSource as:
class NbColumnDataSource(bokeh.models.ColumnDataSource):
subtype = “NbColumnDataSource”
view_model = “ColumnDataSource”
…
This is how e.g. Figure model is implemented (see bokeh.plotting.figure). I’m pretty sure you won’t be able to add new properties to a model if it’s implemented like this.
Mateusz
Best,
Lukas
–
You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
but then you would not need the technique Mateusz mentions with "__subtype__". That technique is useful when you want to re-use a BokehJS implementation but want to add some new capability to the python side model only. I don't see what could ever be useful about a model subclass that just has "pass" as the entire body.
Thanks,
Bryan
···
On Apr 10, 2017, at 09:12, Mateusz Paprocki <[email protected]> wrote:
I want to subclass ColumnDataSource. However, when trying to use this source for plotting (in a jupyter notebook), I get
Javascript error adding output!
Error: Model `NbColumnDataSource' does not exist. This could be due to a widget or a custom model not being registered before first usage.
See your browser Javascript console for more details.
The subclass definition is as simple as possible (for now),
class NbColumnDataSource(bokeh.models.ColumnDataSource):
pass
Is there a trick to subclassing? When looking at the source code for the source included in bokeh I colud not see one…
every model in bokeh has to have a corresponding model implementation in bokehjs. You can override this behavior by implementing NbColumnDataSource as:
class NbColumnDataSource(bokeh.models.ColumnDataSource):
__subtype__ = "NbColumnDataSource"
__view_model__ = "ColumnDataSource"
...
This is how e.g. Figure model is implemented (see bokeh.plotting.figure). I'm pretty sure you won't be able to add new properties to a model if it's implemented like this.
Can you elaborate on what you are trying to accomplish?
I just wanted to modify init to call a custom function but otherwise the class should behave exactly like ColumnDataSource. Mateusz’ solution works perfectly for that.
Thanks a lot,
Lukas
···
Am Montag, 10. April 2017 16:19:31 UTC+2 schrieb Bryan Van de ven:
If you want new BokehJS behaviour, then you’d provide a JS implementation as described in:
but then you would not need the technique Mateusz mentions with “subtype”. That technique is useful when you want to re-use a BokehJS implementation but want to add some new capability to the python side model only. I don’t see what could ever be useful about a model subclass that just has “pass” as the entire body.
Thanks,
Bryan
On Apr 10, 2017, at 09:12, Mateusz Paprocki [email protected] wrote:
I want to subclass ColumnDataSource. However, when trying to use this source for plotting (in a jupyter notebook), I get
Javascript error adding output!
Error: Model `NbColumnDataSource’ does not exist. This could be due to a widget or a custom model not being registered before first usage.
See your browser Javascript console for more details.
The subclass definition is as simple as possible (for now),
class NbColumnDataSource(bokeh.models.ColumnDataSource):
pass
Is there a trick to subclassing? When looking at the source code for the source included in bokeh I colud not see one…
every model in bokeh has to have a corresponding model implementation in bokehjs. You can override this behavior by implementing NbColumnDataSource as:
class NbColumnDataSource(bokeh.models.ColumnDataSource):
__subtype__ = "NbColumnDataSource"
__view_model__ = "ColumnDataSource"
…
This is how e.g. Figure model is implemented (see bokeh.plotting.figure). I’m pretty sure you won’t be able to add new properties to a model if it’s implemented like this.
Mateusz
Best,
Lukas
–
You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
I want to subclass ColumnDataSource. However, when trying to use this source for plotting (in a jupyter notebook), I get
Javascript error adding output!
Error:
Model `NbColumnDataSource’ does not exist. This could be due to a widget or a custom model not being registered before first usage.
See your browser Javascript console for more details.
The subclass definition is as simple as possible (for now),
class NbColumnDataSource(bokeh.models.ColumnDataSource):
pass
Is there a trick to subclassing? When looking at the source code for the source included in bokeh I colud not see one…
every model in bokeh has to have a corresponding model implementation in bokehjs. You can override this behavior by implementing NbColumnDataSource as:
class NbColumnDataSource(bokeh.models.ColumnDataSource):
subtype = “NbColumnDataSource”
view_model = “ColumnDataSource”
…
This is how e.g. Figure model is implemented (see bokeh.plotting.figure). I’m pretty sure you won’t be able to add new properties to a model if it’s implemented like this.
That’s all I need. It works perfectly. Thank you very much!
Lukas
···
Am Montag, 10. April 2017 16:12:47 UTC+2 schrieb mateusz.paprocki: