santosjorge / cufflinks

Productivity Tools for Plotly + Pandas
MIT License
3.03k stars 676 forks source link

Cufflinks Pie chart hover texts not working correctly #199

Open HTenkanen opened 5 years ago

HTenkanen commented 5 years ago

Hi,

thanks for the great work with the library!

I found an issue with pie chart (cufflinks v0.15). When I try to update the hovertexts with my own custom texts using hovertext='text' and text='text', it does not correctly produce the custom hover texts.

I can "sort of" get the texts into the hover text box by separately modifying the hovertext of the trace but what then actually happens is that for some reason the text box will then include both the automatic hover texts (if using e.g. hovertext='label+percent') and my custom texts somehow mixed which is quite strange.

Below is some code to demonstrate.

This should produce custom hover texts but don't (works when using plotly directly):

data.iplot(
        kind='pie', 
        asFigure=True,
        labels='mylabels', 
        values='myvalues',
        text=data["hover_text"].to_list(),
        hoverinfo='text',
        pull=.05,
        hole=.3,
        margin=dict(l=60, r=60, t=0, b=0),
        showlegend=False,
        theme="pearl")

With the code below, I can get my custom hover texts but with confusing results (combined info from my custom texts and the texts automatically produced):

for i, trace in enumerate(figure['data']):
       trace['hovertext'] = data["hover_text"].to_list()

Cheers, Henrikki