improved peer propagation chart

This commit is contained in:
cubedro 2015-04-06 17:56:48 +03:00
parent 7b172df9dd
commit b173cbbcac
3 changed files with 26 additions and 23 deletions

View File

@ -31,7 +31,7 @@ var Node = function Node(data)
uptime: 0, uptime: 0,
lastUpdate: 0 lastUpdate: 0
}; };
this.blockHistory = []; this.blockHistory = Array(MAX_HISTORY);
this.uptime = { this.uptime = {
started: null, started: null,
history: [] history: []

View File

@ -240,8 +240,7 @@ table td {
} }
.th-peerPropagationChart { .th-peerPropagationChart {
text-align: center; width: 140px;
width: 125px;
} }
@media only screen and (max-width: 639px) { @media only screen and (max-width: 639px) {

View File

@ -106,23 +106,7 @@ function StatsCtrl($scope, $filter, socket, _, toastr) {
var index = findIndex({id: data.id}); var index = findIndex({id: data.id});
$scope.nodes[index].stats = data.stats; $scope.nodes[index].stats = data.stats;
$scope.nodes[index].history = data.history; $scope.nodes[index].history = data.history;
$scope.nodes[index].propagation = _.map(data.history, function(block) { makePeerPropagationChart(index);
return block.propagation;
});
jQuery('.' + data.id).sparkline($scope.nodes[index].propagation, {
type: 'bar',
height: 18,
barWidth : 2,
barSpacing : 1,
tooltipSuffix: 'ms',
colorMap: jQuery.range_map({
'0:1': '#10a0de',
'1:5000': '#7bcc3a',
'5001:12000': '#FFD162',
'12001:20000': '#ff8a00',
'20001:': '#F74B4B'
})
});
break; break;
case "info": case "info":
@ -151,6 +135,28 @@ function StatsCtrl($scope, $filter, socket, _, toastr) {
return _.findIndex($scope.nodes, search); return _.findIndex($scope.nodes, search);
} }
function makePeerPropagationChart(index)
{
$scope.nodes[index].propagation = _.map($scope.nodes[index].history, function(block) {
return block.propagation;
});
jQuery('.' + $scope.nodes[index].id).sparkline($scope.nodes[index].propagation, {
type: 'bar',
height: 18,
barWidth : 2,
barSpacing : 1,
tooltipSuffix: 'ms',
colorMap: jQuery.range_map({
'0:1': '#10a0de',
'1:5000': '#7bcc3a',
'5001:12000': '#FFD162',
'12001:20000': '#ff8a00',
'20001:': '#F74B4B'
})
});
}
function addNewNode(data) function addNewNode(data)
{ {
var index = findIndex({id: data.id}); var index = findIndex({id: data.id});
@ -163,9 +169,7 @@ function StatsCtrl($scope, $filter, socket, _, toastr) {
$scope.nodes[index] = data; $scope.nodes[index] = data;
$scope.nodes[index].history = data.history; $scope.nodes[index].history = data.history;
$scope.nodes[index].propagation = _.map(data.history, function(block) { makePeerPropagationChart(index);
return block.propagation;
});
return false; return false;
} }