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