Skip to content

[charts] Highlight doesn't work when series ID is a number #18415

Closed

Description

@bernardobelchior

Highlight doesn't work when series ID is a number. This is because we use the series ID as a key in the series object here.

Keys in object cannot be numbers and will automatically be coerced to string:

Each property name is a string or a Symbol. Any other value, including a number, is coerced to a string. This outputs 'value', since 1 is coerced into '1'.

Source

const a = { 1: 'a' };
console.log(a['1']); // a

Reproduction

Here.

The second series' ID is 1 instead of "1", so highlight doesn't work. If you change it to a string, then it works.

Screen.Recording.2025-06-17.at.17.42.02.mov

Alternatives

  1. Restrict series IDs to strings. This way, we can keep using objects for storing series. I think this might be best because data-series doesn't distinguish between strings and numbers, so we'll have issues there as well.
  2. Use a Map to store series. This way, we can keep using numbers for keys, but it would break all use*SeriesContext because it is exported and accessing maps using the bracket notation doesn't work.

Activity

  1. added
    type: bug
    scope: charts
    on Jun 17, 2025
  2. noobyogi0010 commented on Jun 17, 2025

    @noobyogi0010
    Contributor

    Hey,
    I would like to take up this issue, and I think going with option 1 would be more suitable as it makes it backward compatible and doesn't break existing functionality.
    Let me know if you think otherwise.
    Thanks.

  3. alexfauquette commented on Jun 18, 2025

    @alexfauquette
    Member

    I've open #18423 to fix this.

    The option 1 seems to be the way to go. It 's not the first time we face this kind of issue. But it's a breaking change. ANy body using a number as series' id will get TS complain, preventing build of the application.

    In theory this should not be an issue because we should not rely on the object keys, but on either

    • seriesOrder content which is an array o ids. So the number/string are not an issue
    • series[id].id which is also not an issue for string/number
  4. alexfauquette commented on Jun 18, 2025

    @alexfauquette
    Member

    @noobyogi0010 Thanks for proposing worling on this one, but we found a workaround for this issue

  5. noobyogi0010 commented on Jun 18, 2025

    @noobyogi0010
    Contributor

    No worries at all! Glad it's resolved!
    Thanks!

  6. JCQuintas commented on Jun 18, 2025

    @JCQuintas
    Member

    Fixed by #18423

  7. github-actions commented on Jun 18, 2025

    @github-actions
    Contributor

    This issue has been closed. If you have a similar problem but not exactly the same, please open a new issue.
    Now, if you have additional information related to this issue or things that could help future readers, feel free to leave a comment.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    scope: chartstype: bug

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions