Tooltip values are transferred from one element to another

Hi,
I have a link tooltip that shows 4 values of a link.Not all links have all 4 values. Some have only 3.
When i move the mouse over a link with 4 values, it shows all 4 values, but then if i move to the next link which has only 3 values, it also shows 4 values, where the 4th value is the value taken from the first link.
But,
If i start with the 3 values link, i see only 3 values, and moves to the 4 values link, i see the 4 values on the link. But, i if return back to the 3 values link, the 4th value appears on the link.
Strange…

How are you defining the tooltip? It seems that each time you are not clearing the container of values, whatever that might be.

I’m not sure i follow you, which container ?
Could you point me to a sample ?

https://gojs.net/latest/intro/toolTips.html

How have you defined your tooltip?

I also tried to put “ToolTip” instead of go.Adornment. Didn’t help.

I even tried to replace my code with your sample code :

toolTip:
("ToolTip", (go.TextBlock, { margin: 4 },
new go.Binding(“text”, “serviceId”))
) // end of Adornment

Works the same

As you now know, the same Adornment is reused when showing tooltips, because only one can be shown at a time.

Data Bindings are only evaluated when there is a non-undefined value, because we want to support initial default values.

So the combination means the default values that you had set for your TextBlocks, the empty string, are only used the first time that the tooltip is bound to data.

You could override ToolManager.showToolTip to reset the TextBlock.text properties to “”, and then call the super method.

OK,
I have created my custom ‘HoshenToolManager’ that inherits from go.ToolManager.
Then, it tried to user it by setting :
diagram.toolManager = new HoshenToolManager();
but… it does not work…
I don’t know how yo use it.

Have you initialized your instance of ToolManager completely?

Have you also followed the documentation’s suggestion to set Diagram.defaultTool?

It’s probably much easier to override the method just by modifying the standard instance of Diagram.toolManager, rather than replacing it with a new instance.

I tried to override the showTooTip method by :

go.Diagram.ToolManager.showToolTip = function(…

but the TS compiler complains that ToolManager is not a property of go.Diagram.

So, i tried to override the instance:
this.diagram.toolManager.showToolTip = function(…
but then, during runtime, gojs complains that this.hideToolTip() is not declared…
Please advise…

myDiagram.toolManager.showToolTip = function(tooltip, obj) {
  tooltip.elt(1).elt(3).text = "";
  go.ToolManager.prototype.showToolTip.call(this, tooltip, obj);
};

I don’t know exactly how you want to reset the default values of your tooltip objects. This code is just a guess at the minimum to address one problem.

I have copied the code as is.
Two problems :

  1. During compilation the compiler complains that showToolTip is not a property of ToolManager.
  2. During run time the code crashed for ‘undefined’ showToolTip.

Oops – a typo. Fixed above.

Works fine.
Thanks

Just ran into the same issue. Couldn’t you add some kind of option to define if a specific tooltip adornment should be recreated or reused each time it is opened?
Also not sure if I want to override the standard ToolManager just to handle a specific tooltip in one of my components?

I would now go with this solution:

link.mouseEnter = (e, l: go.Link) => {
   l.toolTip = this.createTooltip();
 };

Where the createTooltip() creates the ToolTip adornment. This makes sure a fresh adornment is created whenever the user hovers over a link.

This seems to work nicely. Do you see any disadvantages in using this approach?

The main problem is one you have probably already considered – the waste of time and memory that the code incurs, and thus the additional lag that might result.

You didn’t want to override showToolTip?