Hi Long,
You could just write a JSON file onto your web server and then use an Ajax call in your js to get the JSON into a js variable. For example (assuming use of JQuery):
var json = null;
var fd = new $jit.ForceDirected({...
$.ajax({
type: 'GET',
url: '/script-to-get-JSON-string.php,
dataType: 'json',
async: false,
success: function(data)
{
json = data;
},
error: function(XMLHttpRequest, textStatus, errorThrown)
{
alert('error obtaining data from server');
return;
}
});
fd.loadJSON(json);
fd.computeIncremental({
iter: 5,
property: 'end',
onComplete: function(){
fd.animate({
modes: ['linear'],
transition: $jit.Trans.Elastic.easeOut,
duration: 5000
});
}
});
You could also use jQuery's getJSON call if easier (see
http://api.jquery.com/jQuery.getJSON/)
Scott.