Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nonselection_glyph seems to be drawn after selection_glyph #2116

Closed
birdsarah opened this issue Mar 29, 2015 · 6 comments
Closed

nonselection_glyph seems to be drawn after selection_glyph #2116

birdsarah opened this issue Mar 29, 2015 · 6 comments

Comments

@birdsarah
Copy link
Member

Using patches to draw a map and want to do selection as it works on the map here: http://africawatermap.aptivate.org/

This doesn't seem to be possible as the non-selected glyphs are being drawn over the selected glyph. Couple of screenshots to highlight this.


selected and non-selected elements are full alpha, but selected has thick line
1

non-selected element keeps line alpha but has full alpha set to 0
2

non-selected element has line_alpha of 0 and fill_alpha of 0.2
3

non-selected element has line_alpha of 0 and fill_alpha of 1
4

@bryevdv
Copy link
Member

bryevdv commented Mar 30, 2015

@birdsarah is it possible you are drawing the patches twice somehow? I don't understand this because the main render method splits all the indices into two groups, the selected and non-selected, and calls individual glyph render functions separately for each (disjoint) set of indices here:

https://github.com/bokeh/bokeh/blob/master/bokehjs/src/coffee/renderer/glyph/glyph_renderer.coffee#L117

It's certainly possible there is a real problem in BokehJS I would just be surprised not to see if affect every glyph in the same way.

@birdsarah
Copy link
Member Author

Hi @bryevdv I'm not understanding your question, but you have hit on the problem

My understanding of the code you linked to:

do_render(ctx, selected, @selection_glyph)
do_render(ctx, nonselected, @nonselection_glyph)

is that:

  • It's rendering the non-selected elements second.
  • This means that in the case where they overlap, the non-selected ones are "on top"

Having tried changing that order locally. That is indeed the source of my error:

With the current code:
selected_rendered_before

With the order of do_render switched:
selected_rendered_after

In case it's useful, here's the relevant piece of code:

    borders = Patches(
        xs='xs', ys='ys',
        fill_color='color_for_active_year', fill_alpha=1,
        line_color="#FFFFFF", line_width=1,
    )
    selected_borders = Patches(
        xs='xs', ys='ys',
        fill_color='color_for_active_year', fill_alpha=1,
        line_color=ORANGE, line_width=5,
    )

    plot.add_glyph(source, borders, selection_glyph=selected_borders, nonselection_glyph=borders)

@bryevdv
Copy link
Member

bryevdv commented Mar 30, 2015

Oh, I see. I misunderstood to mean that an entire non selected glyph was obscuring a selected one, not just the borders. That is a simple fix, but it should go in after our big BokehJS build PR which will hopefully be merged tomorrow.

@bryevdv
Copy link
Member

bryevdv commented Apr 14, 2015

This was changed.

@bryevdv bryevdv closed this as completed Apr 14, 2015
@damianavila damianavila added this to the 0.9 milestone Apr 17, 2015
@damianavila
Copy link
Contributor

This was changed.

Can you link where was changed? Thanks.

@bryevdv
Copy link
Member

bryevdv commented Apr 17, 2015

fixed in #2143

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants