Merge pull request #124 from cubedro/develop

Changed histogram to 10s
This commit is contained in:
Marian OANCΞA 2015-05-13 03:08:36 +03:00
commit 0536a10aea
4 changed files with 12 additions and 14 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -5,7 +5,7 @@ var MAX_HISTORY = 1000;
var MAX_PEER_PROPAGATION = 36; var MAX_PEER_PROPAGATION = 36;
var MIN_PROPAGATION_RANGE = 0; var MIN_PROPAGATION_RANGE = 0;
var MAX_PROPAGATION_RANGE = 20000; var MAX_PROPAGATION_RANGE = 10000;
var MAX_UNCLES_PER_BIN = 25; var MAX_UNCLES_PER_BIN = 25;
var MAX_BINS = 40; var MAX_BINS = 40;
@ -188,7 +188,7 @@ History.prototype.getBlockPropagation = function()
{ {
_.forEach(n.propagTimes, function (p, i) _.forEach(n.propagTimes, function (p, i)
{ {
var prop = _.result(p, 'propagation', -1); var prop = Math.min(MAX_PROPAGATION_RANGE, _.result(p, 'propagation', -1));
if(prop >= 0) if(prop >= 0)
propagation.push(prop); propagation.push(prop);
@ -200,13 +200,10 @@ History.prototype.getBlockPropagation = function()
var avgPropagation = Math.round( _.sum(propagation) / propagation.length ); var avgPropagation = Math.round( _.sum(propagation) / propagation.length );
} }
var x = d3.scale.linear()
.domain([ MIN_PROPAGATION_RANGE, MAX_PROPAGATION_RANGE ])
.interpolate( d3.interpolateRound );
var data = d3.layout.histogram() var data = d3.layout.histogram()
.frequency( false ) .frequency( false )
.bins( x.ticks(MAX_BINS) ) .range([ MIN_PROPAGATION_RANGE, MAX_PROPAGATION_RANGE ])
.bins( MAX_BINS )
( propagation ); ( propagation );
var freqCum = 0; var freqCum = 0;

View File

@ -127,7 +127,7 @@ angular.module('netStatsApp.directives', []).
var TICKS = 40; var TICKS = 40;
var x = d3.scale.linear() var x = d3.scale.linear()
.domain([0, 20000]) .domain([0, 10000])
.rangeRound([0, width]) .rangeRound([0, width])
.interpolate(d3.interpolateRound); .interpolate(d3.interpolateRound);
@ -136,8 +136,8 @@ angular.module('netStatsApp.directives', []).
.interpolate(d3.interpolateRound); .interpolate(d3.interpolateRound);
var color = d3.scale.linear() var color = d3.scale.linear()
.domain([1000, 3000, 7000, 10000, 20000]) .domain([1000, 3000, 7000, 10000])
.range(["#7bcc3a", "#FFD162", "#ff8a00", "#F74B4B", "#CC0000"]); .range(["#7bcc3a", "#FFD162", "#ff8a00", "#F74B4B"]);
var xAxis = d3.svg.axis() var xAxis = d3.svg.axis()
.scale(x) .scale(x)
@ -214,8 +214,8 @@ angular.module('netStatsApp.directives', []).
bar.insert("rect") bar.insert("rect")
.attr("class", "bar") .attr("class", "bar")
.attr("y", function(d) { return y(d.y); }) .attr("y", function(d) { return y(d.y); })
.attr("rx", 1.2) .attr("rx", 1)
.attr("ry", 1.2) .attr("ry", 1)
.attr("fill", function(d) { return color(d.x); }) .attr("fill", function(d) { return color(d.x); })
.attr("width", x(data[0].dx + data[0].x) - x(data[0].x) - 1) .attr("width", x(data[0].dx + data[0].x) - x(data[0].x) - 1)
.attr("height", function(d) { return height - y(d.y) + 1; }); .attr("height", function(d) { return height - y(d.y) + 1; });
@ -236,6 +236,7 @@ angular.module('netStatsApp.directives', []).
scope.$watch('data', function() { scope.$watch('data', function() {
if(scope.data.length > 0) { if(scope.data.length > 0) {
alert(scope.data);
scope.init(); scope.init();
} }
}, true); }, true);