예제 #1
0
        }
    }
    // Beautify the distribution by appliying a logarithm : )
    foreach ($data as &$langLink) {
        $langLink['num_ab'] = round(log($langLink['num_ab']) * 1000);
        $langLink['num_ba'] = round(log($langLink['num_ba']) * 1000);
    }
    // sorting the array by the sum of the incomes and outcomes:
    function sortByEntrySum($a, $b)
    {
        return $a['num_ab'] + $a['num_ba'] - ($b['num_ab'] + $b['num_ba']);
    }
    usort($data, "sortByEntrySum");
    $data = array_reverse($data);
    $data = array_values($data);
    $data = link_top($ulangs, $data);
    // Append the colors to the result data
    $data[] = $colors;
    // echoing it as json formatted string:
    echo json_encode($data);
    mysql_close($connection);
}
// the colour function from the old document:
function hashColor($str)
{
    $h = "";
    for ($i = 0; $i < 4; ++$i) {
        $h .= ord(strtoupper(substr($str, $i)));
    }
    $h = dechex($h);
    while (strlen($h) < 6) {
예제 #2
0
        }
    }
    while ($l = current($lmap)) {
        $arr = explode("|", key($lmap));
        $lmap[key($lmap)] = $arr[0] . "|" . $arr[1] . "|" . $l . "|" . hashColor($arr[1]);
        next($lmap);
    }
    function sortIt($a, $b)
    {
        $a = explode("|", $a);
        $b = explode("|", $b);
        return $a[2] - $b[2];
    }
    usort($lmap, "sortIt");
    $lmap = array_reverse($lmap);
    $lmap = link_top($ulangs, $lmap);
    $echo = "<table>";
    for ($i = 0; $i < count($lmap); ++$i) {
        $data = explode("|", $lmap[$i]);
        $echo .= "<tr><td>" . $data[0] . "</td><td>" . $data[1] . "</td><td><span style='color:" . $data[3] . ";'>" . $data[2] . "</span></td></tr>";
    }
    $echo .= "</table>";
    echo $echo;
    mysql_close($connection);
}
function hashColor($str)
{
    return "#000000";
    $h = "";
    for ($i = 0; $i < 4; ++$i) {
        $h .= ord(strtoupper(substr($str, $i)));