Sigma js change label color

Graphs inside the browser
Post Reply [phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275: count(): Parameter must be an array or an object that implements Countable
louiejre
Posts:4
Joined:26 Mar 2013 01:33
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275: count(): Parameter must be an array or an object that implements Countable
Sigma js change label color

Post by louiejre » 26 Apr 2013 02:00

Anyone know how to change label color/font dynamically? For example, when mouse over a node, change label color to red or increase font size. Thanks.

evilefi
Posts:5
Joined:27 Apr 2012 08:56
Contact:

Re: Sigma js change label color

Post by evilefi » 26 Apr 2013 09:59

Quick&dirty:

Code: Select all

sigma.instances[1].bind('overnodes', function(event){ sigma.instances[1].iterNodes(function(node){if(node.id==event.content){node.color="red";}}); });
sigma.instances[1].bind('outnodes', function(event){ sigma.instances[1].iterNodes(function(node){if(node.id==event.content){node.color="";}}); });
Get inspired here: http://sigmajs.org/examples.html

louiejre
Posts:4
Joined:26 Mar 2013 01:33
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275: count(): Parameter must be an array or an object that implements Countable

Re: Sigma js change label color

Post by louiejre » 27 Apr 2013 01:35

Thank you for the reply. Your code only works with node color, but I was looking for ways to change label colors. I can change the defaultLabelColor property, but it will affect all labels, and change is not dynamic. "label" is a node property, but label color or font is not. I hope someone can point me to the right direction. Thanks.

evilefi
Posts:5
Joined:27 Apr 2012 08:56
Contact:

Re: Sigma js change label color

Post by evilefi » 28 Apr 2013 17:49

Hi.

As you can see here https://github.com/jacomyal/sigma.js/bl ... er.js#L361 the color node property is the only way to modify the filling via node property (if the drawingProperties are set accordingly).

If you need more you I fear you will have to change the implementation of

Code: Select all

drawLabel(node)

Post Reply
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275: count(): Parameter must be an array or an object that implements Countable
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275: count(): Parameter must be an array or an object that implements Countable