Repository navigation
Conversation
With a horizontal legend configured with align: 'end', the last item on a line ends at this.right. Binary floating-point rounding can cause x + width + padding to evaluate slightly higher than this.right (for example by 1e-13). When this happened, _draw() treated the item as wrapping to the next line, incrementing cursor.line beyond lineWidths. Because lineWidths[cursor.line] was undefined, cursor.x became NaN and the item was not painted even though its hit box remained clickable. Use hitboxes[i].row and hitboxes[i].col in _draw() to match the line and column boundaries established during fit(), with a small tolerance fallback when hit boxes are not available.
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.
Fixes #12345
Context
When a horizontal legend is configured with
align: 'end', the last item of a row ends atthis.right. Because binary floating-point arithmetic can introduce small rounding differences (such as1e-13),x + width + paddingcan evaluate slightly abovethis.right.When this occurred,
_draw()treated the item as overflowing the row and incrementedcursor.linepast the available entries inlineWidths.lineWidths[cursor.line]evaluated toundefined, makingcursor.xNaN. The browser canvas ignores calls withNaNcoordinates, leaving the item unrendered while its hit box remained interactive.Changes
hitboxes[i].row(andhitboxes[i].colfor vertical legends) in_draw()to use the row and column assignments established infit().1e-6) to the fallback overflow check when hit boxes are unavailable.test/specs/plugin.legend.tests.jsverifying that the last legend item renders with valid coordinates whenalign: 'end'.