billboard.js icon indicating copy to clipboard operation
billboard.js copied to clipboard

How to know the source of a linked tooltip trigger

Open flickz opened this issue 1 year ago • 3 comments

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.

flickz avatar Jun 26 '23 09:06 flickz

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.

watnab avatar Jun 27 '23 02:06 watnab

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
         }
    }
  },

netil avatar Jun 27 '23 05:06 netil

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;
    }
  },

watnab avatar Jun 27 '23 06:06 watnab