extrawhitecitrus
extrawhitecitrus

Reputation: 43

How to display edited node/edge property as label in cytoscape js?

Using cytoscape.js I can display the name property of my data as a label like this:

'label': 'data(name)'

Is there a possibility to display an edited version without changing the name in the data? For example a substring like this:

'label': 'data({name.split('.')[0]})'

Upvotes: 0

Views: 153

Answers (1)

swatchai
swatchai

Reputation: 18782

The meaning of "data(name)" is equal to javascript code:

data["name"]

or just

data.name

Thus, your node data must have proper key/value, for example:

{ data: { id: "j", name: "Jerry"}}

So that, the node's data.name can return something ("Jerry" in this case). Valid code is limited to the node's data extraction. General javascript code is not possible due to security reasons.

In conclusion, there is no possibility to use:

'label': 'data({name.split('.')[0]})'

because there will be an error due to invalid code.

Upvotes: 1

Related Questions