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

Hover tooltip breaks with zero-width wedges #8742

Closed
PavloFesenko opened this issue Mar 13, 2019 · 3 comments · Fixed by #8755
Closed

Hover tooltip breaks with zero-width wedges #8742

PavloFesenko opened this issue Mar 13, 2019 · 3 comments · Fixed by #8755

Comments

@PavloFesenko
Copy link

PavloFesenko commented Mar 13, 2019

For defects or deficiencies, please provide ALL OF THE FOLLOWING:

ALL software version info (bokeh, python, notebook, OS, browser, any other relevant packages)

bokeh 1.0.4, python 3.6.6, notebook Kaggle, OS Windows 10, browser Chrome

Description of expected behavior and the observed behavior

When one of the values in the wedge/pie chart is 0, the hover tooltip shows the column instead of the single value.

Complete, minimal, self-contained example code that reproduces the issue

from math import pi

import pandas as pd

from bokeh.io import output_file, show
from bokeh.palettes import Category20c
from bokeh.plotting import figure
from bokeh.transform import cumsum

output_file("pie.html")

x = {
    'United States': 0,
    'United Kingdom': 93,
    'Japan': 89,
    'China': 63,
    'Germany': 44,
    'India': 42,
    'Italy': 40,
    'Australia': 35,
    'Brazil': 32,
    'France': 31,
    'Taiwan': 31,
    'Spain': 29
}

data = pd.Series(x).reset_index(name='value').rename(columns={'index':'country'})
data['angle'] = data['value']/data['value'].sum() * 2*pi
data['color'] = Category20c[len(x)]

p = figure(plot_height=350, title="Pie Chart", toolbar_location=None,
           tools="hover", tooltips="@country: @value", x_range=(-0.5, 1.0))

p.wedge(x=0, y=1, radius=0.4,
        start_angle=cumsum('angle', include_zero=True), end_angle=cumsum('angle'),
        line_color="white", fill_color='color', legend='country', source=data)

p.axis.axis_label=None
p.axis.visible=False
p.grid.grid_line_color = None

show(p)

Screenshots or screencasts of the bug in action

Pie chart bug

@bryevdv
Copy link
Member

bryevdv commented Mar 13, 2019

Thanks for the detailed report @PavloFesenko and especially the complete test case

@bryevdv
Copy link
Member

bryevdv commented Mar 13, 2019

Offhand guess: when the angle is zero it ends up hit-testing the entire circle

@PavloFesenko
Copy link
Author

@bryevdv , thanks for a quick response! One can overcome this bug by replacing 0 with a small value, for example, 0.001 but this is just a temporary fix.

@bryevdv bryevdv mentioned this issue Mar 16, 2019
2 tasks
@mattpap mattpap modified the milestones: 1.1.1, 1.1 Mar 16, 2019
@bryevdv bryevdv changed the title Hover tooltip in wedge/pie charts not working correctly Hover tooltip in wedge/pie charts broken with zero width slices Mar 24, 2019
@bryevdv bryevdv changed the title Hover tooltip in wedge/pie charts broken with zero width slices Hover tooltip breaks with zero-width wedges Mar 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants