Skip to content

🐛 [BUG] legend.<channel>.itemLabelText got invoked twice with different arguments #3872

@thisrabbit

Description

@thisrabbit

🐛 Bug description [Please make everyone to understand it]

Please provide a link by forking these links G2Plot or GitHub repo, a minimal reproduction.

📷 Step to reproduce

Insert the following code after line 17

.legend('color', {
    itemLabelText: d => {
      console.log(d);
      return String(d.label).toUpperCase();
    },
  })

In the console, it shows that the callback is invoked twice where:

  • The first time with string arguments
  • The second time with object arguments
Image

And it seems that only the computation result for the second time will be used to display the legend label text.

🏞 Expected result

This behavior was not documented in the doc, and while debugging, only the first string argument is instantly visible to developers, which is error prone and can cause the plot crash.

🚑 Any additional [like screenshots]

  • G2Plot Version:
  • Platform:

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions