Closed maxkfranz closed 8 years ago
Hi. I had to inspect the code to understand how propertly pass a function for "label" style...
If you pass only the code that @maxkfranz exposed then doest not works. You have to put the whole array inside a function being returned, otherway it won't work.
This is how I manage it to work:
...
snap.shot({
elements: {
nodes,
edges
},
style: function(){ return [
{
selector: "node",
css: {
label: "data(id)"
}
},
{
selector: "edge",
css: {
label: function(elem){ return elem.data("weight") > 0 ? elem.data("weight") : " "}
}
}
]},
...
Docs should tell that... It is very confusing saying "// a cytoscape.js stylesheet in json format (or a function that returns it)" without say if you want to make some css property as functions, you should use a function wrapper for style property option.
(In cytoscape.js you can pass a JSON with property being a function. In cytosnap no. I have to make a wrapper function to get the same result)
Thanks
e.g.
Function would get executed in phantom context, so there can't be references outside this scope.