Skip to content

Wrong tooltip value/formattedValue shown if category scale contains labels that convert to numbers within 0..labels.length #12107

@mbehr1

Description

@mbehr1

Expected behavior

In the tooltip for values with a category scale the formattedValue is showing a completely wrong value if the category scale contains labels that convert to numbers within 0..labels.length.
E.g. if there are 5 labels and one of them is "1" for items having that value "1" a wrong tooltip value is returned.

Current behavior

Currently the nth label is shown for a value of "n" and not the label "n".

Reproducible sample

#12106

Optional extra steps/info to reproduce

I think this is due to scale.category.js _getLabelForValue ignoring the type.

Possible solution

See adjusted test case showing the issue and potential fix in
#12106

Context

No response

chart.js version

v4.5.0

Browser name and version

No response

Link to your project

mbehr1/dlt-logs#268

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions