Skip to content

Conversation

@hhjeee
Copy link
Contributor

@hhjeee hhjeee commented Mar 7, 2025

New Pull Request

Fix #4966

This PR modifies the way the y-axis formatter is retrieved in getFormatters(i).

Previously, the formatter was obtained from w.globals.yLabelFormatters[i], which relied on the index. This approach caused issues when the yaxis array was shorter than the series array, especially in cases where some yaxis items had seriesName values in an array format (as seen in the issue example).

To resolve this, I introduced a new function, getFormatterBySeriesName(seriesIndex, w), which finds the appropriate formatter by matching the seriesName within the yaxis array. This ensures that the correct formatter is applied based on the series name rather than relying on array indices.

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • My branch is up to date with any changes from the main branch

@hhjeee hhjeee closed this Mar 7, 2025
@hhjeee hhjeee reopened this Mar 7, 2025
@hhjeee
Copy link
Contributor Author

hhjeee commented Mar 28, 2025

Hi! Just wanted to follow up on this PR.

I understand that introducing a new function like getFormatterBySeriesName might require careful consideration. I’m also totally open to alternative implementations if this approach isn’t the most efficient.

That said, I do believe the current index-based logic for retrieving y-axis formatters (w.globals.yLabelFormatters[i]) should be revisited, as it can lead to mismatches when the yaxis array doesn’t align with the series array — especially when seriesName is an array.

@github-actions
Copy link

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Tooltip formatting not respecting seriesName of yAxis

1 participant