Server side image creation , load datajson dynamically

Hi,

I went through your link - http://gojs.net/latest/intro/serverSideImages.html . I am using phantom js and the image is rendering for me on the server side.

I am not able to give nodedataarray , linkdataarray as arguments to the createImage.js

In your example you have given inline as

var nodeDataArray = [
{ key: “Alpha”, color: “lightblue” },
{ key: “Beta”, color: “orange” },
{ key: “Gamma”, color: “lightgreen” },
{ key: “Delta”, color: “pink” }
];
var linkDataArray = [
{ from: “Alpha”, to: “Beta” },
{ from: “Alpha”, to: “Gamma” },
{ from: “Beta”, to: “Beta” },
{ from: “Gamma”, to: “Delta” },
{ from: “Delta”, to: “Alpha” }
];

i want to replace this with

nodeDataArray = JSON.parse(system.args[1]);
linkDataArray = JSON.parse(system.args[2]);

This will let me call the createImage.js as

phantomjs createImage.js nodedataarrayjson linkdataarrayjson

it seems the function page.evaluate is sandboxed and doesnt let me use system arguments inside the function. Could you point me on the right direction to do this ?

Sorry, but I really don’t know PhantomJS, even though I created the projects/phantom-circuit demo.

Maybe this answers your question: http://phantomjs.org/api/system/property/args.html

Sorry but it doesnt help , probably the person who wrote http://gojs.net/latest/intro/serverSideImages.html could answer this.

Thanks for the effort

Hi , found a fix for this.

you can load the phantomjs arguments as content of the page you are creating

page.content = ‘

’+system.args[1]+’
';

then we inside the page.evaluate function we can do this

page.evaluate(function(){

var nodedataarray = JSON.parse(document.getElementById(‘data’).INNERHTML);
});