myDiagram.linkTemplate =
$(go.Link,
{ routing: go.Link.AvoidsNodes, curve: go.Link.JumpGap, corner: 10, reshapable: true, toShortLength: 7 },
new go.Binding("points").makeTwoWay(),
// mark each Shape to get the link geometry with isPanelMain: true
$(go.Shape, { isPanelMain: true, stroke: "black", strokeWidth: 7 }),
$(go.Shape, { isPanelMain: true, strokeWidth: 5 },
new go.Binding("stroke", "colors")),
$(go.Shape, { isPanelMain: true, stroke: "white", strokeWidth: 3, name: "PIPE", strokeDashArray: [10, 10] }),
$(go.Shape, { toArrow: "Triangle", scale: 1.3, fill: "gray", stroke: null })
);
load();
}
function load() {
$.ajax({
url : "../php/dw_model.php",
type : "GET",
success : function(data){
console.log(data);
$.ajax({
url : "../php/dw_model_link.php",
type : "GET",
success : function(data1){
console.log(data1);
myDiagram.model = new go.GraphLinksModel(data, data1);
// Animate the flow in the pipes
var anim = new go.Animation();
anim.easing = go.Animation.EaseLinear;
myDiagram.links.each(function(link) {
anim.add(link.findObject("PIPE"), "strokeDashOffset", 20, 0)
});
// Run indefinitely
anim.runCount = Infinity;
anim.start();
},
error : function(data1) {
}
});
},
error : function(data) {
}
});
Data: php/dw_model.php [{“key”:“P1”,“category”:“Process”,“pos”:“300 120”,“text”:“VIP”,“color”:“red”},{“key”:“P2”,“category”:“Process”,“pos”:“180 220”,“text”:“Routing-maxscale-RDU1”,“color”:“green”},{“key”:“P3”,“category”:“Process”,“pos”:“420 220”,“text”:“Routing-maxscale-RDU2”,“color”:“blue”},{“key”:“P4”,“category”:“Process”,“pos”:“300 300”,“text”:“Master-DB”,“color”:“yellow”}]
php/dw_model_link.php [{“from”:“P1”,“to”:“P2”,“colors”:“green”,“speed”:“20”},{“from”:“P2”,“to”:“P3”,“colors”:“green”,“speed”:“10”},{“from”:“P3”,“to”:“P2”,“colors”:“blue”,“speed”:“100”},{“from”:“P3”,“to”:“P4”,“colors”:“yellow”,“speed”:“200”}]
I understand that the following routine updates each links with animation property of “strokeDashOffset” to 20. I want to be able to update each links “strokeDashOffset” value with the data from the dw_model_link “speed” key.(ie.“speed”:“20”,“speed”:“10” etc). Any help would be appreciated.