Fixes issue with trying to access tick.label when using Sankey chart#177
Merged
K009 merged 2 commits intoblacklabel:masterfrom Mar 3, 2026
Merged
Fixes issue with trying to access tick.label when using Sankey chart#177K009 merged 2 commits intoblacklabel:masterfrom
K009 merged 2 commits intoblacklabel:masterfrom
Conversation
|
@FadhlurZ Can we add a label |
Contributor
Author
|
@PaultjeScholes Unfortunately it looks like I am not able to add reviewers and a label to this PR. Could you @K009 @mfilipiec maybe take a look at this PR? I think it has quite a big impact for some users of this package. |
Collaborator
|
Hi, thanks a lot for your contribution and for catching this bug. The fix looks solid, happy to merge! |
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.
Fix: Add null checks for Sankey chart compatibility
Problem:
The plugin crashes when rendering Sankey charts with the following error:
TypeError: Cannot read properties of undefined (reading 'label')Root Cause:
In the
bindChartEventsfunction, the code assumes all chart axes havetickPositionsand thataxis.ticks[pos]will always return a valid tick object. However, Sankey charts don't use traditional axes with ticks, causing:undefinedundefinedfor certain positionsSolution:
Added null/undefined checks before accessing tick properties:
Demo where issue is visible in browser console:
https://jsfiddle.net/241fkqr6/
Impact:
This fix ensures the plugin works correctly with Sankey charts and other chart types that don't have traditional axes, while maintaining backward compatibility with all existing chart types.