Skip to content

Commit

Permalink
fixed pie chart to show high rank miners first
Browse files Browse the repository at this point in the history
 * hide low rank miners
 * adjust height for mobile
  • Loading branch information
hackmod committed May 11, 2018
1 parent b3110f2 commit 8cd9126
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions public/js/controllers/StatsController.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ angular.module('BlocksApp').controller('StatsController', function($stateParams,
var radius;
if (window.innerWidth < 800) {
radius = Math.min(width, 450) * 0.6;
d3.select(chartid).attr("height", '700px');
} else {
radius = 450 * 0.5;
}
Expand All @@ -96,6 +95,14 @@ angular.module('BlocksApp').controller('StatsController', function($stateParams,
var legendRectSize = (radius * 0.05);
var legendSpacing = radius * 0.02;

var maxMiners = 23;
if (window.innerWidth < 800) {
var legendHeight = legendRectSize + legendSpacing;
var fixHeight = Math.min(maxMiners, dataset.length) * legendHeight;
fixHeight = height + parseInt(fixHeight) + 50;
d3.select(chartid).attr("height", fixHeight + 'px');
}

var div = d3.select("body").append("div").attr("class", "toolTip");

// fix for mobile layout
Expand Down Expand Up @@ -167,17 +174,22 @@ angular.module('BlocksApp').controller('StatsController', function($stateParams,

//console.log(data.length);

var legendHeight = Math.min(maxMiners, color.domain().length);
var legend = svg.selectAll('.legend')
//.data(color.domain())
.data(data)
.enter()
.append('g')
.attr('class', 'legend')
.attr('transform', function (d, i) {
if (data.length - i >= maxMiners) {
// show maxMiners, hide remains
return 'translate(2000,0)';
}
var height = legendRectSize + legendSpacing;
var offset = height * color.domain().length / 2;
var offset = height * legendHeight / 2;
var horz = -3 * legendRectSize;
var vert = i * height;
var vert = (data.length - i) * height;
var tx, ty;
if (window.innerWidth > 800) {
tx = 250;
Expand Down

0 comments on commit 8cd9126

Please sign in to comment.