I have successfully created a D3 force directive graph using plain JavaScript.
If you want to see the working D3 graph, click on this link.
Now my goal is to fetch data from a service and display the graph in AngularJS. I am wondering how I can turn this into a directive. Any examples or guidance would be highly appreciated!
To retrieve the data from the service, I have set up a controller with the following code:
$scope.buildchart = function(widget) {
var w2 = new Worker("scripts/webworkers/bigQueryWorker.js");
w2.postMessage($scope.selectedClass + ","
+ $rootScope.hierarchystring.toString()
+ "," + "Hierarchy" + "," + Digin_Engine_API);
w2.addEventListener('message', function(event) {
hierarchyRetrieved(event);
});
function hierarchyRetrieved(event) {
var obj = JSON.parse(event.data);
console.log("Hierarchy data is");
console.log(JSON.stringify(obj));
};
};
I'm trying to figure out if there's a way for me to access this data within the mentioned function.
function loadImage() {}