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

How to pass a php result into nodeDataArray and linkDataArray?

$
0
0

@mignoncharly wrote:

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.

<?php

$nodeList = array ("K", "I", "J", "L", "M", "X", "Z");
$linesList = array();

foreach($nodeList as $key){
    $linesList[] = "{key: \"{$key}\"&nbsp;}";
}

$nodeListTwo = implode(',<br>', $linesList);
echo $nodeListTwo;

?>

here ist the Output :

{key: "K" },
{key: "I" },
{key: "J" },
{key: "L" },
{key: "M" },
{key: "X" },
{key: "Z" }

I have used this line var nodeDataArray = JSON.parse( '<?php echo json_encode($nodeListTwo) ?>' ); to make sure

var nodeDataArray =
[
{key: "K" },
{key: "I" },
{key: "J" },
{key: "L" },
{key: "M" },
{key: "X" },
{key: "Z" }
]

but it doesn't work.

Or is there a way to fill var nodeDataArray and var linkDataArray dynamically ? because each letter comes from an (php) Array.

Thank

Posts: 4

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 6977

Latest Images

Trending Articles



Latest Images