treemap limit 42
This commit is contained in:
@@ -27,6 +27,11 @@ function hex2rgb($color){
|
||||
return $rgb;
|
||||
}
|
||||
|
||||
function tri($a, $b) {
|
||||
if ($a['value'] == $b['value']) return 0;
|
||||
return ($a['value'] < $b['value']) ? 1 : -1;
|
||||
}
|
||||
|
||||
class topisto_treemap
|
||||
{
|
||||
private static function getRGB($methode, $gradient, $factor)
|
||||
@@ -75,6 +80,19 @@ class topisto_treemap
|
||||
|
||||
$data = blockchain::getTransactionData($the_block, $type);
|
||||
|
||||
usort($data, 'tri');
|
||||
|
||||
$n=0;
|
||||
$i=count($data)-1;
|
||||
while($i>41) $n+=$data[$i--]['value'];
|
||||
$n=intval(round(($n * 1.0) / count($data)));
|
||||
|
||||
$data = array_slice($data, 0, 42);
|
||||
$data[] = ["hash" => "0000000000000000000000000000000000000000000000000000000000000000", "value" => $n];
|
||||
|
||||
usort($data, 'tri');
|
||||
|
||||
|
||||
$vBgColor = imagecolorallocate($vImage, 10, 10, 10);
|
||||
imagefilledrectangle($vImage, $x, $y, $x+$width, $y+$height, $vBgColor);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user