Skip to content

Ensure hoverinfo <--> hovertemplate number formatting equivalence #3968

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

Merged
merged 4 commits into from
Jun 18, 2019

Conversation

etpinard
Copy link
Contributor

This fixes the default hovertemplate formatting for flags for traces: choropleth, scattergeo, scatterpolar(gl), barpolar and scatterternary - which should be the end of this story ✅

In brief, when setting hovertemplate in a trace we say hoverinfo flag x, we guarantee that the hover labels with hoverinfo: 'x' OR hovertemplate: '%{x}' render the same (i.e with the same number formatting).

cc @plotly/plotly_js

@etpinard etpinard added bug something broken status: reviewable labels Jun 17, 2019

// N.B here the ° sign is part of the formatted value for thetaunit:'degrees'
var thetaVal = angularAxis.thetaunit === 'degrees' ? Lib.rad2deg(cdi.theta) : cdi.theta;
pointData.thetaLabel = Axes.tickText(angularAxis, thetaVal, 'hover').text;
Copy link
Contributor Author

@etpinard etpinard Jun 17, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This here is an interesting case. In a similar scenario, note also that:

Plotly.newPlot(gd, [{
  y: [1],
  hovertemplate: '%{y}'
}], {
  yaxis: {ticksuffix: ' --', tickprefix: '-- '}
})

shows -- 1 -- in the hover labels.


Please let me know if you think ticksuffix and tickprefix should be left out.

@archmoj
Copy link
Contributor

archmoj commented Jun 18, 2019

Masterly done.
💃

@etpinard etpinard merged commit 2b4de3e into master Jun 18, 2019
@etpinard etpinard deleted the choropleth-z-hovertemplate-formatting-fix branch June 18, 2019 13:52
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

Successfully merging this pull request may close these issues.

2 participants