Hello,
I’m trying to make a diagram using GraphLinksModel Class. I used the Minimal GoJS Sample as base and i want to fill var with data coming from a php code.
I have it but it has been set manually. As I said I would like to get that content of var nodeDataArray in a “programmatically way”. I want to fill it via my php code because the content of var nodeDataArray will change at times.
I hope you understand my preoccupation … if not clear i could past the code. Thank for your time
I’m not sure what you mean by “fill dynamically”, or by "I would like to get that content of var nodeDataArray in a “programmatically way”, but instead of setting the whole node data array at once you can also add or remove from the node data:
anayway … i have already wrote the code in php and to pass it in var nodeDataArray is the issue. My Intention was not to have a written code but some indications ans why not explanations. Thanks anyway
Were you trying to include the tag when you inserted the generated code? I asked you to insert the code inside your script tag. Use triple backquotes before and after the JavaScript code. Please read: Code Formatting
<script>
function init() {
if (window.goSamples) goSamples(); // init for these samples -- you don't need to call this
var $ = go.GraphObject.make; // for conciseness in defining templates
myDiagram = $(go.Diagram, "myDiagramDiv", // create a Diagram for the DIV HTML element
{
initialContentAlignment: go.Spot.Center, // center the content
"undoManager.isEnabled": true // enable undo & redo
});
// define a simple Node template
myDiagram.nodeTemplate =
$(go.Node, "Auto", // the Shape will go around the TextBlock
$(go.Shape, "RoundedRectangle", { strokeWidth: 1}, { fill: "white"}),// new go.Binding("fill", "color")
$(go.TextBlock,
{ margin: 20 }, // some room around the text
// TextBlock.text is bound to Node.data.key
new go.Binding("text", "key"))
);
var nodeDataArray = <?php echo '[' . implode(', ', $nodeListTwo) . ']' ?>
var linkDataArray = <?php echo '[' . implode(', ', $linesFamily) . ']' ?>
myDiagram.model = new go.GraphLinksModel(nodeDataArray, linkDataArray);
}
</script>
OK. it works now with the tags. thks.
By the way … I have already solved the Problem (as you can see the content of nodeDataArray and linkDataArray) BUT now I was wondering how i can display the result so that the arrows couldn’t cross others Node? (see picture)
Thanks for replying. Well, That picture attests that I have arleady read (may be not well!? that is why I’m asking Help?) those links you sent and displayed using GraphObject.make . My question is about arrows not the diagram (Diagram.layout)itself. Thanks for your time
Normally the first priority is to arrange the nodes so that they make sense to the user. That usually results in limited cross-overs of links over nodes and links across links. That’s why I first emphasized using the right Layout.