Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to know the source of a linked tooltip trigger #3267

Open
flickz opened this issue Jun 26, 2023 · 3 comments
Open

How to know the source of a linked tooltip trigger #3267

flickz opened this issue Jun 26, 2023 · 3 comments

Comments

@flickz
Copy link

flickz commented Jun 26, 2023

Description

Hey guys,
I have two charts with linked tooltips. Is there a way to know which of the charts is the source of the tooltip trigger?

PS: Both charts tooltips are customized using the tooltip.content option.

@watnab
Copy link

watnab commented Jun 27, 2023

I don't know the way to know which chart is hovered.
It seems this means the source Chart object when the handler is called.
However it seems the handlers of both chart can be called.

@netil netil added the question label Jun 27, 2023
@netil
Copy link
Member

netil commented Jun 27, 2023

I made an example to determine the instance were triggered the event. (open the devtool and checkout the console log)

  tooltip: {
    linked: true,
    contents: function() {
         if (this === currentInstance) {
               // within this block, means from the current instance triggered the event
         }
    }
  },

@watnab
Copy link

watnab commented Jun 27, 2023

I see.

I don't know the way to know which chart is hovered.

let currentInstance = null;

  onover: function(event) {
    if (event.isTrusted) {
     	currentInstance = this;
    }
  },

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

No branches or pull requests

3 participants