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