On Mar 12, 2018, at 02:25, Albert Chau <albert_chau@alumni.sfu.ca> wrote:
Thanks for the reply Bryan.
GH issue created: Feature Request: support hit-testing for text glyphs · Issue #7618 · bokeh/bokeh · GitHub
With regards to your idea of plotting transparent rectangles with the text. How would I go about determining the bounds of the text glyph and hence the bounds of the rectangle?
I took a quick look through the docs but didn't see anything obvious.
cheers
albert.
On Fri, Mar 9, 2018 at 9:08 AM, Bryan Van de ven <bryan@bokeh.org> wrote:
Hi,
Text glyphs do no currently support hit-testing, so hover or selections (or callbacks based on those) do not work with text yet. Adding this feature would be a nice task for a new contributor. In any case I don't actually see a GH issue for it, so making a feature request on GH would be the first step:
Issues · bokeh/bokeh · GitHub
As an immediate workaround, you could possibly plot transparent (alpha=0) rectangles or other glyphs on top of the text, and use those for hit testing.
Thanks,
Bryan
> On Mar 4, 2018, at 17:53, Albert Chau <albertdude@gmail.com> wrote:
>
> Hi,
>
> Is it possible to have rendered text objects selectable with the tap or box-selection tools?
> In the sample below, rendered circles and quads can be selected but not the text objects.
>
>
>
>
> import bokeh.plotting as BPlotting
> import bokeh.models as BModels
>
>
> def circle_CB(window=None):
> selected_indices = cb_obj.selected['1d'].indices
> console.log("circle_CB: selected_indices", selected_indices)
>
>
> def text_CB(window=None):
> selected_indices = cb_obj.selected['1d'].indices
> console.log("text_CB: selected_indices", selected_indices)
>
>
> def quad_CB(window=None):
> selected_indices = cb_obj.selected['1d'].indices
> console.log("quad_CB: selected_indices", selected_indices)
>
>
> p = BPlotting.figure(tools="tap,box_select")
>
>
> x = range(5)
>
>
> y1 = x
> source1 = BPlotting.ColumnDataSource( data=dict(x=x, y=y1) )
> source1.callback = BModels.CustomJS.from_py_func(circle_CB)
> p.circle('x', 'y', source=source1)
>
>
> y2 = [i+5 for i in x]
> t2 = [str(i) for i in y2]
> source2 = BPlotting.ColumnDataSource( data=dict(x=x, y=y2, text=t2) )
> source2.callback = BModels.CustomJS.from_py_func(text_CB)
> p.text('x', 'y', source=source2, text='text')
>
>
> l = [1,2]
> r = [2,3]
> b = [3,4]
> t = [4,5]
> source3 = BPlotting.ColumnDataSource( data=dict(l=l, r=r, b=b, t=t) )
> source3.callback = BModels.CustomJS.from_py_func(quad_CB)
> p.quad(left='l', right='r', bottom='b', top='t', alpha=0.7, source=source3)
>
>
> BPlotting.output_file('select_text.html')
> BPlotting.save(p)
>
>
>
>
> --
> 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+unsubscribe@continuum.io.
> To post to this group, send email to bokeh@continuum.io.
> To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/304d02ea-424d-4226-ae9a-d72d4b6c46ba%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/g1zm_uBJFKk/unsubscribe\.
To unsubscribe from this group and all its topics, send an email to bokeh+unsubscribe@continuum.io.
To post to this group, send email to bokeh@continuum.io.
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/6EF47310-C4F7-4764-BFAD-7A55D2358A5F%40anaconda.com\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.
--
You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bokeh+unsubscribe@continuum.io.
To post to this group, send email to bokeh@continuum.io.
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/CAFVdAeW-00Rv5CaB%3Di7XHemO5fWEW0FxWB91qoztj8Znj1abpw%40mail.gmail.com\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.