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

Bryanv/usability #7921

Merged
merged 8 commits into from May 25, 2018

Conversation

Projects
None yet
2 participants
@bryevdv
Copy link
Member

bryevdv commented May 20, 2018

@pzwang suggested trying to get more in the "user mind" this PR is an attempt to make some common things easier than they currently are. In particular:

  • add $name special variable to shoe glyph renderer name
  • adds tooltips convenience arg to Figure
  • adds Plot.hover accessor

all of which make simple hover tool cases much easier to get up and running. Also update various examples to pass dataframes or dicts directly as source where possible.

I'd like to try and solve at least one more issue, which is there is not a good way to add a single hover tool to a vbar_stack etc that covers the stacked quantities.

cc @mattpap for any early thoughts.

  • tests added / passed
  • release document entry (if new feature or API change)
@bryevdv

This comment has been minimized.

Copy link
Member Author

bryevdv commented May 20, 2018

Oh, I also disabled _repr_pretty it made the console ipython unusable.

@bryevdv

This comment has been minimized.

Copy link
Member Author

bryevdv commented May 20, 2018

OK, I found a slight special-casey solution, but it is trivial to implement, and reasonable to explain, which is to add support for @$name specifically, with the meaning @ (lookup a column) but use special var $name for getting the column name. This lets a single hover tool work great for stacked bar charts:

from bokeh.core.properties import value
from bokeh.io import show, output_file
from bokeh.plotting import figure

output_file("stacked.html")

fruits = ['Apples', 'Pears', 'Nectarines', 'Plums', 'Grapes', 'Strawberries']
years = ["2015", "2016", "2017"]
colors = ["#c9d9d3", "#718dbf", "#e84d60"]

data = {'fruits' : fruits,
        '2015'   : [2, 1, 4, 3, 2, 4],
        '2016'   : [5, 3, 4, 2, 4, 6],
        '2017'   : [3, 2, 4, 4, 5, 3]}

p = figure(x_range=fruits, plot_height=250, title="Fruit Counts by Year",
           toolbar_location=None, tools="hover", tooltips="$name @fruits: @$name")

p.vbar_stack(years, x='fruits', width=0.9, color=colors, source=data,
             legend=[value(x) for x in years])

p.y_range.start = 0
p.x_range.range_padding = 0.1
p.xgrid.grid_line_color = None
p.axis.minor_tick_line_color = None
p.outline_line_color = None
p.legend.location = "top_left"
p.legend.orientation = "horizontal"

show(p)

screen shot 2018-05-20 at 17 49 25

@bryevdv bryevdv force-pushed the bryanv/usability branch 2 times, most recently from 159547d to 3dc9b87 May 21, 2018

@bryevdv

This comment has been minimized.

Copy link
Member Author

bryevdv commented May 21, 2018

I put _repr_pretty_ back for now, but we have to do something about it. IPython console is currently unusable due to super long reprs spamming the console.

@bryevdv bryevdv force-pushed the bryanv/usability branch from 3dc9b87 to 615d883 May 24, 2018

@mattpap

This comment has been minimized.

Copy link
Contributor

mattpap commented May 24, 2018

I put repr_pretty back for now, but we have to do something about it.

This behavior isn't unexpected. We just need to revisit #7729 (comment).

@bryevdv

This comment has been minimized.

Copy link
Member Author

bryevdv commented May 24, 2018

This behavior isn't unexpected. We just need to revisit #7729 (comment).

That's exactly what I said.

@bryevdv bryevdv force-pushed the bryanv/usability branch from 615d883 to 313cfd2 May 24, 2018

@bryevdv bryevdv added status: ready and removed status: WIP labels May 24, 2018

@bryevdv

This comment has been minimized.

Copy link
Member Author

bryevdv commented May 24, 2018

@mattpap this is ready, I will plan to merge later today unless you indicate you want additional time to comment.

bryevdv added some commits May 20, 2018

@bryevdv bryevdv force-pushed the bryanv/usability branch from 313cfd2 to 78f22de May 24, 2018

@@ -83,6 +83,10 @@ class FigureOptions(Options):
The type of the y-axis.
""")

tooltips = Either(String, List(Tuple(String, String)), help="""

This comment has been minimized.

@mattpap

mattpap May 24, 2018

Contributor

Missing docstring.

This comment has been minimized.

@bryevdv

bryevdv May 24, 2018

Author Member

Thanks, I have added it and will merge when green.

@mattpap

This comment has been minimized.

Copy link
Contributor

mattpap commented May 24, 2018

Changes to bokeh's plotting API should be mirrored in bokehjs. Though given the bokehjs API is behind anyway, this could be done in another PR, filling in all the gaps.

@bryevdv bryevdv merged commit 422a437 into master May 25, 2018

2 checks passed

Better Code Hub ✅ Better Code Hub approves this code
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

@bryevdv bryevdv deleted the bryanv/usability branch May 25, 2018

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