kaluginserg / cytoscape-node-html-label

Labels for cytoscape node. Demo:
https://kaluginserg.github.io/cytoscape-node-html-label/
MIT License
102 stars 43 forks source link

HTML Label visibility when corresponding node is not displayed or invisible #14

Open cversari opened 6 years ago

cversari commented 6 years ago

Hello, the HTML Label is visible independently of the style of the node. So if the node style is { display: 'none' } or { visibility: 'hidden' } the HTML label is still visible even if the corresponding node is not.

In practice this is not a problem, in fact it is very easy to hide the HTML label by checking the style of the node in the function assigned to the "tpl" attribute in the parameters passed to cy.nodeHtmlLabel().

However, I cannot figure out a case where the HTML should be visible when the node style is { display: 'none' } (while it may make sense to let the HTML label visible even if the style is { visibility: 'hidden' }).

So I am not sure whether this behavior is a bug, I am just reporting it in the case it is.

Cristian

McManning commented 6 years ago

Hey Cristian,

Coincidentally - I've ran into the same issue today and was about to open a ticket as well 😄. What was your workaround for accessing the Cytoscape node? I wasn't able to find a way to access the underlying node from within the tpl function - only the data stored in the node's data().

Thanks! Chase

cversari commented 6 years ago

Hi Chase, in the node's data() I get the id of the node, then I query the cytoscape main object to find the node (something like cy.$('#' + data.id)). Let me know if that works for you.

Cristian

jspautsch commented 6 years ago

in the node's data() I get the id of the node, then I query the cytoscape main object to find the node (something like cy.$('#' + data.id)). Let me know if that works for you.

We did the same thing (except with cy.getElementById), but it would be nice if the tpl function returned the actual element. I'm not sure why it only returns the data.

maxkfranz commented 5 years ago

It is possible to use something like query: 'node:visible'?

josejulio commented 5 years ago

It is possible to use something like query: 'node:visible'?

That works for me.

This would also "hide" (as the last rule) the text if you have several rules

{
    query: 'node:hidden',
    tpl: () => ''
}