arnaucube
arnaucube/goBlockchainDataAnalysisPublic Self-hosted repository
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
14        $scope.options = {
15            chart: '#sankeyChart',
16            width: 960,
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            $http.get(urlapi + 'address/sankey/' + address.id)
40                .then(function(data, status, headers, config) {
41                    console.log('data success');
42                    console.log(data);
43                    $scope.data.nodes = data.data.nodes;
44                    $scope.data.links = data.data.links;
45                    console.log($scope.data);
46                    let chart = new d3.sankeyChart(data.data, $scope.options);
47                    //$scope.data = data.data;
48                }, function(data, status, headers, config) {
49                    console.log('data error');
50                });
51        };
52    });