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.

52 lines
1.8 KiB

  1. 'use strict';
  2. angular.module('app.sankey', ['ngRoute', 'ngSankey'])
  3. .config(['$routeProvider', function($routeProvider) {
  4. $routeProvider.when('/sankey', {
  5. templateUrl: 'views/sankey/sankey.html',
  6. controller: 'SankeyCtrl'
  7. });
  8. }])
  9. .controller('SankeyCtrl', function($scope, $http, $routeParams) {
  10. $scope.options = {
  11. chart: '#sankeyChart',
  12. width: 960,
  13. height: 500,
  14. margin: {top: 1, right: 1, bottom: 6, left: 1},
  15. node: {width: 15, padding :10, showValue: false},
  16. value: {format: ',.0f', unit : ''},
  17. dynamicLinkColor: true,
  18. trafficInLinks: true
  19. };
  20. $scope.data={
  21. nodes: [],
  22. links: []
  23. };
  24. $http.get(urlapi + 'alladdresses')
  25. .then(function(data, status, headers, config) {
  26. console.log('data success');
  27. console.log(data);
  28. $scope.addresses = data.data;
  29. }, function(data, status, headers, config) {
  30. console.log('data error');
  31. });
  32. $scope.getAddressSankey = function(address) {
  33. console.log(address);
  34. $http.get(urlapi + 'address/sankey/' + address.id)
  35. .then(function(data, status, headers, config) {
  36. console.log('data success');
  37. console.log(data);
  38. $scope.data.nodes = data.data.nodes;
  39. $scope.data.links = data.data.links;
  40. console.log($scope.data);
  41. let chart = new d3.sankeyChart(data.data, $scope.options);
  42. //$scope.data = data.data;
  43. }, function(data, status, headers, config) {
  44. console.log('data error');
  45. });
  46. };
  47. });