I am working on producing a force directed layout (using d3.js http://bl.ocks.org/mbostock/raw/4062045/) on some data that I am pulling from a MS SQL server database. Currently I am generating the json file using a python script and then running it on the local server using python -m SimpleHTTPServer.
What I want to do is to create a link between my python script and the HTML such that when I type in the webaddress, the python script should run on the server side and generate the json file. During this I need to block the UI. When the file is generated, the graph should display itself on the screen. I can generate the graph and json files separately. Need to put them together with a blockui or progress bar(i think progress bar would be too much).
I am a noob to javascript and web development, kinda learning on the fly while creating my graph. Any guidance in this direction would be much appreciated.
Thanks,
Prateek
EDIT:
The snippet of the code as of now is as follows:
d3.json("json_data.json", function(error, graph)
{
var nodeMap = {};
graph.nodes.forEach(function(x) { nodeMap[x.name] = x; });
graph.links = graph.links.map(
function(x)
{
return {
source: nodeMap[x.source],
target: nodeMap[x.target],
value: x.value
};
});
force
.nodes(graph.nodes)
.links(graph.links)
.start();
This code I will put in under the success section of the ajax request. I want the script to send the ajax request for a min to see for the existence of the json_data.json file on the server and to display the spinning wheel while the file is created if the time runs out there is the control transfer to the error section of the request.
The json file is simply as:
nodes: {}
links: {} //without any children level of depth.