Hi,
Sorry for not including that.
I define a function to create a map (it calls a function to setup the plot which is working correctly). Within this function the TapTool is called. Selecting the glyphs works but the the text update does not.
def make_map(source, fill_color_string = “active_color”):
counties = Patches(
xs='xs',
ys='ys',
fill_color=fill_color_string,
line_color=DK_GRAY,
line_width=0.5,
)
selected_counties = Patches(
xs='xs',
ys='ys',
fill_color=fill_color_string,
line_color=BLACK,
line_width=1,
)
non_selected_counties = Patches(
xs='xs',
ys='ys',
fill_color=fill_color_string,
line_color=DK_GRAY,
line_width=0.5,
fill_alpha=0.5,
)
map_box = setup_map_plot()
map_box.add_glyph(source, counties, selection_glyph=selected_counties, nonselection_glyph=non_selected_counties)
map_box.add_tools(TapTool())
return map_box
``
I define the function to create the text
def pop_info_text(source, val1):
xdr = Range1d(0, 251)
ydr = Range1d(0, 151)
pop_info_plot = Plot(
x_range=xdr,
y_range=ydr,
title=“”,
plot_width=250,
plot_height=150,
outline_line_color=None,
toolbar_location=None,
min_border=0,
name = Text(x=0, y=120, text=val1, **FONT_PROPS_LG)
pop_info_plot.add_glyph(source, Text(), selection_glyph=name)
return pop_info_plot
``
I pass the pandas data into a ColumnDataSource
source = ColumnDataSource(data)
I then call the the make_map method and the method that creates the text and everything get assembled into a panel.
pop_plot = make_map(source, “active_color”)
pop_info_plot = pop_info_text(source, “NAME”)
tabs = Tabs(tabs=[
Panel(title="Zones", child=hplot(zone_plot, vplot(zone_info_plot, zone_legend_plot))),
Panel(title="Population", child=hplot(pop_plot, vplot(pop_info_plot, pop_legend_plot))),
])
``
Thank you for the help. I can try and upload the notebook and data source if that would help as well.
-Mark
···
On Thursday, June 18, 2015 at 2:13:03 PM UTC-4, Sarah Bird wrote:
Hi,
You’ve shared the snippet of the code where the text is added, but you haven’t shared the section of the code where the TapTool is added, and where the glyphs you’re clicking on are added.
Can you share these too? Then can help debug.
If everything has the same source
this should work.
Sincerely,
Sarah Bird
On Thu, Jun 18, 2015 at 2:42 PM, [email protected] wrote:
Hi there,
I’m fairly new to coding and Bokeh but love it so far. I’m working with a group to produce visualizations for geodata. Anyway I have been off to a pretty good start but I’ve run into an issue with the TapTool. I followed the structure of the code that Sarah Bird uses in her PyCon talk and there is one section where she creates responsive text. This is something I need to do. I structured the code the same way and it didn’t work. I tried running her notebooks (Building the static visualization) from that talk and it didn’t work in there either.
Basically I define a function to create the text and pass the text a variable that based which glyph is selected. I will include a snippet of the code.
def pop_info_text(source, val1):
xdr = Range1d(0, 251)
ydr = Range1d(0, 151)
pop_info_plot = Plot(
x_range=xdr,
y_range=ydr,
title=“”,
plot_width=250,
plot_height=150,
outline_line_color=None,
toolbar_location=None,
min_border=0,
name = Text(x=0, y=120, text=val1, **FONT_PROPS_LG)
pop_info_plot.add_glyph(source, Text(), selection_glyph=name)
return pop_info_plot
``
This is simplified but I think it shares the point. Basically I want to plot a text object that says the name of the selected glyph, I then call the method.
pop_info_plot = pop_info_text(source, “NAME”)
``
“NAME” corresponds to the column of the data set with the name of the glyph in it.
For some reason nothing happens and I’m really curious about this because it used to work on Sarah Bird’s example but It doesn’t anymore.
I appreciate any help,
-Mark
–
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/769eaa9c-c4c5-4521-bffb-4d65731b7faa%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.