Quantcast
Channel: GoJS - Northwoods Software
Viewing all articles
Browse latest Browse all 7069

Binding more than one value

$
0
0

@g.bartoli wrote:

Dear Northwoods Software,
we are evaluating GoJS for a small internal project, I'm a beginner and I would like to ask a small question.

I already understood how to bind simple model properties to nodes and link templates and also how to use conversion functions to translate a text into a color, like in this perfectly working case:

function nodeType2Color(type) {
if (type === "BPOP") return "OrangeRed";
if (type === "BOMP") return "Peru";
return "white";
}

myDiagram.linkTemplate = $(go.Link, $(go.Shape,
new go.Binding("stroke", "cabletype", cableType2Color)));

I'm asking if it's possible to merge more than one property and pass it to a conversion function.
Suppose I have the following data for a node:

{"key":"ABC","label":"foo","type":"bar"}

And this simple merging function:

function mergeTexts(text1, text2) { return text1.concat(text2); };

How can I write a function that binds "label" and "type" to a new text to be used as a label ("foobar", in this case) for the node or the link? The following try is (obviously) not working...

myDiagram.linkTemplate = $(go.Link, $(go.Shape,
new go.Binding("text", "label", "type", mergeTexts)));

I hope I have explained well, English is not my main language.

Thanks in advance,
Guido

Posts: 3

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 7069

Trending Articles