<?php |
<?php |
include_once("../lib/common.inc.php"); |
include_once("../lib/common.inc.php"); |
|
echo '<style> |
|
div { |
|
padding: 5px; |
|
display: inline-block; |
|
} |
|
</style>'; |
// http://www.herethere.net/~samson/php/color_gradient/color_gradient_generator.php.txt |
// http://www.herethere.net/~samson/php/color_gradient/color_gradient_generator.php.txt |
// return the interpolated value between pBegin and pEnd |
// return the interpolated value between pBegin and pEnd |
function interpolate($pBegin, $pEnd, $pStep, $pMax) |
function interpolate($pBegin, $pEnd, $pStep, $pMax) |
{ |
{ |
if ($pBegin < $pEnd) { |
if ($pBegin < $pEnd) { |
return (($pEnd - $pBegin) * ($pStep / $pMax)) + $pBegin; |
return (($pEnd - $pBegin) * ($pStep / $pMax)) + $pBegin; |
} |
} |
else { |
else { |
return (($pBegin - $pEnd) * (1 - ($pStep / $pMax))) + $pEnd; |
return (($pBegin - $pEnd) * (1 - ($pStep / $pMax))) + $pEnd; |
} |
} |
} |
} |
function Gradient($HexFrom, $HexTo, $ColorSteps) |
function Gradient($HexFrom, $HexTo, $ColorSteps) |
{ |
{ |
$theColorBegin = hexdec($HexFrom); |
$theColorBegin = hexdec($HexFrom); |
$theColorEnd = hexdec($HexTo); |
$theColorEnd = hexdec($HexTo); |
$theNumSteps = intval($ColorSteps); |
$theNumSteps = intval($ColorSteps); |
$theR0 = ($theColorBegin & 0xff0000) >> 16; |
$theR0 = ($theColorBegin & 0xff0000) >> 16; |
$theG0 = ($theColorBegin & 0x00ff00) >> 8; |
$theG0 = ($theColorBegin & 0x00ff00) >> 8; |
$theB0 = ($theColorBegin & 0x0000ff) >> 0; |
$theB0 = ($theColorBegin & 0x0000ff) >> 0; |
$theR1 = ($theColorEnd & 0xff0000) >> 16; |
$theR1 = ($theColorEnd & 0xff0000) >> 16; |
$theG1 = ($theColorEnd & 0x00ff00) >> 8; |
$theG1 = ($theColorEnd & 0x00ff00) >> 8; |
$theB1 = ($theColorEnd & 0x0000ff) >> 0; |
$theB1 = ($theColorEnd & 0x0000ff) >> 0; |
$GradientColors = array(); |
$GradientColors = array(); |
// generate gradient swathe now |
// generate gradient swathe now |
for ($i = 0; $i <= $theNumSteps; $i++) { |
for ($i = 0; $i <= $theNumSteps; $i++) { |
$theR = interpolate($theR0, $theR1, $i, $theNumSteps); |
$theR = interpolate($theR0, $theR1, $i, $theNumSteps); |
$theG = interpolate($theG0, $theG1, $i, $theNumSteps); |
$theG = interpolate($theG0, $theG1, $i, $theNumSteps); |
$theB = interpolate($theB0, $theB1, $i, $theNumSteps); |
$theB = interpolate($theB0, $theB1, $i, $theNumSteps); |
$theVal = ((($theR << 8) | $theG) << 8) | $theB; |
$theVal = ((($theR << 8) | $theG) << 8) | $theB; |
$GradientColors[] = sprintf("%06X", $theVal); |
$GradientColors[] = sprintf("%06X", $theVal); |
} |
} |
return $GradientColors; |
return $GradientColors; |
} |
} |
$Gradients = Gradient("66FF00" , "FF0000" , 10); |
$Gradients = Gradient("66FF00" , "FF0000" , 10); |
|
|
$query = "select max(sum) from (SELECT sum(heuristic_value) |
$query = 'select max(sum) from (SELECT sum(heuristic_value) |
as sum FROM heuristic_results group by CNID) as a"; |
as sum FROM heuristic_results group by "CNID") as a'; |
$result = mysql_query($query); |
$result = $conn->query($query); |
$r = mysql_fetch_array($result, MYSQL_BOTH); |
$r = $result->fetch(); |
$maxVal = $r[0]; |
$maxVal = $r[0]; |
|
|
$query = "SELECT sum(heuristic_value) as sum, CNID |
$query = 'SELECT sum(heuristic_value) as sum, "CNID" |
FROM `heuristic_results` group by CNID order by sum DESC LIMIT 30"; |
FROM heuristic_results group by "CNID" order by sum DESC LIMIT 300'; |
$result = mysql_query($query); |
$result = $conn->query($query); |
if (!$result) echo mysql_error().$query; |
foreach ($result->fetchAll() as $r) { |
while ($r = mysql_fetch_array($result, MYSQL_BOTH)) { |
echo '<div style="background: #'.$Gradients[floor(($r['sum']/$maxVal) * 10)].';">'; |
echo '<span style="background: #'.$Gradients[floor(($r['sum']/$maxVal) * 10)].'; padding: 5px;">'; |
|
echo '<a title="'.$r['sum'].'" href="../displayContract.php?CNID='.$r['CNID'].'">X</a>'; |
echo '<a title="'.$r['sum'].'" href="../displayContract.php?CNID='.$r['CNID'].'">X</a>'; |
echo "</span>"; |
echo "</div>"; |
} |
} |
|
|
?> |
?> |