Skip to content

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

Merged
etpinard merged 4 commits into
masterfrom
choropleth-z-hovertemplate-formatting-fix
Jun 18, 2019
Merged

Ensure hoverinfo <--> hovertemplate number formatting equivalence #3968
etpinard merged 4 commits into
masterfrom
choropleth-z-hovertemplate-formatting-fix

Conversation

@etpinard

Copy link
Copy Markdown
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


// 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;

@etpinardetpinardJun 17, 2019

Copy link
Copy Markdown
ContributorAuthor

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
Copy Markdown
Contributor

Masterly done.
💃

@etpinard
etpinard merged commit 2b4de3e into masterJun 18, 2019
@etpinard
etpinard deleted the choropleth-z-hovertemplate-formatting-fix branch June 18, 2019 13:52
etpinard added a commit that referenced this pull request Jun 26, 2019
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugsomething broken

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@etpinard@archmoj