You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
1.3 KiB

  1. var urlapi = "http://127.0.0.1:3014/";
  2. //var urlapi = document.location.href + "api/";
  3. console.log(urlapi);
  4. var app = angular.module("webApp", ['chart.js']);
  5. var nodes, edges, container;
  6. var options = {
  7. layout:{
  8. improvedLayout: false
  9. }/*,
  10. physics:{
  11. //stabilization: false,
  12. // enabled: false
  13. }*/
  14. };
  15. app.controller("webCtrl", function($scope, $http) {
  16. //chart
  17. $scope.labels=[];
  18. $scope.data=[];
  19. $scope.nodes=[];
  20. $scope.edges=[];
  21. $http.get(urlapi + 'map')
  22. .then(function (data) {
  23. console.log('data success');
  24. console.log(data); // for browser console
  25. $scope.nodes=data.data.Nodes;
  26. $scope.edges=data.data.Edges;
  27. console.log($scope.nodes);
  28. console.log($scope.edges);
  29. $scope.showMap();
  30. //alert("Ara mateix es mostren (entre persones i tweets): " + nodes.length + " nodes.");
  31. //$scope.refreshChart();
  32. }, function(data){
  33. console.log('data error');
  34. console.log(status);
  35. console.log(data);
  36. });
  37. $scope.showMap=function(){
  38. var nodes = $scope.nodes;
  39. var edges = $scope.edges;
  40. container = document.getElementById('mynetwork');
  41. var data = {
  42. nodes: nodes,
  43. edges: edges
  44. };
  45. var network = new vis.Network(container, data, options);
  46. toastr.info("map completed");
  47. };
  48. });