Is there a way to change a single value using CustomJS callbacks?

I have some circle glpyhs and I want the radius to be adjustable with a slider. I have the following example working:

···

fig = Figure(plot_width=400, plot_height=400)

source = ColumnDataSource(data=dict(

x = np.random.random(size=8),

y = np.random.random(size=8),

r = [.1]*8

)

)

cir = fig.circle(“x”, “y”, radius=“r”, source=source, fill_color=“red”, fill_alpha=.5)

callback = CustomJS(args=dict(source=source), code="""

data = source.get(‘data’);

r = data[‘r’];

new_r = cb_obj.get(‘value’);

for (i = 0; i < 8; i++) {

r[i] = new_r;

}

source.trigger(‘change’);

“”")

slider = Slider(start=.01, end=.2, value=.1, step=0.01, callback=callback)


Notice that I have to have an array of radii. Is there anyway to replicate this behavior with just setting the value the same for all circles without using an array? I am needing to do this for a plot with 150,000 points and it seems the

performance is struggling since I need to set the radius for all 150000 points when I do it this way.

I’ve tried stuff like:


callback = CustomJS(args=dict(radius = cir.glpyh.radius), code="""

(some JS code)

“”"


and I get an error saying it was expecting a list of values.

Any other ideas?

Thanks.

(Untested) Try:

  callback = CustomJS(args=dict(glyph=cir.glpyh), code="""
    glyph.radius = { value: 10 }
  """)

Also note, only model objects can go in "args". So, "glyph" is ok, but not "glyph.radius"

Bryan

···

On Jul 5, 2016, at 3:11 PM, [email protected] wrote:

I have some circle glpyhs and I want the radius to be adjustable with a slider. I have the following example working:

--------------------------------------------------------------------------
fig = Figure(plot_width=400, plot_height=400)

source = ColumnDataSource(data=dict(
        x = np.random.random(size=8),
        y = np.random.random(size=8),
        r = [.1]*8
    )
)

cir = fig.circle("x", "y", radius="r", source=source, fill_color="red", fill_alpha=.5)

callback = CustomJS(args=dict(source=source), code="""
    data = source.get('data');
    r = data['r'];
    
    new_r = cb_obj.get('value');
    for (i = 0; i < 8; i++) {
        r[i] = new_r;
    }
    
    source.trigger('change');
""")

slider = Slider(start=.01, end=.2, value=.1, step=0.01, callback=callback)
------------------------------------------------------------

Notice that I have to have an array of radii. Is there anyway to replicate this behavior with just setting the value the same for all circles without using an array? I am needing to do this for a plot with 150,000 points and it seems the
performance is struggling since I need to set the radius for all 150000 points when I do it this way.

I've tried stuff like:
------------------------------------------------------------
callback = CustomJS(args=dict(radius = cir.glpyh.radius), code="""
  (some JS code)
"""
-----------------------------------------------------------
and I get an error saying it was expecting a list of values.

Any other ideas?

Thanks.

--
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/228f3462-e599-44dc-8773-48efcdd98471%40continuum.io\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.

Here is the code I tried:

import numpy as np
from bokeh.plotting import Figure, output_file, show
from bokeh.layouts import column
from bokeh.models import CustomJS, Slider

fig = Figure(plot_width=400, plot_height=400)

COUNT = 10
cir = fig.circle(x=np.random.rand(COUNT), y=np.random.rand(COUNT),
fill_color=“red”, line_color=“black”, radius=.05)

callback = CustomJS(args=dict(glyph=cir.glyph), code=“”"
glyph.radius = { value: cb_obj.get(‘value’)/100 }

console.log(glyph.radius)

“”")

slider = Slider(start=1, end=10, step=0.1, value=5, callback=callback)

output_file(“temp.html”)

show(column(fig, slider))

``

I went to the console and confirmed that the value of the radius was getting changed, but the changes aren’t being reflected in the glyph. I know when you’re dealing with a ColumnDataSource, you call source.trigger(“change”) to trigger it to update. I tried adding glyph.trigger(“change”), but that didn’t help. Is there something similar that is necessary? Is this a bug?

Thanks,

Tanner

···

On Tuesday, July 5, 2016 at 10:33:03 PM UTC-6, Bryan Van de ven wrote:

(Untested) Try:

    callback  = CustomJS(args=dict(glyph=cir.glpyh), code="""

            glyph.radius = { value: 10 }

    """)

Also note, only model objects can go in “args”. So, “glyph” is ok, but not “glyph.radius”

Bryan

On Jul 5, 2016, at 3:11 PM, [email protected] wrote:

I have some circle glpyhs and I want the radius to be adjustable with a slider. I have the following example working:


fig = Figure(plot_width=400, plot_height=400)

source = ColumnDataSource(data=dict(

    x = np.random.random(size=8),
    y = np.random.random(size=8),
    r = [.1]*8
)

)

cir = fig.circle(“x”, “y”, radius=“r”, source=source, fill_color=“red”, fill_alpha=.5)

callback = CustomJS(args=dict(source=source), code=“”"

data = source.get('data');
r = data['r'];
new_r = cb_obj.get('value');
for (i = 0; i < 8; i++) {
    r[i] = new_r;
}
source.trigger('change');

“”")

slider = Slider(start=.01, end=.2, value=.1, step=0.01, callback=callback)


Notice that I have to have an array of radii. Is there anyway to replicate this behavior with just setting the value the same for all circles without using an array? I am needing to do this for a plot with 150,000 points and it seems the
performance is struggling since I need to set the radius for all 150000 points when I do it this way.

I’ve tried stuff like:


callback = CustomJS(args=dict(radius = cir.glpyh.radius), code=“”"

(some JS code)

“”"


and I get an error saying it was expecting a list of values.

Any other ideas?

Thanks.


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/228f3462-e599-44dc-8773-48efcdd98471%40continuum.io.

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

Hi Tanner,

I forgot that currently only setting line and fill properties is really supported in this manner. There is an open issue:

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

However, this will fucntion as a workaround for now:

  callback = CustomJS(args=dict(renderer=cir), code="""
    renderer.glyph.radius = { value: cb_obj.get('value')/100 }
    renderer.data_source.trigger('change')
  """)

Thanks,

Bryan

···

On Jul 7, 2016, at 10:09 PM, [email protected] wrote:

Here is the code I tried:

import numpy as np
from bokeh.plotting import Figure, output_file, show
from bokeh.layouts import column
from bokeh.models import CustomJS, Slider

fig = Figure(plot_width=400, plot_height=400)

COUNT = 10
cir = fig.circle(x=np.random.rand(COUNT), y=np.random.rand(COUNT),
                fill_color="red", line_color="black", radius=.05)

callback = CustomJS(args=dict(glyph=cir.glyph), code="""
    glyph.radius = { value: cb_obj.get('value')/100 }

    console.log(glyph.radius)
""")

slider = Slider(start=1, end=10, step=0.1, value=5, callback=callback)

output_file("temp.html")

show(column(fig, slider))

I went to the console and confirmed that the value of the radius was getting changed, but the changes aren't being reflected in the glyph. I know when you're dealing with a ColumnDataSource, you call source.trigger("change") to trigger it to update. I tried adding glyph.trigger("change"), but that didn't help. Is there something similar that is necessary? Is this a bug?

Thanks,

Tanner

On Tuesday, July 5, 2016 at 10:33:03 PM UTC-6, Bryan Van de ven wrote:
(Untested) Try:

        callback = CustomJS(args=dict(glyph=cir.glpyh), code="""
                glyph.radius = { value: 10 }
        """)

Also note, only model objects can go in "args". So, "glyph" is ok, but not "glyph.radius"

Bryan

> On Jul 5, 2016, at 3:11 PM, tannerkch...@gmail.com wrote:
>
> I have some circle glpyhs and I want the radius to be adjustable with a slider. I have the following example working:
>
> --------------------------------------------------------------------------
> fig = Figure(plot_width=400, plot_height=400)
>
> source = ColumnDataSource(data=dict(
> x = np.random.random(size=8),
> y = np.random.random(size=8),
> r = [.1]*8
> )
> )
>
> cir = fig.circle("x", "y", radius="r", source=source, fill_color="red", fill_alpha=.5)
>
> callback = CustomJS(args=dict(source=source), code="""
> data = source.get('data');
> r = data['r'];
>
> new_r = cb_obj.get('value');
> for (i = 0; i < 8; i++) {
> r[i] = new_r;
> }
>
> source.trigger('change');
> """)
>
> slider = Slider(start=.01, end=.2, value=.1, step=0.01, callback=callback)
> ------------------------------------------------------------
>
> Notice that I have to have an array of radii. Is there anyway to replicate this behavior with just setting the value the same for all circles without using an array? I am needing to do this for a plot with 150,000 points and it seems the
> performance is struggling since I need to set the radius for all 150000 points when I do it this way.
>
> I've tried stuff like:
> ------------------------------------------------------------
> callback = CustomJS(args=dict(radius = cir.glpyh.radius), code="""
> (some JS code)
> """
> -----------------------------------------------------------
> and I get an error saying it was expecting a list of values.
>
> Any other ideas?
>
> Thanks.
>
> --
> 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 bokeh+un...@continuum.io.
> To post to this group, send email to bo...@continuum.io.
> To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/228f3462-e599-44dc-8773-48efcdd98471%40continuum.io\.
> 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/4cbfd8a9-75af-45a6-87d9-5acecfc05319%40continuum.io\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.

Awesome! Thanks for always responding so quickly. Do you know of a similar work around when using on_change?

import numpy as np
from bokeh.io import curdoc
from bokeh.plotting import Figure, output_file, show
from bokeh.layouts import column
from bokeh.models import CustomJS, Slider

fig = Figure(plot_width=400, plot_height=400)

COUNT = 10
cir = fig.circle(x=np.random.rand(COUNT), y=np.random.rand(COUNT),
fill_color=“red”, line_color=“black”, radius=.05)

def update_size(attrname, old, new):
cir.glyph.radius = slider.value/100.

slider = Slider(start=1, end=10, step=0.1, value=5)
slider.on_change(‘value’, update_size)

curdoc().add_root(column(fig, slider))

``

Thanks,

Tanner

···

On Thursday, July 7, 2016 at 9:26:07 PM UTC-6, Bryan Van de ven wrote:

Hi Tanner,

I forgot that currently only setting line and fill properties is really supported in this manner. There is an open issue:

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

However, this will fucntion as a workaround for now:

    callback = CustomJS(args=dict(renderer=cir), code="""
            renderer.glyph.radius = { value: cb_obj.get('value')/100 }
            renderer.data_source.trigger('change')

    """)

Thanks,

Bryan

On Jul 7, 2016, at 10:09 PM, [email protected] wrote:

Here is the code I tried:

import numpy as np

from bokeh.plotting import Figure, output_file, show

from bokeh.layouts import column

from bokeh.models import CustomJS, Slider

fig = Figure(plot_width=400, plot_height=400)

COUNT = 10

cir = fig.circle(x=np.random.rand(COUNT), y=np.random.rand(COUNT),

            fill_color="red", line_color="black", radius=.05)

callback = CustomJS(args=dict(glyph=cir.glyph), code=“”"

glyph.radius = { value: cb_obj.get('value')/100 }
console.log(glyph.radius)

“”")

slider = Slider(start=1, end=10, step=0.1, value=5, callback=callback)

output_file(“temp.html”)

show(column(fig, slider))

I went to the console and confirmed that the value of the radius was getting changed, but the changes aren’t being reflected in the glyph. I know when you’re dealing with a ColumnDataSource, you call source.trigger(“change”) to trigger it to update. I tried adding glyph.trigger(“change”), but that didn’t help. Is there something similar that is necessary? Is this a bug?

Thanks,

Tanner

On Tuesday, July 5, 2016 at 10:33:03 PM UTC-6, Bryan Van de ven wrote:

(Untested) Try:

    callback  = CustomJS(args=dict(glyph=cir.glpyh), code="""
            glyph.radius = { value: 10 }
    """)

Also note, only model objects can go in “args”. So, “glyph” is ok, but not “glyph.radius”

Bryan

On Jul 5, 2016, at 3:11 PM, [email protected] wrote:

I have some circle glpyhs and I want the radius to be adjustable with a slider. I have the following example working:


fig = Figure(plot_width=400, plot_height=400)

source = ColumnDataSource(data=dict(
x = np.random.random(size=8),
y = np.random.random(size=8),
r = [.1]*8
)
)

cir = fig.circle(“x”, “y”, radius=“r”, source=source, fill_color=“red”, fill_alpha=.5)

callback = CustomJS(args=dict(source=source), code=“”"
data = source.get(‘data’);
r = data[‘r’];

new_r = cb_obj.get('value');
for (i = 0; i < 8; i++) {
    r[i] = new_r;
}

source.trigger('change');

“”")

slider = Slider(start=.01, end=.2, value=.1, step=0.01, callback=callback)

Notice that I have to have an array of radii. Is there anyway to replicate this behavior with just setting the value the same for all circles without using an array? I am needing to do this for a plot with 150,000 points and it seems the

performance is struggling since I need to set the radius for all 150000 points when I do it this way.

I’ve tried stuff like:

callback = CustomJS(args=dict(radius = cir.glpyh.radius), code=“”"
(some JS code)
“”"

and I get an error saying it was expecting a list of values.

Any other ideas?

Thanks.


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/228f3462-e599-44dc-8773-48efcdd98471%40continuum.io.
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/4cbfd8a9-75af-45a6-87d9-5acecfc05319%40continuum.io.

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

I'd try:

  cir.data_source.trigger('change')

Thanks,

Bryan

···

On Jul 7, 2016, at 10:42 PM, [email protected] wrote:

Awesome! Thanks for always responding so quickly. Do you know of a similar work around when using on_change?

import numpy as np
from bokeh.io import curdoc
from bokeh.plotting import Figure, output_file, show
from bokeh.layouts import column
from bokeh.models import CustomJS, Slider

fig = Figure(plot_width=400, plot_height=400)

COUNT = 10
cir = fig.circle(x=np.random.rand(COUNT), y=np.random.rand(COUNT),
                fill_color="red", line_color="black", radius=.05)

def update_size(attrname, old, new):
    cir.glyph.radius = slider.value/100.

slider = Slider(start=1, end=10, step=0.1, value=5)
slider.on_change('value', update_size)

curdoc().add_root(column(fig, slider))

Thanks,

Tanner

On Thursday, July 7, 2016 at 9:26:07 PM UTC-6, Bryan Van de ven wrote:
Hi Tanner,

I forgot that currently only setting line and fill properties is really supported in this manner. There is an open issue:

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

However, this will fucntion as a workaround for now:

        callback = CustomJS(args=dict(renderer=cir), code="""
                renderer.glyph.radius = { value: cb_obj.get('value')/100 }
                renderer.data_source.trigger('change')
        """)

Thanks,

Bryan

> On Jul 7, 2016, at 10:09 PM, tannerkch...@gmail.com wrote:
>
> Here is the code I tried:
>
> import numpy as np
> from bokeh.plotting import Figure, output_file, show
> from bokeh.layouts import column
> from bokeh.models import CustomJS, Slider
>
>
> fig = Figure(plot_width=400, plot_height=400)
>
> COUNT = 10
> cir = fig.circle(x=np.random.rand(COUNT), y=np.random.rand(COUNT),
> fill_color="red", line_color="black", radius=.05)
>
> callback = CustomJS(args=dict(glyph=cir.glyph), code="""
> glyph.radius = { value: cb_obj.get('value')/100 }
>
> console.log(glyph.radius)
> """)
>
> slider = Slider(start=1, end=10, step=0.1, value=5, callback=callback)
>
> output_file("temp.html")
>
> show(column(fig, slider))
>
> I went to the console and confirmed that the value of the radius was getting changed, but the changes aren't being reflected in the glyph. I know when you're dealing with a ColumnDataSource, you call source.trigger("change") to trigger it to update. I tried adding glyph.trigger("change"), but that didn't help. Is there something similar that is necessary? Is this a bug?
>
> Thanks,
>
> Tanner
>
>
>
> On Tuesday, July 5, 2016 at 10:33:03 PM UTC-6, Bryan Van de ven wrote:
> (Untested) Try:
>
> callback = CustomJS(args=dict(glyph=cir.glpyh), code="""
> glyph.radius = { value: 10 }
> """)
>
> Also note, only model objects can go in "args". So, "glyph" is ok, but not "glyph.radius"
>
> Bryan
>
>
> > On Jul 5, 2016, at 3:11 PM, tannerkch...@gmail.com wrote:
> >
> > I have some circle glpyhs and I want the radius to be adjustable with a slider. I have the following example working:
> >
> > --------------------------------------------------------------------------
> > fig = Figure(plot_width=400, plot_height=400)
> >
> > source = ColumnDataSource(data=dict(
> > x = np.random.random(size=8),
> > y = np.random.random(size=8),
> > r = [.1]*8
> > )
> > )
> >
> > cir = fig.circle("x", "y", radius="r", source=source, fill_color="red", fill_alpha=.5)
> >
> > callback = CustomJS(args=dict(source=source), code="""
> > data = source.get('data');
> > r = data['r'];
> >
> > new_r = cb_obj.get('value');
> > for (i = 0; i < 8; i++) {
> > r[i] = new_r;
> > }
> >
> > source.trigger('change');
> > """)
> >
> > slider = Slider(start=.01, end=.2, value=.1, step=0.01, callback=callback)
> > ------------------------------------------------------------
> >
> > Notice that I have to have an array of radii. Is there anyway to replicate this behavior with just setting the value the same for all circles without using an array? I am needing to do this for a plot with 150,000 points and it seems the
> > performance is struggling since I need to set the radius for all 150000 points when I do it this way.
> >
> > I've tried stuff like:
> > ------------------------------------------------------------
> > callback = CustomJS(args=dict(radius = cir.glpyh.radius), code="""
> > (some JS code)
> > """
> > -----------------------------------------------------------
> > and I get an error saying it was expecting a list of values.
> >
> > Any other ideas?
> >
> > Thanks.
> >
> > --
> > 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 bokeh+un...@continuum.io.
> > To post to this group, send email to bo...@continuum.io.
> > To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/228f3462-e599-44dc-8773-48efcdd98471%40continuum.io\.
> > 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 bokeh+un...@continuum.io.
> To post to this group, send email to bo...@continuum.io.
> To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/4cbfd8a9-75af-45a6-87d9-5acecfc05319%40continuum.io\.
> 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/747d6d15-322d-4955-bb6d-c345a2c9387d%40continuum.io\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.

I tried your suggestion and got:
TypeError(‘trigger() takes at least 4 arguments (2 given)’

``

I then tried (after reading the doc string for ‘trigger’):
cir.data_source.trigger(“change”, old, new)

``

and got:

AttributeError("type object ‘ColumnDataSource’ has no attribute ‘change’

``

···

On Thursday, July 7, 2016 at 10:53:06 PM UTC-6, Bryan Van de ven wrote:

I’d try:

    cir.data_source.trigger('change')

Thanks,

Bryan

On Jul 7, 2016, at 10:42 PM, [email protected] wrote:

Awesome! Thanks for always responding so quickly. Do you know of a similar work around when using on_change?

import numpy as np

from bokeh.io import curdoc

from bokeh.plotting import Figure, output_file, show

from bokeh.layouts import column

from bokeh.models import CustomJS, Slider

fig = Figure(plot_width=400, plot_height=400)

COUNT = 10

cir = fig.circle(x=np.random.rand(COUNT), y=np.random.rand(COUNT),

            fill_color="red", line_color="black", radius=.05)

def update_size(attrname, old, new):

cir.glyph.radius = slider.value/100.

slider = Slider(start=1, end=10, step=0.1, value=5)

slider.on_change(‘value’, update_size)

curdoc().add_root(column(fig, slider))

Thanks,

Tanner

On Thursday, July 7, 2016 at 9:26:07 PM UTC-6, Bryan Van de ven wrote:

Hi Tanner,

I forgot that currently only setting line and fill properties is really supported in this manner. There is an open issue:

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

However, this will fucntion as a workaround for now:

    callback = CustomJS(args=dict(renderer=cir), code="""
            renderer.glyph.radius = { value: cb_obj.get('value')/100 }
            renderer.data_source.trigger('change')
    """)

Thanks,

Bryan

On Jul 7, 2016, at 10:09 PM, [email protected] wrote:

Here is the code I tried:

import numpy as np
from bokeh.plotting import Figure, output_file, show
from bokeh.layouts import column
from bokeh.models import CustomJS, Slider

fig = Figure(plot_width=400, plot_height=400)

COUNT = 10
cir = fig.circle(x=np.random.rand(COUNT), y=np.random.rand(COUNT),
fill_color=“red”, line_color=“black”, radius=.05)

callback = CustomJS(args=dict(glyph=cir.glyph), code=“”"
glyph.radius = { value: cb_obj.get(‘value’)/100 }

console.log(glyph.radius)

“”")

slider = Slider(start=1, end=10, step=0.1, value=5, callback=callback)

output_file(“temp.html”)

show(column(fig, slider))

I went to the console and confirmed that the value of the radius was getting changed, but the changes aren’t being reflected in the glyph. I know when you’re dealing with a ColumnDataSource, you call source.trigger(“change”) to trigger it to update. I tried adding glyph.trigger(“change”), but that didn’t help. Is there something similar that is necessary? Is this a bug?

Thanks,

Tanner

On Tuesday, July 5, 2016 at 10:33:03 PM UTC-6, Bryan Van de ven wrote:
(Untested) Try:

    callback  = CustomJS(args=dict(glyph=cir.glpyh), code="""
            glyph.radius = { value: 10 }
    """)

Also note, only model objects can go in “args”. So, “glyph” is ok, but not “glyph.radius”

Bryan

On Jul 5, 2016, at 3:11 PM, [email protected] wrote:

I have some circle glpyhs and I want the radius to be adjustable with a slider. I have the following example working:


fig = Figure(plot_width=400, plot_height=400)

source = ColumnDataSource(data=dict(
x = np.random.random(size=8),
y = np.random.random(size=8),
r = [.1]*8
)
)

cir = fig.circle(“x”, “y”, radius=“r”, source=source, fill_color=“red”, fill_alpha=.5)

callback = CustomJS(args=dict(source=source), code=“”"
data = source.get(‘data’);
r = data[‘r’];

new_r = cb_obj.get('value');
for (i = 0; i < 8; i++) {
    r[i] = new_r;
}

source.trigger('change');

“”")

slider = Slider(start=.01, end=.2, value=.1, step=0.01, callback=callback)

Notice that I have to have an array of radii. Is there anyway to replicate this behavior with just setting the value the same for all circles without using an array? I am needing to do this for a plot with 150,000 points and it seems the
performance is struggling since I need to set the radius for all 150000 points when I do it this way.

I’ve tried stuff like:

callback = CustomJS(args=dict(radius = cir.glpyh.radius), code=“”"
(some JS code)
“”"

and I get an error saying it was expecting a list of values.

Any other ideas?

Thanks.


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/228f3462-e599-44dc-8773-48efcdd98471%40continuum.io.
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/4cbfd8a9-75af-45a6-87d9-5acecfc05319%40continuum.io.
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/747d6d15-322d-4955-bb6d-c345a2c9387d%40continuum.io.

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

Ah, hrm. This might work but I'm not sure it's great. If "ds" is the data source:

  ds.trigger('data', ds.data, ds.data)

Bryan

···

On Jul 7, 2016, at 11:58 PM, [email protected] wrote:

I tried your suggestion and got:
TypeError('trigger() takes at least 4 arguments (2 given)'

I then tried (after reading the doc string for 'trigger'):
cir.data_source.trigger("change", old, new)
and got:
AttributeError("type object 'ColumnDataSource' has no attribute 'change'

On Thursday, July 7, 2016 at 10:53:06 PM UTC-6, Bryan Van de ven wrote:
I'd try:

        cir.data_source.trigger('change')

Thanks,

Bryan

> On Jul 7, 2016, at 10:42 PM, tannerkch...@gmail.com wrote:
>
> Awesome! Thanks for always responding so quickly. Do you know of a similar work around when using on_change?
>
> import numpy as np
> from bokeh.io import curdoc
> from bokeh.plotting import Figure, output_file, show
> from bokeh.layouts import column
> from bokeh.models import CustomJS, Slider
>
> fig = Figure(plot_width=400, plot_height=400)
>
> COUNT = 10
> cir = fig.circle(x=np.random.rand(COUNT), y=np.random.rand(COUNT),
> fill_color="red", line_color="black", radius=.05)
>
> def update_size(attrname, old, new):
> cir.glyph.radius = slider.value/100.
>
> slider = Slider(start=1, end=10, step=0.1, value=5)
> slider.on_change('value', update_size)
>
> curdoc().add_root(column(fig, slider))
>
> Thanks,
>
> Tanner
>
> On Thursday, July 7, 2016 at 9:26:07 PM UTC-6, Bryan Van de ven wrote:
> Hi Tanner,
>
> I forgot that currently only setting line and fill properties is really supported in this manner. There is an open issue:
>
> https://github.com/bokeh/bokeh/issues/2367
>
> However, this will fucntion as a workaround for now:
>
> callback = CustomJS(args=dict(renderer=cir), code="""
> renderer.glyph.radius = { value: cb_obj.get('value')/100 }
> renderer.data_source.trigger('change')
> """)
>
> Thanks,
>
> Bryan
>
> > On Jul 7, 2016, at 10:09 PM, tannerkch...@gmail.com wrote:
> >
> > Here is the code I tried:
> >
> > import numpy as np
> > from bokeh.plotting import Figure, output_file, show
> > from bokeh.layouts import column
> > from bokeh.models import CustomJS, Slider
> >
> >
> > fig = Figure(plot_width=400, plot_height=400)
> >
> > COUNT = 10
> > cir = fig.circle(x=np.random.rand(COUNT), y=np.random.rand(COUNT),
> > fill_color="red", line_color="black", radius=.05)
> >
> > callback = CustomJS(args=dict(glyph=cir.glyph), code="""
> > glyph.radius = { value: cb_obj.get('value')/100 }
> >
> > console.log(glyph.radius)
> > """)
> >
> > slider = Slider(start=1, end=10, step=0.1, value=5, callback=callback)
> >
> > output_file("temp.html")
> >
> > show(column(fig, slider))
> >
> > I went to the console and confirmed that the value of the radius was getting changed, but the changes aren't being reflected in the glyph. I know when you're dealing with a ColumnDataSource, you call source.trigger("change") to trigger it to update. I tried adding glyph.trigger("change"), but that didn't help. Is there something similar that is necessary? Is this a bug?
> >
> > Thanks,
> >
> > Tanner
> >
> >
> >
> > On Tuesday, July 5, 2016 at 10:33:03 PM UTC-6, Bryan Van de ven wrote:
> > (Untested) Try:
> >
> > callback = CustomJS(args=dict(glyph=cir.glpyh), code="""
> > glyph.radius = { value: 10 }
> > """)
> >
> > Also note, only model objects can go in "args". So, "glyph" is ok, but not "glyph.radius"
> >
> > Bryan
> >
> >
> > > On Jul 5, 2016, at 3:11 PM, tannerkch...@gmail.com wrote:
> > >
> > > I have some circle glpyhs and I want the radius to be adjustable with a slider. I have the following example working:
> > >
> > > --------------------------------------------------------------------------
> > > fig = Figure(plot_width=400, plot_height=400)
> > >
> > > source = ColumnDataSource(data=dict(
> > > x = np.random.random(size=8),
> > > y = np.random.random(size=8),
> > > r = [.1]*8
> > > )
> > > )
> > >
> > > cir = fig.circle("x", "y", radius="r", source=source, fill_color="red", fill_alpha=.5)
> > >
> > > callback = CustomJS(args=dict(source=source), code="""
> > > data = source.get('data');
> > > r = data['r'];
> > >
> > > new_r = cb_obj.get('value');
> > > for (i = 0; i < 8; i++) {
> > > r[i] = new_r;
> > > }
> > >
> > > source.trigger('change');
> > > """)
> > >
> > > slider = Slider(start=.01, end=.2, value=.1, step=0.01, callback=callback)
> > > ------------------------------------------------------------
> > >
> > > Notice that I have to have an array of radii. Is there anyway to replicate this behavior with just setting the value the same for all circles without using an array? I am needing to do this for a plot with 150,000 points and it seems the
> > > performance is struggling since I need to set the radius for all 150000 points when I do it this way.
> > >
> > > I've tried stuff like:
> > > ------------------------------------------------------------
> > > callback = CustomJS(args=dict(radius = cir.glpyh.radius), code="""
> > > (some JS code)
> > > """
> > > -----------------------------------------------------------
> > > and I get an error saying it was expecting a list of values.
> > >
> > > Any other ideas?
> > >
> > > Thanks.
> > >
> > > --
> > > 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 bokeh+un...@continuum.io.
> > > To post to this group, send email to bo...@continuum.io.
> > > To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/228f3462-e599-44dc-8773-48efcdd98471%40continuum.io\.
> > > 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 bokeh+un...@continuum.io.
> > To post to this group, send email to bo...@continuum.io.
> > To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/4cbfd8a9-75af-45a6-87d9-5acecfc05319%40continuum.io\.
> > 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 bokeh+un...@continuum.io.
> To post to this group, send email to bo...@continuum.io.
> To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/747d6d15-322d-4955-bb6d-c345a2c9387d%40continuum.io\.
> 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/a0b51faf-28de-423c-b197-275e346f9240%40continuum.io\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.

That didn’t work. I printed out cir.data_source.data and found that radius is not stored there. Just x and y.

···

On Thursday, July 7, 2016 at 11:01:41 PM UTC-6, Bryan Van de ven wrote:

Ah, hrm. This might work but I’m not sure it’s great. If “ds” is the data source:

    ds.trigger('data', ds.data, ds.data)

Bryan

On Jul 7, 2016, at 11:58 PM, [email protected] wrote:

I tried your suggestion and got:

TypeError(‘trigger() takes at least 4 arguments (2 given)’

I then tried (after reading the doc string for ‘trigger’):

cir.data_source.trigger(“change”, old, new)

and got:

AttributeError("type object ‘ColumnDataSource’ has no attribute ‘change’

On Thursday, July 7, 2016 at 10:53:06 PM UTC-6, Bryan Van de ven wrote:

I’d try:

    cir.data_source.trigger('change')

Thanks,

Bryan

On Jul 7, 2016, at 10:42 PM, [email protected] wrote:

Awesome! Thanks for always responding so quickly. Do you know of a similar work around when using on_change?

import numpy as np
from bokeh.io import curdoc
from bokeh.plotting import Figure, output_file, show
from bokeh.layouts import column
from bokeh.models import CustomJS, Slider

fig = Figure(plot_width=400, plot_height=400)

COUNT = 10
cir = fig.circle(x=np.random.rand(COUNT), y=np.random.rand(COUNT),
fill_color=“red”, line_color=“black”, radius=.05)

def update_size(attrname, old, new):
cir.glyph.radius = slider.value/100.

slider = Slider(start=1, end=10, step=0.1, value=5)
slider.on_change(‘value’, update_size)

curdoc().add_root(column(fig, slider))

Thanks,

Tanner

On Thursday, July 7, 2016 at 9:26:07 PM UTC-6, Bryan Van de ven wrote:
Hi Tanner,

I forgot that currently only setting line and fill properties is really supported in this manner. There is an open issue:

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

However, this will fucntion as a workaround for now:

    callback = CustomJS(args=dict(renderer=cir), code="""
            renderer.glyph.radius = { value: cb_obj.get('value')/100 }
            renderer.data_source.trigger('change')
    """)

Thanks,

Bryan

On Jul 7, 2016, at 10:09 PM, [email protected] wrote:

Here is the code I tried:

import numpy as np
from bokeh.plotting import Figure, output_file, show
from bokeh.layouts import column
from bokeh.models import CustomJS, Slider

fig = Figure(plot_width=400, plot_height=400)

COUNT = 10
cir = fig.circle(x=np.random.rand(COUNT), y=np.random.rand(COUNT),
fill_color=“red”, line_color=“black”, radius=.05)

callback = CustomJS(args=dict(glyph=cir.glyph), code=“”"
glyph.radius = { value: cb_obj.get(‘value’)/100 }

console.log(glyph.radius)

“”")

slider = Slider(start=1, end=10, step=0.1, value=5, callback=callback)

output_file(“temp.html”)

show(column(fig, slider))

I went to the console and confirmed that the value of the radius was getting changed, but the changes aren’t being reflected in the glyph. I know when you’re dealing with a ColumnDataSource, you call source.trigger(“change”) to trigger it to update. I tried adding glyph.trigger(“change”), but that didn’t help. Is there something similar that is necessary? Is this a bug?

Thanks,

Tanner

On Tuesday, July 5, 2016 at 10:33:03 PM UTC-6, Bryan Van de ven wrote:
(Untested) Try:

    callback  = CustomJS(args=dict(glyph=cir.glpyh), code="""
            glyph.radius = { value: 10 }
    """)

Also note, only model objects can go in “args”. So, “glyph” is ok, but not “glyph.radius”

Bryan

On Jul 5, 2016, at 3:11 PM, [email protected] wrote:

I have some circle glpyhs and I want the radius to be adjustable with a slider. I have the following example working:


fig = Figure(plot_width=400, plot_height=400)

source = ColumnDataSource(data=dict(
x = np.random.random(size=8),
y = np.random.random(size=8),
r = [.1]*8
)
)

cir = fig.circle(“x”, “y”, radius=“r”, source=source, fill_color=“red”, fill_alpha=.5)

callback = CustomJS(args=dict(source=source), code=“”"
data = source.get(‘data’);
r = data[‘r’];

new_r = cb_obj.get('value');
for (i = 0; i < 8; i++) {
    r[i] = new_r;
}

source.trigger('change');

“”")

slider = Slider(start=.01, end=.2, value=.1, step=0.01, callback=callback)

Notice that I have to have an array of radii. Is there anyway to replicate this behavior with just setting the value the same for all circles without using an array? I am needing to do this for a plot with 150,000 points and it seems the
performance is struggling since I need to set the radius for all 150000 points when I do it this way.

I’ve tried stuff like:

callback = CustomJS(args=dict(radius = cir.glpyh.radius), code=“”"
(some JS code)
“”"

and I get an error saying it was expecting a list of values.

Any other ideas?

Thanks.


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/228f3462-e599-44dc-8773-48efcdd98471%40continuum.io.
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/4cbfd8a9-75af-45a6-87d9-5acecfc05319%40continuum.io.
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/747d6d15-322d-4955-bb6d-c345a2c9387d%40continuum.io.
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/a0b51faf-28de-423c-b197-275e346f9240%40continuum.io.

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

Right, I didn't mention details, but as I said this is a workaround. It's meant as a roundabout way to trigger some code that will pick up the radius change. To be clear, this suggestion was in *addition* to the

  cir.glyph.radius = slider.value/100.

line, not instead of, in case that was confusing.

Bryan

···

On Jul 8, 2016, at 12:14 AM, [email protected] wrote:

That didn't work. I printed out `cir.data_source.data` and found that `radius` is not stored there. Just `x` and `y`.

On Thursday, July 7, 2016 at 11:01:41 PM UTC-6, Bryan Van de ven wrote:
Ah, hrm. This might work but I'm not sure it's great. If "ds" is the data source:

        ds.trigger('data', ds.data, ds.data)

Bryan

> On Jul 7, 2016, at 11:58 PM, tannerkch...@gmail.com wrote:
>
> I tried your suggestion and got:
> TypeError('trigger() takes at least 4 arguments (2 given)'
>
> I then tried (after reading the doc string for 'trigger'):
> cir.data_source.trigger("change", old, new)
> and got:
> AttributeError("type object 'ColumnDataSource' has no attribute 'change'
>
>
>
> On Thursday, July 7, 2016 at 10:53:06 PM UTC-6, Bryan Van de ven wrote:
> I'd try:
>
> cir.data_source.trigger('change')
>
> Thanks,
>
> Bryan
>
> > On Jul 7, 2016, at 10:42 PM, tannerkch...@gmail.com wrote:
> >
> > Awesome! Thanks for always responding so quickly. Do you know of a similar work around when using on_change?
> >
> > import numpy as np
> > from bokeh.io import curdoc
> > from bokeh.plotting import Figure, output_file, show
> > from bokeh.layouts import column
> > from bokeh.models import CustomJS, Slider
> >
> > fig = Figure(plot_width=400, plot_height=400)
> >
> > COUNT = 10
> > cir = fig.circle(x=np.random.rand(COUNT), y=np.random.rand(COUNT),
> > fill_color="red", line_color="black", radius=.05)
> >
> > def update_size(attrname, old, new):
> > cir.glyph.radius = slider.value/100.
> >
> > slider = Slider(start=1, end=10, step=0.1, value=5)
> > slider.on_change('value', update_size)
> >
> > curdoc().add_root(column(fig, slider))
> >
> > Thanks,
> >
> > Tanner
> >
> > On Thursday, July 7, 2016 at 9:26:07 PM UTC-6, Bryan Van de ven wrote:
> > Hi Tanner,
> >
> > I forgot that currently only setting line and fill properties is really supported in this manner. There is an open issue:
> >
> > https://github.com/bokeh/bokeh/issues/2367
> >
> > However, this will fucntion as a workaround for now:
> >
> > callback = CustomJS(args=dict(renderer=cir), code="""
> > renderer.glyph.radius = { value: cb_obj.get('value')/100 }
> > renderer.data_source.trigger('change')
> > """)
> >
> > Thanks,
> >
> > Bryan
> >
> > > On Jul 7, 2016, at 10:09 PM, tannerkch...@gmail.com wrote:
> > >
> > > Here is the code I tried:
> > >
> > > import numpy as np
> > > from bokeh.plotting import Figure, output_file, show
> > > from bokeh.layouts import column
> > > from bokeh.models import CustomJS, Slider
> > >
> > >
> > > fig = Figure(plot_width=400, plot_height=400)
> > >
> > > COUNT = 10
> > > cir = fig.circle(x=np.random.rand(COUNT), y=np.random.rand(COUNT),
> > > fill_color="red", line_color="black", radius=.05)
> > >
> > > callback = CustomJS(args=dict(glyph=cir.glyph), code="""
> > > glyph.radius = { value: cb_obj.get('value')/100 }
> > >
> > > console.log(glyph.radius)
> > > """)
> > >
> > > slider = Slider(start=1, end=10, step=0.1, value=5, callback=callback)
> > >
> > > output_file("temp.html")
> > >
> > > show(column(fig, slider))
> > >
> > > I went to the console and confirmed that the value of the radius was getting changed, but the changes aren't being reflected in the glyph. I know when you're dealing with a ColumnDataSource, you call source.trigger("change") to trigger it to update. I tried adding glyph.trigger("change"), but that didn't help. Is there something similar that is necessary? Is this a bug?
> > >
> > > Thanks,
> > >
> > > Tanner
> > >
> > >
> > >
> > > On Tuesday, July 5, 2016 at 10:33:03 PM UTC-6, Bryan Van de ven wrote:
> > > (Untested) Try:
> > >
> > > callback = CustomJS(args=dict(glyph=cir.glpyh), code="""
> > > glyph.radius = { value: 10 }
> > > """)
> > >
> > > Also note, only model objects can go in "args". So, "glyph" is ok, but not "glyph.radius"
> > >
> > > Bryan
> > >
> > >
> > > > On Jul 5, 2016, at 3:11 PM, tannerkch...@gmail.com wrote:
> > > >
> > > > I have some circle glpyhs and I want the radius to be adjustable with a slider. I have the following example working:
> > > >
> > > > --------------------------------------------------------------------------
> > > > fig = Figure(plot_width=400, plot_height=400)
> > > >
> > > > source = ColumnDataSource(data=dict(
> > > > x = np.random.random(size=8),
> > > > y = np.random.random(size=8),
> > > > r = [.1]*8
> > > > )
> > > > )
> > > >
> > > > cir = fig.circle("x", "y", radius="r", source=source, fill_color="red", fill_alpha=.5)
> > > >
> > > > callback = CustomJS(args=dict(source=source), code="""
> > > > data = source.get('data');
> > > > r = data['r'];
> > > >
> > > > new_r = cb_obj.get('value');
> > > > for (i = 0; i < 8; i++) {
> > > > r[i] = new_r;
> > > > }
> > > >
> > > > source.trigger('change');
> > > > """)
> > > >
> > > > slider = Slider(start=.01, end=.2, value=.1, step=0.01, callback=callback)
> > > > ------------------------------------------------------------
> > > >
> > > > Notice that I have to have an array of radii. Is there anyway to replicate this behavior with just setting the value the same for all circles without using an array? I am needing to do this for a plot with 150,000 points and it seems the
> > > > performance is struggling since I need to set the radius for all 150000 points when I do it this way.
> > > >
> > > > I've tried stuff like:
> > > > ------------------------------------------------------------
> > > > callback = CustomJS(args=dict(radius = cir.glpyh.radius), code="""
> > > > (some JS code)
> > > > """
> > > > -----------------------------------------------------------
> > > > and I get an error saying it was expecting a list of values.
> > > >
> > > > Any other ideas?
> > > >
> > > > Thanks.
> > > >
> > > > --
> > > > 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 bokeh+un...@continuum.io.
> > > > To post to this group, send email to bo...@continuum.io.
> > > > To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/228f3462-e599-44dc-8773-48efcdd98471%40continuum.io\.
> > > > 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 bokeh+un...@continuum.io.
> > > To post to this group, send email to bo...@continuum.io.
> > > To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/4cbfd8a9-75af-45a6-87d9-5acecfc05319%40continuum.io\.
> > > 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 bokeh+un...@continuum.io.
> > To post to this group, send email to bo...@continuum.io.
> > To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/747d6d15-322d-4955-bb6d-c345a2c9387d%40continuum.io\.
> > 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 bokeh+un...@continuum.io.
> To post to this group, send email to bo...@continuum.io.
> To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/a0b51faf-28de-423c-b197-275e346f9240%40continuum.io\.
> 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/a866e5ff-2706-4871-a9eb-124605b82e68%40continuum.io\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.

Ya, I think I understood what you meant. Here’s my update_size function:

def update_size(attrname, old, new):
cir.glyph.radius = slider.value/100.
cir.data_source.trigger(“data”, cir.data_source.data, cir.data_source.data)

``

···

On Thursday, July 7, 2016 at 11:18:00 PM UTC-6, Bryan Van de ven wrote:

Right, I didn’t mention details, but as I said this is a workaround. It’s meant as a roundabout way to trigger some code that will pick up the radius change. To be clear, this suggestion was in addition to the

    cir.glyph.radius = slider.value/100.

line, not instead of, in case that was confusing.

Bryan

On Jul 8, 2016, at 12:14 AM, [email protected] wrote:

That didn’t work. I printed out cir.data_source.data and found that radius is not stored there. Just x and y.

On Thursday, July 7, 2016 at 11:01:41 PM UTC-6, Bryan Van de ven wrote:

Ah, hrm. This might work but I’m not sure it’s great. If “ds” is the data source:

    ds.trigger('data', ds.data, ds.data)

Bryan

On Jul 7, 2016, at 11:58 PM, [email protected] wrote:

I tried your suggestion and got:
TypeError(‘trigger() takes at least 4 arguments (2 given)’

I then tried (after reading the doc string for ‘trigger’):
cir.data_source.trigger(“change”, old, new)
and got:
AttributeError("type object ‘ColumnDataSource’ has no attribute ‘change’

On Thursday, July 7, 2016 at 10:53:06 PM UTC-6, Bryan Van de ven wrote:
I’d try:

    cir.data_source.trigger('change')

Thanks,

Bryan

On Jul 7, 2016, at 10:42 PM, [email protected] wrote:

Awesome! Thanks for always responding so quickly. Do you know of a similar work around when using on_change?

import numpy as np
from bokeh.io import curdoc
from bokeh.plotting import Figure, output_file, show
from bokeh.layouts import column
from bokeh.models import CustomJS, Slider

fig = Figure(plot_width=400, plot_height=400)

COUNT = 10
cir = fig.circle(x=np.random.rand(COUNT), y=np.random.rand(COUNT),
fill_color=“red”, line_color=“black”, radius=.05)

def update_size(attrname, old, new):
cir.glyph.radius = slider.value/100.

slider = Slider(start=1, end=10, step=0.1, value=5)
slider.on_change(‘value’, update_size)

curdoc().add_root(column(fig, slider))

Thanks,

Tanner

On Thursday, July 7, 2016 at 9:26:07 PM UTC-6, Bryan Van de ven wrote:
Hi Tanner,

I forgot that currently only setting line and fill properties is really supported in this manner. There is an open issue:

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

However, this will fucntion as a workaround for now:

    callback = CustomJS(args=dict(renderer=cir), code="""
            renderer.glyph.radius = { value: cb_obj.get('value')/100 }
            renderer.data_source.trigger('change')
    """)

Thanks,

Bryan

On Jul 7, 2016, at 10:09 PM, [email protected] wrote:

Here is the code I tried:

import numpy as np
from bokeh.plotting import Figure, output_file, show
from bokeh.layouts import column
from bokeh.models import CustomJS, Slider

fig = Figure(plot_width=400, plot_height=400)

COUNT = 10
cir = fig.circle(x=np.random.rand(COUNT), y=np.random.rand(COUNT),
fill_color=“red”, line_color=“black”, radius=.05)

callback = CustomJS(args=dict(glyph=cir.glyph), code=“”"
glyph.radius = { value: cb_obj.get(‘value’)/100 }

console.log(glyph.radius)

“”")

slider = Slider(start=1, end=10, step=0.1, value=5, callback=callback)

output_file(“temp.html”)

show(column(fig, slider))

I went to the console and confirmed that the value of the radius was getting changed, but the changes aren’t being reflected in the glyph. I know when you’re dealing with a ColumnDataSource, you call source.trigger(“change”) to trigger it to update. I tried adding glyph.trigger(“change”), but that didn’t help. Is there something similar that is necessary? Is this a bug?

Thanks,

Tanner

On Tuesday, July 5, 2016 at 10:33:03 PM UTC-6, Bryan Van de ven wrote:
(Untested) Try:

    callback  = CustomJS(args=dict(glyph=cir.glpyh), code="""
            glyph.radius = { value: 10 }
    """)

Also note, only model objects can go in “args”. So, “glyph” is ok, but not “glyph.radius”

Bryan

On Jul 5, 2016, at 3:11 PM, [email protected] wrote:

I have some circle glpyhs and I want the radius to be adjustable with a slider. I have the following example working:


fig = Figure(plot_width=400, plot_height=400)

source = ColumnDataSource(data=dict(
x = np.random.random(size=8),
y = np.random.random(size=8),
r = [.1]*8
)
)

cir = fig.circle(“x”, “y”, radius=“r”, source=source, fill_color=“red”, fill_alpha=.5)

callback = CustomJS(args=dict(source=source), code=“”"
data = source.get(‘data’);
r = data[‘r’];

new_r = cb_obj.get('value');
for (i = 0; i < 8; i++) {
    r[i] = new_r;
}

source.trigger('change');

“”")

slider = Slider(start=.01, end=.2, value=.1, step=0.01, callback=callback)

Notice that I have to have an array of radii. Is there anyway to replicate this behavior with just setting the value the same for all circles without using an array? I am needing to do this for a plot with 150,000 points and it seems the
performance is struggling since I need to set the radius for all 150000 points when I do it this way.

I’ve tried stuff like:

callback = CustomJS(args=dict(radius = cir.glpyh.radius), code=“”"
(some JS code)
“”"

and I get an error saying it was expecting a list of values.

Any other ideas?

Thanks.


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/228f3462-e599-44dc-8773-48efcdd98471%40continuum.io.
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/4cbfd8a9-75af-45a6-87d9-5acecfc05319%40continuum.io.
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/747d6d15-322d-4955-bb6d-c345a2c9387d%40continuum.io.
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/a0b51faf-28de-423c-b197-275e346f9240%40continuum.io.
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/a866e5ff-2706-4871-a9eb-124605b82e68%40continuum.io.

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

If that's not working then there may not be a way currently, apart from putting radius values in a column in a column data source.

Bryan

···

On Jul 8, 2016, at 12:24 AM, [email protected] wrote:

Ya, I think I understood what you meant. Here's my update_size function:

def update_size(attrname, old, new):
    cir.glyph.radius = slider.value/100.
    cir.data_source.trigger("data", cir.data_source.data, cir.data_source.data)

On Thursday, July 7, 2016 at 11:18:00 PM UTC-6, Bryan Van de ven wrote:
Right, I didn't mention details, but as I said this is a workaround. It's meant as a roundabout way to trigger some code that will pick up the radius change. To be clear, this suggestion was in *addition* to the

        cir.glyph.radius = slider.value/100.

line, not instead of, in case that was confusing.

Bryan

> On Jul 8, 2016, at 12:14 AM, tannerkch...@gmail.com wrote:
>
> That didn't work. I printed out `cir.data_source.data` and found that `radius` is not stored there. Just `x` and `y`.
>
> On Thursday, July 7, 2016 at 11:01:41 PM UTC-6, Bryan Van de ven wrote:
> Ah, hrm. This might work but I'm not sure it's great. If "ds" is the data source:
>
> ds.trigger('data', ds.data, ds.data)
>
> Bryan
>
> > On Jul 7, 2016, at 11:58 PM, tannerkch...@gmail.com wrote:
> >
> > I tried your suggestion and got:
> > TypeError('trigger() takes at least 4 arguments (2 given)'
> >
> > I then tried (after reading the doc string for 'trigger'):
> > cir.data_source.trigger("change", old, new)
> > and got:
> > AttributeError("type object 'ColumnDataSource' has no attribute 'change'
> >
> >
> >
> > On Thursday, July 7, 2016 at 10:53:06 PM UTC-6, Bryan Van de ven wrote:
> > I'd try:
> >
> > cir.data_source.trigger('change')
> >
> > Thanks,
> >
> > Bryan
> >
> > > On Jul 7, 2016, at 10:42 PM, tannerkch...@gmail.com wrote:
> > >
> > > Awesome! Thanks for always responding so quickly. Do you know of a similar work around when using on_change?
> > >
> > > import numpy as np
> > > from bokeh.io import curdoc
> > > from bokeh.plotting import Figure, output_file, show
> > > from bokeh.layouts import column
> > > from bokeh.models import CustomJS, Slider
> > >
> > > fig = Figure(plot_width=400, plot_height=400)
> > >
> > > COUNT = 10
> > > cir = fig.circle(x=np.random.rand(COUNT), y=np.random.rand(COUNT),
> > > fill_color="red", line_color="black", radius=.05)
> > >
> > > def update_size(attrname, old, new):
> > > cir.glyph.radius = slider.value/100.
> > >
> > > slider = Slider(start=1, end=10, step=0.1, value=5)
> > > slider.on_change('value', update_size)
> > >
> > > curdoc().add_root(column(fig, slider))
> > >
> > > Thanks,
> > >
> > > Tanner
> > >
> > > On Thursday, July 7, 2016 at 9:26:07 PM UTC-6, Bryan Van de ven wrote:
> > > Hi Tanner,
> > >
> > > I forgot that currently only setting line and fill properties is really supported in this manner. There is an open issue:
> > >
> > > https://github.com/bokeh/bokeh/issues/2367
> > >
> > > However, this will fucntion as a workaround for now:
> > >
> > > callback = CustomJS(args=dict(renderer=cir), code="""
> > > renderer.glyph.radius = { value: cb_obj.get('value')/100 }
> > > renderer.data_source.trigger('change')
> > > """)
> > >
> > > Thanks,
> > >
> > > Bryan
> > >
> > > > On Jul 7, 2016, at 10:09 PM, tannerkch...@gmail.com wrote:
> > > >
> > > > Here is the code I tried:
> > > >
> > > > import numpy as np
> > > > from bokeh.plotting import Figure, output_file, show
> > > > from bokeh.layouts import column
> > > > from bokeh.models import CustomJS, Slider
> > > >
> > > >
> > > > fig = Figure(plot_width=400, plot_height=400)
> > > >
> > > > COUNT = 10
> > > > cir = fig.circle(x=np.random.rand(COUNT), y=np.random.rand(COUNT),
> > > > fill_color="red", line_color="black", radius=.05)
> > > >
> > > > callback = CustomJS(args=dict(glyph=cir.glyph), code="""
> > > > glyph.radius = { value: cb_obj.get('value')/100 }
> > > >
> > > > console.log(glyph.radius)
> > > > """)
> > > >
> > > > slider = Slider(start=1, end=10, step=0.1, value=5, callback=callback)
> > > >
> > > > output_file("temp.html")
> > > >
> > > > show(column(fig, slider))
> > > >
> > > > I went to the console and confirmed that the value of the radius was getting changed, but the changes aren't being reflected in the glyph. I know when you're dealing with a ColumnDataSource, you call source.trigger("change") to trigger it to update. I tried adding glyph.trigger("change"), but that didn't help. Is there something similar that is necessary? Is this a bug?
> > > >
> > > > Thanks,
> > > >
> > > > Tanner
> > > >
> > > >
> > > >
> > > > On Tuesday, July 5, 2016 at 10:33:03 PM UTC-6, Bryan Van de ven wrote:
> > > > (Untested) Try:
> > > >
> > > > callback = CustomJS(args=dict(glyph=cir.glpyh), code="""
> > > > glyph.radius = { value: 10 }
> > > > """)
> > > >
> > > > Also note, only model objects can go in "args". So, "glyph" is ok, but not "glyph.radius"
> > > >
> > > > Bryan
> > > >
> > > >
> > > > > On Jul 5, 2016, at 3:11 PM, tannerkch...@gmail.com wrote:
> > > > >
> > > > > I have some circle glpyhs and I want the radius to be adjustable with a slider. I have the following example working:
> > > > >
> > > > > --------------------------------------------------------------------------
> > > > > fig = Figure(plot_width=400, plot_height=400)
> > > > >
> > > > > source = ColumnDataSource(data=dict(
> > > > > x = np.random.random(size=8),
> > > > > y = np.random.random(size=8),
> > > > > r = [.1]*8
> > > > > )
> > > > > )
> > > > >
> > > > > cir = fig.circle("x", "y", radius="r", source=source, fill_color="red", fill_alpha=.5)
> > > > >
> > > > > callback = CustomJS(args=dict(source=source), code="""
> > > > > data = source.get('data');
> > > > > r = data['r'];
> > > > >
> > > > > new_r = cb_obj.get('value');
> > > > > for (i = 0; i < 8; i++) {
> > > > > r[i] = new_r;
> > > > > }
> > > > >
> > > > > source.trigger('change');
> > > > > """)
> > > > >
> > > > > slider = Slider(start=.01, end=.2, value=.1, step=0.01, callback=callback)
> > > > > ------------------------------------------------------------
> > > > >
> > > > > Notice that I have to have an array of radii. Is there anyway to replicate this behavior with just setting the value the same for all circles without using an array? I am needing to do this for a plot with 150,000 points and it seems the
> > > > > performance is struggling since I need to set the radius for all 150000 points when I do it this way.
> > > > >
> > > > > I've tried stuff like:
> > > > > ------------------------------------------------------------
> > > > > callback = CustomJS(args=dict(radius = cir.glpyh.radius), code="""
> > > > > (some JS code)
> > > > > """
> > > > > -----------------------------------------------------------
> > > > > and I get an error saying it was expecting a list of values.
> > > > >
> > > > > Any other ideas?
> > > > >
> > > > > Thanks.
> > > > >
> > > > > --
> > > > > 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 bokeh+un...@continuum.io.
> > > > > To post to this group, send email to bo...@continuum.io.
> > > > > To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/228f3462-e599-44dc-8773-48efcdd98471%40continuum.io\.
> > > > > 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 bokeh+un...@continuum.io.
> > > > To post to this group, send email to bo...@continuum.io.
> > > > To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/4cbfd8a9-75af-45a6-87d9-5acecfc05319%40continuum.io\.
> > > > 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 bokeh+un...@continuum.io.
> > > To post to this group, send email to bo...@continuum.io.
> > > To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/747d6d15-322d-4955-bb6d-c345a2c9387d%40continuum.io\.
> > > 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 bokeh+un...@continuum.io.
> > To post to this group, send email to bo...@continuum.io.
> > To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/a0b51faf-28de-423c-b197-275e346f9240%40continuum.io\.
> > 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 bokeh+un...@continuum.io.
> To post to this group, send email to bo...@continuum.io.
> To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/a866e5ff-2706-4871-a9eb-124605b82e68%40continuum.io\.
> 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/d808814c-7ee9-466e-af43-ac1e67689d5f%40continuum.io\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.

Okay, I can work with that. Thanks for taking the time to help! Would you like me to submit a feature request on GitHub?

···

On Thu, Jul 7, 2016 at 11:27 PM, Bryan Van de Ven [email protected] wrote:

If that’s not working then there may not be a way currently, apart from putting radius values in a column in a column data source.

Bryan

On Jul 8, 2016, at 12:24 AM, [email protected] wrote:

Ya, I think I understood what you meant. Here’s my update_size function:

def update_size(attrname, old, new):

cir.glyph.radius = slider.value/100.
cir.data_source.trigger("data", cir.data_source.data,       cir.data_source.data)

On Thursday, July 7, 2016 at 11:18:00 PM UTC-6, Bryan Van de ven wrote:

Right, I didn’t mention details, but as I said this is a workaround. It’s meant as a roundabout way to trigger some code that will pick up the radius change. To be clear, this suggestion was in addition to the

    cir.glyph.radius = slider.value/100.

line, not instead of, in case that was confusing.

Bryan

On Jul 8, 2016, at 12:14 AM, [email protected] wrote:

That didn’t work. I printed out cir.data_source.data and found that radius is not stored there. Just x and y.

On Thursday, July 7, 2016 at 11:01:41 PM UTC-6, Bryan Van de ven wrote:

Ah, hrm. This might work but I’m not sure it’s great. If “ds” is the data source:

    ds.trigger('data', ds.data, ds.data)

Bryan

On Jul 7, 2016, at 11:58 PM, [email protected] wrote:

I tried your suggestion and got:

TypeError(‘trigger() takes at least 4 arguments (2 given)’

I then tried (after reading the doc string for ‘trigger’):

cir.data_source.trigger(“change”, old, new)

and got:

AttributeError("type object ‘ColumnDataSource’ has no attribute ‘change’

On Thursday, July 7, 2016 at 10:53:06 PM UTC-6, Bryan Van de ven wrote:

I’d try:

    cir.data_source.trigger('change')

Thanks,

Bryan

On Jul 7, 2016, at 10:42 PM, [email protected] wrote:

Awesome! Thanks for always responding so quickly. Do you know of a similar work around when using on_change?

import numpy as np

from bokeh.io import curdoc

from bokeh.plotting import Figure, output_file, show

from bokeh.layouts import column

from bokeh.models import CustomJS, Slider

fig = Figure(plot_width=400, plot_height=400)

COUNT = 10

cir = fig.circle(x=np.random.rand(COUNT), y=np.random.rand(COUNT),

            fill_color="red", line_color="black", radius=.05)

def update_size(attrname, old, new):

cir.glyph.radius = slider.value/100.

slider = Slider(start=1, end=10, step=0.1, value=5)

slider.on_change(‘value’, update_size)

curdoc().add_root(column(fig, slider))

Thanks,

Tanner

On Thursday, July 7, 2016 at 9:26:07 PM UTC-6, Bryan Van de ven wrote:

Hi Tanner,

I forgot that currently only setting line and fill properties is really supported in this manner. There is an open issue:

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

However, this will fucntion as a workaround for now:

    callback = CustomJS(args=dict(renderer=cir), code="""
            renderer.glyph.radius = { value: cb_obj.get('value')/100 }
            renderer.data_source.trigger('change')
    """)

Thanks,

Bryan

On Jul 7, 2016, at 10:09 PM, [email protected] wrote:

Here is the code I tried:

import numpy as np

from bokeh.plotting import Figure, output_file, show

from bokeh.layouts import column

from bokeh.models import CustomJS, Slider

fig = Figure(plot_width=400, plot_height=400)

COUNT = 10

cir = fig.circle(x=np.random.rand(COUNT), y=np.random.rand(COUNT),

            fill_color="red", line_color="black", radius=.05)

callback = CustomJS(args=dict(glyph=cir.glyph), code=“”"

glyph.radius = { value: cb_obj.get('value')/100 }
console.log(glyph.radius)

“”")

slider = Slider(start=1, end=10, step=0.1, value=5, callback=callback)

output_file(“temp.html”)

show(column(fig, slider))

I went to the console and confirmed that the value of the radius was getting changed, but the changes aren’t being reflected in the glyph. I know when you’re dealing with a ColumnDataSource, you call source.trigger(“change”) to trigger it to update. I tried adding glyph.trigger(“change”), but that didn’t help. Is there something similar that is necessary? Is this a bug?

Thanks,

Tanner

On Tuesday, July 5, 2016 at 10:33:03 PM UTC-6, Bryan Van de ven wrote:

(Untested) Try:

    callback  = CustomJS(args=dict(glyph=cir.glpyh), code="""
            glyph.radius = { value: 10 }
    """)

Also note, only model objects can go in “args”. So, “glyph” is ok, but not “glyph.radius”

Bryan

On Jul 5, 2016, at 3:11 PM, [email protected] wrote:

I have some circle glpyhs and I want the radius to be adjustable with a slider. I have the following example working:


fig = Figure(plot_width=400, plot_height=400)

source = ColumnDataSource(data=dict(

    x = np.random.random(size=8),
    y = np.random.random(size=8),
    r = [.1]*8
)

)

cir = fig.circle(“x”, “y”, radius=“r”, source=source, fill_color=“red”, fill_alpha=.5)

callback = CustomJS(args=dict(source=source), code=“”"

data = source.get('data');
r = data['r'];
new_r = cb_obj.get('value');
for (i = 0; i < 8; i++) {
    r[i] = new_r;
}
source.trigger('change');

“”")

slider = Slider(start=.01, end=.2, value=.1, step=0.01, callback=callback)


Notice that I have to have an array of radii. Is there anyway to replicate this behavior with just setting the value the same for all circles without using an array? I am needing to do this for a plot with 150,000 points and it seems the

performance is struggling since I need to set the radius for all 150000 points when I do it this way.

I’ve tried stuff like:


callback = CustomJS(args=dict(radius = cir.glpyh.radius), code=“”"

(some JS code)

“”"


and I get an error saying it was expecting a list of values.

Any other ideas?

Thanks.

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/228f3462-e599-44dc-8773-48efcdd98471%40continuum.io.

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/4cbfd8a9-75af-45a6-87d9-5acecfc05319%40continuum.io.

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/747d6d15-322d-4955-bb6d-c345a2c9387d%40continuum.io.

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/a0b51faf-28de-423c-b197-275e346f9240%40continuum.io.

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/a866e5ff-2706-4871-a9eb-124605b82e68%40continuum.io.

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/d808814c-7ee9-466e-af43-ac1e67689d5f%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/XaTE5CnLlCY/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/2C6E44E5-6451-42EB-A5CD-55B31F1C0C5A%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Thanks, sorry I don't have a better option for now. I think this is covered by the issue I linked earlier.

Thanks,

Bryan

···

On Jul 8, 2016, at 12:28 AM, Tanner Christensen <[email protected]> wrote:

Okay, I can work with that. Thanks for taking the time to help! Would you like me to submit a feature request on GitHub?

On Thu, Jul 7, 2016 at 11:27 PM, Bryan Van de Ven <[email protected]> wrote:
If that's not working then there may not be a way currently, apart from putting radius values in a column in a column data source.

Bryan

> On Jul 8, 2016, at 12:24 AM, [email protected] wrote:
>
> Ya, I think I understood what you meant. Here's my update_size function:
>
> def update_size(attrname, old, new):
> cir.glyph.radius = slider.value/100.
> cir.data_source.trigger("data", cir.data_source.data, cir.data_source.data)
>
>
>
> On Thursday, July 7, 2016 at 11:18:00 PM UTC-6, Bryan Van de ven wrote:
> Right, I didn't mention details, but as I said this is a workaround. It's meant as a roundabout way to trigger some code that will pick up the radius change. To be clear, this suggestion was in *addition* to the
>
> cir.glyph.radius = slider.value/100.
>
> line, not instead of, in case that was confusing.
>
> Bryan
>
>
> > On Jul 8, 2016, at 12:14 AM, tannerkch...@gmail.com wrote:
> >
> > That didn't work. I printed out `cir.data_source.data` and found that `radius` is not stored there. Just `x` and `y`.
> >
> > On Thursday, July 7, 2016 at 11:01:41 PM UTC-6, Bryan Van de ven wrote:
> > Ah, hrm. This might work but I'm not sure it's great. If "ds" is the data source:
> >
> > ds.trigger('data', ds.data, ds.data)
> >
> > Bryan
> >
> > > On Jul 7, 2016, at 11:58 PM, tannerkch...@gmail.com wrote:
> > >
> > > I tried your suggestion and got:
> > > TypeError('trigger() takes at least 4 arguments (2 given)'
> > >
> > > I then tried (after reading the doc string for 'trigger'):
> > > cir.data_source.trigger("change", old, new)
> > > and got:
> > > AttributeError("type object 'ColumnDataSource' has no attribute 'change'
> > >
> > >
> > >
> > > On Thursday, July 7, 2016 at 10:53:06 PM UTC-6, Bryan Van de ven wrote:
> > > I'd try:
> > >
> > > cir.data_source.trigger('change')
> > >
> > > Thanks,
> > >
> > > Bryan
> > >
> > > > On Jul 7, 2016, at 10:42 PM, tannerkch...@gmail.com wrote:
> > > >
> > > > Awesome! Thanks for always responding so quickly. Do you know of a similar work around when using on_change?
> > > >
> > > > import numpy as np
> > > > from bokeh.io import curdoc
> > > > from bokeh.plotting import Figure, output_file, show
> > > > from bokeh.layouts import column
> > > > from bokeh.models import CustomJS, Slider
> > > >
> > > > fig = Figure(plot_width=400, plot_height=400)
> > > >
> > > > COUNT = 10
> > > > cir = fig.circle(x=np.random.rand(COUNT), y=np.random.rand(COUNT),
> > > > fill_color="red", line_color="black", radius=.05)
> > > >
> > > > def update_size(attrname, old, new):
> > > > cir.glyph.radius = slider.value/100.
> > > >
> > > > slider = Slider(start=1, end=10, step=0.1, value=5)
> > > > slider.on_change('value', update_size)
> > > >
> > > > curdoc().add_root(column(fig, slider))
> > > >
> > > > Thanks,
> > > >
> > > > Tanner
> > > >
> > > > On Thursday, July 7, 2016 at 9:26:07 PM UTC-6, Bryan Van de ven wrote:
> > > > Hi Tanner,
> > > >
> > > > I forgot that currently only setting line and fill properties is really supported in this manner. There is an open issue:
> > > >
> > > > https://github.com/bokeh/bokeh/issues/2367
> > > >
> > > > However, this will fucntion as a workaround for now:
> > > >
> > > > callback = CustomJS(args=dict(renderer=cir), code="""
> > > > renderer.glyph.radius = { value: cb_obj.get('value')/100 }
> > > > renderer.data_source.trigger('change')
> > > > """)
> > > >
> > > > Thanks,
> > > >
> > > > Bryan
> > > >
> > > > > On Jul 7, 2016, at 10:09 PM, tannerkch...@gmail.com wrote:
> > > > >
> > > > > Here is the code I tried:
> > > > >
> > > > > import numpy as np
> > > > > from bokeh.plotting import Figure, output_file, show
> > > > > from bokeh.layouts import column
> > > > > from bokeh.models import CustomJS, Slider
> > > > >
> > > > >
> > > > > fig = Figure(plot_width=400, plot_height=400)
> > > > >
> > > > > COUNT = 10
> > > > > cir = fig.circle(x=np.random.rand(COUNT), y=np.random.rand(COUNT),
> > > > > fill_color="red", line_color="black", radius=.05)
> > > > >
> > > > > callback = CustomJS(args=dict(glyph=cir.glyph), code="""
> > > > > glyph.radius = { value: cb_obj.get('value')/100 }
> > > > >
> > > > > console.log(glyph.radius)
> > > > > """)
> > > > >
> > > > > slider = Slider(start=1, end=10, step=0.1, value=5, callback=callback)
> > > > >
> > > > > output_file("temp.html")
> > > > >
> > > > > show(column(fig, slider))
> > > > >
> > > > > I went to the console and confirmed that the value of the radius was getting changed, but the changes aren't being reflected in the glyph. I know when you're dealing with a ColumnDataSource, you call source.trigger("change") to trigger it to update. I tried adding glyph.trigger("change"), but that didn't help. Is there something similar that is necessary? Is this a bug?
> > > > >
> > > > > Thanks,
> > > > >
> > > > > Tanner
> > > > >
> > > > >
> > > > >
> > > > > On Tuesday, July 5, 2016 at 10:33:03 PM UTC-6, Bryan Van de ven wrote:
> > > > > (Untested) Try:
> > > > >
> > > > > callback = CustomJS(args=dict(glyph=cir.glpyh), code="""
> > > > > glyph.radius = { value: 10 }
> > > > > """)
> > > > >
> > > > > Also note, only model objects can go in "args". So, "glyph" is ok, but not "glyph.radius"
> > > > >
> > > > > Bryan
> > > > >
> > > > >
> > > > > > On Jul 5, 2016, at 3:11 PM, tannerkch...@gmail.com wrote:
> > > > > >
> > > > > > I have some circle glpyhs and I want the radius to be adjustable with a slider. I have the following example working:
> > > > > >
> > > > > > --------------------------------------------------------------------------
> > > > > > fig = Figure(plot_width=400, plot_height=400)
> > > > > >
> > > > > > source = ColumnDataSource(data=dict(
> > > > > > x = np.random.random(size=8),
> > > > > > y = np.random.random(size=8),
> > > > > > r = [.1]*8
> > > > > > )
> > > > > > )
> > > > > >
> > > > > > cir = fig.circle("x", "y", radius="r", source=source, fill_color="red", fill_alpha=.5)
> > > > > >
> > > > > > callback = CustomJS(args=dict(source=source), code="""
> > > > > > data = source.get('data');
> > > > > > r = data['r'];
> > > > > >
> > > > > > new_r = cb_obj.get('value');
> > > > > > for (i = 0; i < 8; i++) {
> > > > > > r[i] = new_r;
> > > > > > }
> > > > > >
> > > > > > source.trigger('change');
> > > > > > """)
> > > > > >
> > > > > > slider = Slider(start=.01, end=.2, value=.1, step=0.01, callback=callback)
> > > > > > ------------------------------------------------------------
> > > > > >
> > > > > > Notice that I have to have an array of radii. Is there anyway to replicate this behavior with just setting the value the same for all circles without using an array? I am needing to do this for a plot with 150,000 points and it seems the
> > > > > > performance is struggling since I need to set the radius for all 150000 points when I do it this way.
> > > > > >
> > > > > > I've tried stuff like:
> > > > > > ------------------------------------------------------------
> > > > > > callback = CustomJS(args=dict(radius = cir.glpyh.radius), code="""
> > > > > > (some JS code)
> > > > > > """
> > > > > > -----------------------------------------------------------
> > > > > > and I get an error saying it was expecting a list of values.
> > > > > >
> > > > > > Any other ideas?
> > > > > >
> > > > > > Thanks.
> > > > > >
> > > > > > --
> > > > > > 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 bokeh+un...@continuum.io.
> > > > > > To post to this group, send email to bo...@continuum.io.
> > > > > > To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/228f3462-e599-44dc-8773-48efcdd98471%40continuum.io\.
> > > > > > 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 bokeh+un...@continuum.io.
> > > > > To post to this group, send email to bo...@continuum.io.
> > > > > To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/4cbfd8a9-75af-45a6-87d9-5acecfc05319%40continuum.io\.
> > > > > 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 bokeh+un...@continuum.io.
> > > > To post to this group, send email to bo...@continuum.io.
> > > > To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/747d6d15-322d-4955-bb6d-c345a2c9387d%40continuum.io\.
> > > > 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 bokeh+un...@continuum.io.
> > > To post to this group, send email to bo...@continuum.io.
> > > To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/a0b51faf-28de-423c-b197-275e346f9240%40continuum.io\.
> > > 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 bokeh+un...@continuum.io.
> > To post to this group, send email to bo...@continuum.io.
> > To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/a866e5ff-2706-4871-a9eb-124605b82e68%40continuum.io\.
> > 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/d808814c-7ee9-466e-af43-ac1e67689d5f%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/XaTE5CnLlCY/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/2C6E44E5-6451-42EB-A5CD-55B31F1C0C5A%40continuum.io\.
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/CANsN81bRVYEqBFeDw_VWwnDVxayPuVppY06EGEeCaE_B4%2BPPCA%40mail.gmail.com\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.