Possible Bokeh Bug/Issue with CustomJS and PropertyValueDict

I’m not sure what I’m about to describe is a Bokeh bug, a misuse on my part of the tools, or a misunderstanding of javascript, so I thought I’d start here instead of going straight to the github issue tracker. I’m using the latest version of Bokeh 0.13.0 on py36.

Basically what I’m trying to do is update a standalone plot (no server) using the values extracted from two sliders using CustomJS callbacks. The values are extracted from the sliders and then stored in a PropertyValueDict and then the PropertyValueDict is used to update the plots. A minimal example can be found in the following:

The behavior that I’m seeing is that when I adjust one slider, the value corresponding to the other slider is set back to its default value (that I created the original python PropertyValueDict with) in the plot, although the value displayed on the slider remains at its previous value. What I want to happen is that the values are maintained as the value of whatever each sider is set to.

Does anyone have an idea of what might be going wrong or if there is a different approach/workaround for this?

Thanks,

Josh

I’m not a Bokeh expert but looking at the source of test.html, you see that PropertyValueDict is frozen when transitioning from Python to Javascript. So with every callback you get the same values.

The only “live” JS object that I know and that you can easily get your hand on while still in Python is ColumnarDataSource.

So the following works:

Instead of line 26:

state = ColumnDataSource(data=dict(y0=[default_y0], y1=[default_y1]))

Instead of line 51:

state.data[’{}’] = [cb_obj.value];

Best,
Boris

···

On Sunday, July 8, 2018 at 4:15:09 AM UTC+3, Joshua Adelman wrote:

I’m not sure what I’m about to describe is a Bokeh bug, a misuse on my part of the tools, or a misunderstanding of javascript, so I thought I’d start here instead of going straight to the github issue tracker. I’m using the latest version of Bokeh 0.13.0 on py36.

Basically what I’m trying to do is update a standalone plot (no server) using the values extracted from two sliders using CustomJS callbacks. The values are extracted from the sliders and then stored in a PropertyValueDict and then the PropertyValueDict is used to update the plots. A minimal example can be found in the following:

https://gist.github.com/synapticarbors/a701f4fb202764a329e2441e1e92b8df

The behavior that I’m seeing is that when I adjust one slider, the value corresponding to the other slider is set back to its default value (that I created the original python PropertyValueDict with) in the plot, although the value displayed on the slider remains at its previous value. What I want to happen is that the values are maintained as the value of whatever each sider is set to.

Does anyone have an idea of what might be going wrong or if there is a different approach/workaround for this?

Thanks,

Josh

Also forgot:
lines 33,34:

var y0_val = state.data[‘y0’][0];

var y1_val = state.data[‘y1’][0];

···

On Sunday, July 8, 2018 at 4:15:09 AM UTC+3, Joshua Adelman wrote:

I’m not sure what I’m about to describe is a Bokeh bug, a misuse on my part of the tools, or a misunderstanding of javascript, so I thought I’d start here instead of going straight to the github issue tracker. I’m using the latest version of Bokeh 0.13.0 on py36.

Basically what I’m trying to do is update a standalone plot (no server) using the values extracted from two sliders using CustomJS callbacks. The values are extracted from the sliders and then stored in a PropertyValueDict and then the PropertyValueDict is used to update the plots. A minimal example can be found in the following:

https://gist.github.com/synapticarbors/a701f4fb202764a329e2441e1e92b8df

The behavior that I’m seeing is that when I adjust one slider, the value corresponding to the other slider is set back to its default value (that I created the original python PropertyValueDict with) in the plot, although the value displayed on the slider remains at its previous value. What I want to happen is that the values are maintained as the value of whatever each sider is set to.

Does anyone have an idea of what might be going wrong or if there is a different approach/workaround for this?

Thanks,

Josh

Boris,

Thanks, that seems to have worked. The ergonomics of it aren’t ideal, but it works. It would be nice to have a general purpose object that didn’t have to cast everything as array-like columns to pass and persist non-columnar data. Maybe it’s just not possible at this point to do in Bokeh.

Thanks again,

Josh

···

On Sunday, July 8, 2018 at 11:30:31 AM UTC-4, Boris Ettinger wrote:

Also forgot:
lines 33,34:

var y0_val = state.data[‘y0’][0];

var y1_val = state.data[‘y1’][0];

On Sunday, July 8, 2018 at 4:15:09 AM UTC+3, Joshua Adelman wrote:

I’m not sure what I’m about to describe is a Bokeh bug, a misuse on my part of the tools, or a misunderstanding of javascript, so I thought I’d start here instead of going straight to the github issue tracker. I’m using the latest version of Bokeh 0.13.0 on py36.

Basically what I’m trying to do is update a standalone plot (no server) using the values extracted from two sliders using CustomJS callbacks. The values are extracted from the sliders and then stored in a PropertyValueDict and then the PropertyValueDict is used to update the plots. A minimal example can be found in the following:

https://gist.github.com/synapticarbors/a701f4fb202764a329e2441e1e92b8df

The behavior that I’m seeing is that when I adjust one slider, the value corresponding to the other slider is set back to its default value (that I created the original python PropertyValueDict with) in the plot, although the value displayed on the slider remains at its previous value. What I want to happen is that the values are maintained as the value of whatever each sider is set to.

Does anyone have an idea of what might be going wrong or if there is a different approach/workaround for this?

Thanks,

Josh

Hi,

It sounds like you want something like Namespace Models, which are not implemented yet:

[https://github.com/bokeh/bokeh/issues/3674](https://github.com/bokeh/bokeh/issues/3674)

As an aside, PropertyValueDict is an incredibly low level piece of Bokeh. It’s really purely an implementation detail, and not meant to be used at all by end users which is why its not ever demonstrated in any examples, tutorials, or user guide materials.

Thanks,

Bryan

···

On Jul 8, 2018, at 15:12, Joshua Adelman [email protected] wrote:

Boris,

Thanks, that seems to have worked. The ergonomics of it aren’t ideal, but it works. It would be nice to have a general purpose object that didn’t have to cast everything as array-like columns to pass and persist non-columnar data. Maybe it’s just not possible at this point to do in Bokeh.

Thanks again,

Josh

On Sunday, July 8, 2018 at 11:30:31 AM UTC-4, Boris Ettinger wrote:

Also forgot:
lines 33,34:

var y0_val = state.data[‘y0’][0];

var y1_val = state.data[‘y1’][0];

On Sunday, July 8, 2018 at 4:15:09 AM UTC+3, Joshua Adelman wrote:

I’m not sure what I’m about to describe is a Bokeh bug, a misuse on my part of the tools, or a misunderstanding of javascript, so I thought I’d start here instead of going straight to the github issue tracker. I’m using the latest version of Bokeh 0.13.0 on py36.

Basically what I’m trying to do is update a standalone plot (no server) using the values extracted from two sliders using CustomJS callbacks. The values are extracted from the sliders and then stored in a PropertyValueDict and then the PropertyValueDict is used to update the plots. A minimal example can be found in the following:

https://gist.github.com/synapticarbors/a701f4fb202764a329e2441e1e92b8df

The behavior that I’m seeing is that when I adjust one slider, the value corresponding to the other slider is set back to its default value (that I created the original python PropertyValueDict with) in the plot, although the value displayed on the slider remains at its previous value. What I want to happen is that the values are maintained as the value of whatever each sider is set to.

Does anyone have an idea of what might be going wrong or if there is a different approach/workaround for this?

Thanks,

Josh


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].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/b0fcece9-3ae6-47dc-931a-29fb96e8121d%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Joshua,

I just realized that the easiest and most elegant way to use sliders’ values is just to pass the sliders as parameters to callbacks.
I rewrote sliders.py as a standalone in this gist https://gist.github.com/2torus/d320575cea49c04e221784737c51fba5

Bryan,

Is it worth committing the gist above to Bokeh as an example?

Best,

Boris

···

On Mon, Jul 9, 2018 at 7:32 AM Bryan Van de ven [email protected] wrote:

Hi,

It sounds like you want something like Namespace Models, which are not implemented yet:

https://github.com/bokeh/bokeh/issues/3674

As an aside, PropertyValueDict is an incredibly low level piece of Bokeh. It’s really purely an implementation detail, and not meant to be used at all by end users which is why its not ever demonstrated in any examples, tutorials, or user guide materials.

Thanks,

Bryan

On Jul 8, 2018, at 15:12, Joshua Adelman [email protected] wrote:

Boris,

Thanks, that seems to have worked. The ergonomics of it aren’t ideal, but it works. It would be nice to have a general purpose object that didn’t have to cast everything as array-like columns to pass and persist non-columnar data. Maybe it’s just not possible at this point to do in Bokeh.

Thanks again,

Josh

On Sunday, July 8, 2018 at 11:30:31 AM UTC-4, Boris Ettinger wrote:

Also forgot:
lines 33,34:

var y0_val = state.data[‘y0’][0];

var y1_val = state.data[‘y1’][0];

On Sunday, July 8, 2018 at 4:15:09 AM UTC+3, Joshua Adelman wrote:

I’m not sure what I’m about to describe is a Bokeh bug, a misuse on my part of the tools, or a misunderstanding of javascript, so I thought I’d start here instead of going straight to the github issue tracker. I’m using the latest version of Bokeh 0.13.0 on py36.

Basically what I’m trying to do is update a standalone plot (no server) using the values extracted from two sliders using CustomJS callbacks. The values are extracted from the sliders and then stored in a PropertyValueDict and then the PropertyValueDict is used to update the plots. A minimal example can be found in the following:

https://gist.github.com/synapticarbors/a701f4fb202764a329e2441e1e92b8df

The behavior that I’m seeing is that when I adjust one slider, the value corresponding to the other slider is set back to its default value (that I created the original python PropertyValueDict with) in the plot, although the value displayed on the slider remains at its previous value. What I want to happen is that the values are maintained as the value of whatever each sider is set to.

Does anyone have an idea of what might be going wrong or if there is a different approach/workaround for this?

Thanks,

Josh

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].

To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/b0fcece9-3ae6-47dc-931a-29fb96e8121d%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.

You received this message because you are subscribed to a topic in the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this topic, visit https://groups.google.com/a/continuum.io/d/topic/bokeh/AhzYOLZa4Kw/unsubscribe.

To unsubscribe from this group and all its topics, send an email to [email protected].

To post to this group, send email to [email protected].

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/BED90E52-2B29-446B-BDB3-C90D721F5F45%40anaconda.com.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Hi,

This is already what the gallery example does, unless I am missing something:

[https://bokeh.pydata.org/en/latest/docs/gallery/slider.html](https://bokeh.pydata.org/en/latest/docs/gallery/slider.html)

Thanks,

Bryan

···

On Jul 9, 2018, at 13:06, Boris Ettinger [email protected] wrote:

Joshua,

I just realized that the easiest and most elegant way to use sliders’ values is just to pass the sliders as parameters to callbacks.
I rewrote sliders.py as a standalone in this gist https://gist.github.com/2torus/d320575cea49c04e221784737c51fba5

Bryan,

Is it worth committing the gist above to Bokeh as an example?

Best,

Boris

On Mon, Jul 9, 2018 at 7:32 AM Bryan Van de ven [email protected] wrote:

Hi,

It sounds like you want something like Namespace Models, which are not implemented yet:

[https://github.com/bokeh/bokeh/issues/3674](https://github.com/bokeh/bokeh/issues/3674)

As an aside, PropertyValueDict is an incredibly low level piece of Bokeh. It’s really purely an implementation detail, and not meant to be used at all by end users which is why its not ever demonstrated in any examples, tutorials, or user guide materials.

Thanks,

Bryan

On Jul 8, 2018, at 15:12, Joshua Adelman [email protected] wrote:

Boris,

Thanks, that seems to have worked. The ergonomics of it aren’t ideal, but it works. It would be nice to have a general purpose object that didn’t have to cast everything as array-like columns to pass and persist non-columnar data. Maybe it’s just not possible at this point to do in Bokeh.

Thanks again,

Josh

On Sunday, July 8, 2018 at 11:30:31 AM UTC-4, Boris Ettinger wrote:

Also forgot:
lines 33,34:

var y0_val = state.data[‘y0’][0];

var y1_val = state.data[‘y1’][0];

On Sunday, July 8, 2018 at 4:15:09 AM UTC+3, Joshua Adelman wrote:

I’m not sure what I’m about to describe is a Bokeh bug, a misuse on my part of the tools, or a misunderstanding of javascript, so I thought I’d start here instead of going straight to the github issue tracker. I’m using the latest version of Bokeh 0.13.0 on py36.

Basically what I’m trying to do is update a standalone plot (no server) using the values extracted from two sliders using CustomJS callbacks. The values are extracted from the sliders and then stored in a PropertyValueDict and then the PropertyValueDict is used to update the plots. A minimal example can be found in the following:

https://gist.github.com/synapticarbors/a701f4fb202764a329e2441e1e92b8df

The behavior that I’m seeing is that when I adjust one slider, the value corresponding to the other slider is set back to its default value (that I created the original python PropertyValueDict with) in the plot, although the value displayed on the slider remains at its previous value. What I want to happen is that the values are maintained as the value of whatever each sider is set to.

Does anyone have an idea of what might be going wrong or if there is a different approach/workaround for this?

Thanks,

Josh

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].

To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/b0fcece9-3ae6-47dc-931a-29fb96e8121d%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.

You received this message because you are subscribed to a topic in the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this topic, visit https://groups.google.com/a/continuum.io/d/topic/bokeh/AhzYOLZa4Kw/unsubscribe.

To unsubscribe from this group and all its topics, send an email to [email protected].

To post to this group, send email to [email protected].

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/BED90E52-2B29-446B-BDB3-C90D721F5F45%40anaconda.com.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.

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].

To post to this group, send email to [email protected].

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/CAMYuvi2XYHHgoMLps003Lpd0j4M2dv7WUiGYzSqbqeBK7hTYWw%40mail.gmail.com.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.

(facepalm) You are right, it is the same example.

···

On Mon, Jul 9, 2018 at 11:10 PM Bryan Van de ven [email protected] wrote:

Hi,

This is already what the gallery example does, unless I am missing something:

https://bokeh.pydata.org/en/latest/docs/gallery/slider.html

Thanks,

Bryan

On Jul 9, 2018, at 13:06, Boris Ettinger [email protected] wrote:

Joshua,

I just realized that the easiest and most elegant way to use sliders’ values is just to pass the sliders as parameters to callbacks.
I rewrote sliders.py as a standalone in this gist https://gist.github.com/2torus/d320575cea49c04e221784737c51fba5

Bryan,

Is it worth committing the gist above to Bokeh as an example?

Best,

Boris

On Mon, Jul 9, 2018 at 7:32 AM Bryan Van de ven [email protected] wrote:

Hi,

It sounds like you want something like Namespace Models, which are not implemented yet:

[https://github.com/bokeh/bokeh/issues/3674](https://github.com/bokeh/bokeh/issues/3674)

As an aside, PropertyValueDict is an incredibly low level piece of Bokeh. It’s really purely an implementation detail, and not meant to be used at all by end users which is why its not ever demonstrated in any examples, tutorials, or user guide materials.

Thanks,

Bryan

On Jul 8, 2018, at 15:12, Joshua Adelman [email protected] wrote:

Boris,

Thanks, that seems to have worked. The ergonomics of it aren’t ideal, but it works. It would be nice to have a general purpose object that didn’t have to cast everything as array-like columns to pass and persist non-columnar data. Maybe it’s just not possible at this point to do in Bokeh.

Thanks again,

Josh

On Sunday, July 8, 2018 at 11:30:31 AM UTC-4, Boris Ettinger wrote:

Also forgot:
lines 33,34:

var y0_val = state.data[‘y0’][0];

var y1_val = state.data[‘y1’][0];

On Sunday, July 8, 2018 at 4:15:09 AM UTC+3, Joshua Adelman wrote:

I’m not sure what I’m about to describe is a Bokeh bug, a misuse on my part of the tools, or a misunderstanding of javascript, so I thought I’d start here instead of going straight to the github issue tracker. I’m using the latest version of Bokeh 0.13.0 on py36.

Basically what I’m trying to do is update a standalone plot (no server) using the values extracted from two sliders using CustomJS callbacks. The values are extracted from the sliders and then stored in a PropertyValueDict and then the PropertyValueDict is used to update the plots. A minimal example can be found in the following:

https://gist.github.com/synapticarbors/a701f4fb202764a329e2441e1e92b8df

The behavior that I’m seeing is that when I adjust one slider, the value corresponding to the other slider is set back to its default value (that I created the original python PropertyValueDict with) in the plot, although the value displayed on the slider remains at its previous value. What I want to happen is that the values are maintained as the value of whatever each sider is set to.

Does anyone have an idea of what might be going wrong or if there is a different approach/workaround for this?

Thanks,

Josh

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].

To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/b0fcece9-3ae6-47dc-931a-29fb96e8121d%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.

You received this message because you are subscribed to a topic in the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this topic, visit https://groups.google.com/a/continuum.io/d/topic/bokeh/AhzYOLZa4Kw/unsubscribe.

To unsubscribe from this group and all its topics, send an email to [email protected].

To post to this group, send email to [email protected].

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/BED90E52-2B29-446B-BDB3-C90D721F5F45%40anaconda.com.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.

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].

To post to this group, send email to [email protected].

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/CAMYuvi2XYHHgoMLps003Lpd0j4M2dv7WUiGYzSqbqeBK7hTYWw%40mail.gmail.com.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.

You received this message because you are subscribed to a topic in the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this topic, visit https://groups.google.com/a/continuum.io/d/topic/bokeh/AhzYOLZa4Kw/unsubscribe.

To unsubscribe from this group and all its topics, send an email to [email protected].

To post to this group, send email to [email protected].

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/DE711E72-ADC8-4A2B-B4B7-54F0FD44DC61%40anaconda.com.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.