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

Hoverformat fails to apply when showticklabels=False #261

Closed
yankev opened this issue Feb 17, 2016 · 4 comments
Closed

Hoverformat fails to apply when showticklabels=False #261

yankev opened this issue Feb 17, 2016 · 4 comments
Labels
bug something broken

Comments

@yankev
Copy link
Contributor

yankev commented Feb 17, 2016

This is in reference to the following issue in the Plotly Python API:
Issue 398

Unless showticklabels = True then the hoverformat is not applied.
For example in the following code:

from plotly.graph_objs import Scatter, Layout, YAxis, Figure
import plotly.plotly as py

data = [Scatter(x=[1, 2, 3],
                 y=[0.12345, 0.23456, 0.34567])]
layout = Layout(yaxis=YAxis(showticklabels=False,
                            hoverformat=",.2r",))
figure = Figure(data=data, layout=layout)
py.iplot(figure)

Plot generated from the code

The associated yaxis portion of the json is

yaxis:{
  hoverformat:",.2r",
  showticklabels:false,
  type:"linear",
  range:[
             -0.2711700793681046,
              0.7894967832778617
             ],
  autorange:false
}

and so it appears to have translated correctly from the python plot function call.

@mdtusz
Copy link
Contributor

mdtusz commented Feb 17, 2016

Confirmed (unless @etpinard knows some reason why not). Thanks for reporting it.

Aside: For markdown links, the structure is name of link. Looks like you may have gotten it mixed up 😉

@mdtusz mdtusz added the bug something broken label Feb 17, 2016
@etpinard
Copy link
Contributor

@yankev even better: use this template to show the bug in a codepen

@yankev
Copy link
Contributor Author

yankev commented Feb 17, 2016

@mdtusz Haha yeah.
@etpinard Oh ok, I'll just adjust the link to the one you made this time.

@etpinard
Copy link
Contributor

Here's the problematic block: https://github.com/plotly/plotly.js/blob/master/src/plots/cartesian/tick_defaults.js#L33-L54

We only coerce hoverformat when showticklabels is true --- which is a little too crude.

Arguably, the logic for tickprefix and ticksuffix is wrong too. We should coerce them even in the case where showticklabels is false.

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

No branches or pull requests

3 participants