Skip to content

Keep shape label texttemplate working on category axes - #8219

Open
Yahiro025 wants to merge 3 commits into
plotly:mainfrom
Yahiro025:fix-multicategory-texttemplate-fork
Open

Yahiro025 wants to merge 3 commits into
plotly:mainfrom
Yahiro025:fix-multicategory-texttemplate-fork

Conversation

@Yahiro025

Copy link
Copy Markdown
Contributor

A shape with label.texttemplate throws TypeError: axis.d2l is not a function on a multicategory axis, and on a plain category axis the same conversion can append the shape's numeric positions as new categories.

label_texttemplate.js maps shape positions with axis.d2l. Multicategory axes do not define it, and category axes define d2l_noadd, which maps existing categories and numeric positions without adding categories. This uses that variant when the axis provides it and falls back to d2l otherwise. The new case in test/jasmine/tests/shapes_test.js throws on master and passes with the change.

Fixes #8214

Shape label templates map positions with axis.d2l, which multicategory axes do not define, so a label with texttemplate throws 'axis.d2l is not a function'. On category axes d2l also appends unknown positions as categories, so the template changes the axis range.

Use d2l_noadd when the axis provides it: it returns existing category indices and numeric positions without adding categories, and it is the only data-to-linear conversion multicategory axes define.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG]: Shape label texttemplate throws on multicategory axes

1 participant