Skip to content

Commit

Permalink
allow auto for non/selection glyphs (#5698)
Browse files Browse the repository at this point in the history
  • Loading branch information
bryevdv committed Jan 11, 2017
1 parent 18b867c commit fbe1fa8
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
12 changes: 9 additions & 3 deletions bokeh/models/renderers.py
Expand Up @@ -10,7 +10,7 @@
from ..model import Model
from ..core.enums import RenderLevel
from ..core.properties import abstract
from ..core.properties import String, Enum, Instance, Float, Bool, Override
from ..core.properties import Auto, Bool, Either, Enum, Float, Instance, Override, String
from ..core import validation
from ..core.validation.errors import BAD_COLUMN_NAME, MISSING_GLYPH, NO_SOURCE_FOR_GLYPH

Expand Down Expand Up @@ -131,14 +131,20 @@ def _check_bad_column_name(self):
and ranges.
""")

selection_glyph = Instance(Glyph, help="""
selection_glyph = Either(Auto, Instance(Glyph), default="auto", help="""
An optional glyph used for selected points.
If set to "auto" then the standard glyph will be used for selected
points.
""")

nonselection_glyph = Instance(Glyph, help="""
nonselection_glyph = Either(Auto, Instance(Glyph), default="auto", help="""
An optional glyph used for explicitly non-selected points
(i.e., non-selected when there are other points that are selected,
but not when no points at all are selected.)
If set to "auto" then a glyph with a low alpha value (0.1) will
be used for non-selected points.
""")

hover_glyph = Instance(Glyph, help="""
Expand Down
18 changes: 11 additions & 7 deletions bokehjs/src/coffee/models/renderers/glyph_renderer.coffee
Expand Up @@ -25,11 +25,15 @@ export class GlyphRendererView extends RendererView

selection_glyph = @model.selection_glyph
if not selection_glyph?
selection_glyph = mk_glyph({fill: {}, line: {}})
else if selection_glyph == "auto"
selection_glyph = mk_glyph(@model.selection_defaults)
@selection_glyph = @build_glyph_view(selection_glyph)

nonselection_glyph = @model.nonselection_glyph
if not nonselection_glyph?
nonselection_glyph = mk_glyph({fill: {}, line: {}})
else if nonselection_glyph == "auto"
nonselection_glyph = mk_glyph(@model.nonselection_defaults)
@nonselection_glyph = @build_glyph_view(nonselection_glyph)

Expand Down Expand Up @@ -236,13 +240,13 @@ export class GlyphRenderer extends Renderer
return index

@define {
x_range_name: [ p.String, 'default' ]
y_range_name: [ p.String, 'default' ]
data_source: [ p.Instance ]
glyph: [ p.Instance ]
hover_glyph: [ p.Instance ]
nonselection_glyph: [ p.Instance ]
selection_glyph: [ p.Instance ]
x_range_name: [ p.String, 'default' ]
y_range_name: [ p.String, 'default' ]
data_source: [ p.Instance ]
glyph: [ p.Instance ]
hover_glyph: [ p.Instance ]
nonselection_glyph: [ p.Any, 'auto' ] # Instance or "auto"
selection_glyph: [ p.Any, 'auto' ] # Instance or "auto"
}

@override {
Expand Down

0 comments on commit fbe1fa8

Please sign in to comment.