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