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.

51 lines
1.8 KiB

  1. 'use strict';
  2. angular.module('app.block', ['ngRoute', 'ngSankey'])
  3. .config(['$routeProvider', function($routeProvider) {
  4. $routeProvider.when('/block/:height', {
  5. templateUrl: 'views/block/block.html',
  6. controller: 'BlockCtrl'
  7. });
  8. }])
  9. .controller('BlockCtrl', function($scope, $http, $routeParams) {
  10. $scope.block = {};
  11. $http.get(urlapi + 'block/' + $routeParams.height)
  12. .then(function(data, status, headers, config) {
  13. console.log(data);
  14. $scope.block = data.data;
  15. }, function(data, status, headers, config) {
  16. console.log('data error');
  17. });
  18. //Sankey
  19. $scope.options = {
  20. chart: '#sankeyChart',
  21. width: 700,
  22. height: 280,
  23. margin: {top: 1, right: 1, bottom: 6, left: 1},
  24. node: {width: 15, padding :10, showValue: false},
  25. value: {format: ',.0f', unit : ''},
  26. dynamicLinkColor: true,
  27. trafficInLinks: true
  28. };
  29. $scope.data={
  30. nodes: [],
  31. links: []
  32. };
  33. $http.get(urlapi + 'block/' + $routeParams.height + '/sankey')
  34. .then(function(data, status, headers, config) {
  35. console.log('data success');
  36. console.log(data);
  37. $scope.data.nodes = data.data.nodes;
  38. $scope.data.links = data.data.links;
  39. console.log($scope.data);
  40. d3.selectAll("svg > *").remove();
  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. });