Repository navigation
Conversation
Specs for the label that getLabelAndValue() gives a point in scatter and bubble charts: from a category x axis, from a category y axis beside a linear x axis, from the x axis when both are category axes, for a point whose category repeats, from data.labels when it has an entry, and empty without either or for a point without a category.
When data.labels has no entry for a point, getLabelAndValue() of the scatter and bubble controllers now gives the label of the point's own category: from the index axis when it is a category axis, else from the value axis when that one is, else ''. Before, the label was read from data.labels by index only. That worked only because the category scale adds the labels it infers from the data to data.labels, and it named the wrong category when categories repeat or both axes are category axes.
✅ Deploy Preview for chartjs-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
Size Change: +308 B (+0.09%) Total Size: 362 kB 📦 View Changed
ℹ️ View Unchanged
|
kurkle
marked this pull request as ready for review
November 24, 2026 03:40
etimberg
approved these changes
Nov 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #11495 and #11893. This is piece P2 of the design in
openspec/changes/isolate-category-scale-labels/(Decision 7).What was wrong
When
data.labelshas no entry for a point, the scatter and bubble controllers read the tooltip label fromchart.data.labels[index]. That works only because the category scale writes the labels it infers from the data into the shareddata.labels. Once each category scale keeps its inferred labels to itself (a later piece of the same design), that read gets nothing and the tooltip title goes blank. Reading by index was also wrong before that: it gives the wrong category when categories repeat, and with two category axes it reads from both axes' labels mixed into one array.What changed
In
getLabelAndValue()ofcontroller.scatter.jsandcontroller.bubble.js, the label is:data.labelsentry at the point's index, when there is one (unchanged);'', which also covers a point that has no category.Each controller gets the same small
categoryLabel()helper. A category axis is recognised byscale.type === 'category', so a custom scale that extendsCategoryScaleunder another id is not recognised.Tests
New specs, under
tooltip labelintest/specs/controller.scatter.tests.jsandtest/specs/controller.bubble.tests.js:'b''b''b''a','b','a': point 2 is'a'data.labelshas an entry: that entrydata.labelsand no category axis:''''Results, Karma in Chrome:
Expected '' to be 'b',Expected '' to be 'a'Expected '' to be 'b'/'a'data.labels. They protect the label once the scale stops writing there; the third row shows that.data.labelsheld at the point's index.plugin.filler,scale.radialLinear,scale.time,scale.timeseries). Those 7 fail the same way on master in my local Chrome 158, so they are not caused by this change.pnpm lint-typespasses.How to try it
Hover the third point. The tooltip title is
a; on master it is empty.