Skip to content

Fix/category scale wrong tooltip #12106

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add test for category scale getLabelForValue
showing the problem/issue if a label is a string
but converts to a number within the labels range.
  • Loading branch information
mbehr1 committed Aug 2, 2025
commit d326efcae3454f04d61edbc6b20bb2ee20000a54
4 changes: 3 additions & 1 deletion test/specs/scale.category.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ describe('Category scale tests', function() {
yAxisID: 'y',
data: [10, 5, 0, 25, 78]
}],
labels: ['tick1', 'tick2', 'tick3', 'tick4', 'tick5']
labels: ['tick1', 'tick2', 'tick3', '1', 'tick5']
},
options: {
scales: {
Expand All @@ -176,6 +176,8 @@ describe('Category scale tests', function() {
var scale = chart.scales.x;

expect(scale.getLabelForValue(1)).toBe('tick2');
expect(scale.getLabelForValue('tick3')).toBe('tick3');
expect(scale.getLabelForValue('1')).toBe('1'); // and not 'tick2'
});

it('Should get the correct pixel for a value when horizontal', function() {
Expand Down