|
|
<!DOCTYPE html> |
<!DOCTYPE html> |
<html xmlns="http://www.w3.org/1999/xhtml"> |
<html xmlns="http://www.w3.org/1999/xhtml"> |
<head> |
<head> |
<meta charset="UTF-8"/> |
<meta charset="UTF-8"/> |
<title>Minimal BubbleTree Demo</title> |
<title>Minimal BubbleTree Demo</title> |
<script type="text/javascript" src="lib/bubbletree/lib/jquery-1.5.2.min.js"></script> |
<script type="text/javascript" src="lib/bubbletree/lib/jquery-1.5.2.min.js"></script> |
<script type="text/javascript" src="lib/bubbletree/lib/jquery.history.js"></script> |
<script type="text/javascript" src="lib/bubbletree/lib/jquery.history.js"></script> |
<script type="text/javascript" src="lib/bubbletree/lib/raphael.js"></script> |
<script type="text/javascript" src="lib/bubbletree/lib/raphael.js"></script> |
<script type="text/javascript" src="lib/bubbletree/lib/vis4.js"></script> |
<script type="text/javascript" src="lib/bubbletree/lib/vis4.js"></script> |
<script type="text/javascript" src="lib/bubbletree/lib/Tween.js"></script> |
<script type="text/javascript" src="lib/bubbletree/lib/Tween.js"></script> |
<script type="text/javascript" src="lib/bubbletree/build/bubbletree.js"></script> |
<script type="text/javascript" src="lib/bubbletree/build/bubbletree.js"></script> |
<link rel="stylesheet" type="text/css" href="lib/bubbletree/build/bubbletree.css" /> |
<link rel="stylesheet" type="text/css" href="lib/bubbletree/build/bubbletree.css" /> |
<script type="text/javascript" src="lib/bubbletree/styles/cofog.js"></script> |
<script type="text/javascript" src="lib/bubbletree/styles/cofog.js"></script> |
|
|
|
|
<script type="text/javascript"> |
<script type="text/javascript"> |
|
|
$(function() { |
$(function() { |
<?php |
<?php |
include_once ("lib/common.inc.php"); |
include_once ("lib/common.inc.php"); |
|
|
|
include("lib/Color.php"); |
|
$color = new Lux_Color(); |
|
|
|
|
$unspscresult = mysql_query("select * from UNSPSCcategories;"); |
$unspscresult = mysql_query("select * from UNSPSCcategories;"); |
while ($row = mysql_fetch_assoc($unspscresult)) { |
while ($row = mysql_fetch_assoc($unspscresult)) { |
$unspsc[$row['UNSPSC']] = $row['Title']; |
$unspsc[$row['UNSPSC']] = $row['Title']; |
} |
} |
$total = 0; |
$total = 0; |
|
$cats = 0; |
$catsresult = mysql_query("SELECT LEFT( categoryUNSPSC, 1 ) as cat , |
$catsresult = mysql_query("SELECT LEFT( categoryUNSPSC, 1 ) as cat , |
SUM( value ) as value |
SUM( value ) as value |
FROM `contractnotice` |
FROM `contractnotice` |
WHERE childCN = 0 |
WHERE childCN = 0 |
GROUP BY cat ;"); |
GROUP BY cat ;"); |
$nodes = Array(); |
$nodes = Array(); |
while ($row = mysql_fetch_assoc($catsresult)) { |
while ($row = mysql_fetch_assoc($catsresult)) { |
|
$cats++; |
|
$catColor = $color->hsl2hex(Array($cats/10, .7, .5)); |
$catName = $unspsc[$row['cat'] . "0000000"] . $row['cat']; |
$catName = $unspsc[$row['cat'] . "0000000"] . $row['cat']; |
if ($row['cat'] == "") $catName = "null"; |
if ($row['cat'] == "") $catName = "null"; |
$subnodes = Array(); |
$subnodes = Array(); |
$cattwosresult = mysql_query("SELECT LEFT( categoryUNSPSC, 2 ) as cat , |
$cattwosresult = mysql_query("SELECT LEFT( categoryUNSPSC, 2 ) as cat , |
SUM( value ) as value |
SUM( value ) as value |
FROM `contractnotice` |
FROM `contractnotice` |
WHERE childCN = 0 and LEFT( categoryUNSPSC, 1 ) = '{$row['cat']}' |
WHERE childCN = 0 and LEFT( categoryUNSPSC, 1 ) = '{$row['cat']}' |
GROUP BY cat ;"); |
GROUP BY cat ;"); |
while ($tworow = mysql_fetch_assoc($cattwosresult)) { |
while ($tworow = mysql_fetch_assoc($cattwosresult)) { |
$subcatName = $unspsc[$tworow['cat'] . "000000"] . $tworow['cat']; |
$subcatName = $unspsc[$tworow['cat'] . "000000"] . $tworow['cat']; |
if ($tworow['cat'] == "") $subcatName = "null"; |
if ($tworow['cat'] == "") $subcatName = "null"; |
$subsubnodes = Array(); |
$subsubnodes = Array(); |
$catthreesresult = mysql_query("SELECT LEFT( categoryUNSPSC, 3 ) as cat , |
$catthreesresult = mysql_query("SELECT LEFT( categoryUNSPSC, 3 ) as cat , |
SUM( value ) as value |
SUM( value ) as value |
FROM `contractnotice` |
FROM `contractnotice` |
WHERE childCN = 0 and LEFT( categoryUNSPSC, 2 ) = '{$tworow['cat']}' |
WHERE childCN = 0 and LEFT( categoryUNSPSC, 2 ) = '{$tworow['cat']}' |
GROUP BY cat ;"); |
GROUP BY cat ;"); |
|
$subCatColor = $color->hsl2hex(Array($cats/10, rand(1,10)/10, .5)); |
while ($threerow = mysql_fetch_assoc($catthreesresult)) { |
while ($threerow = mysql_fetch_assoc($catthreesresult)) { |
$subsubcatName = $unspsc[$threerow['cat'] . "00000"] . $threerow['cat']; |
$subsubcatName = $unspsc[$threerow['cat'] . "00000"] . $threerow['cat']; |
if ($threerow['cat'] == "") $subsubcatName = "null"; |
if ($threerow['cat'] == "") $subsubcatName = "null"; |
$subsubnodes[] = Array( |
$subsubnodes[] = Array( |
"label" => $subsubcatName, |
"label" => $subsubcatName, |
"amount" => $threerow['value'], |
"amount" => $threerow['value'], |
"color" => "#000000" |
"color" => "#".$subCatColor |
); |
); |
} |
} |
$subnodes[] = Array( |
$subnodes[] = Array( |
"label" => $subcatName, |
"label" => $subcatName, |
"amount" => $tworow['value'], |
"amount" => $tworow['value'], |
"color" => "#000000", |
"color" => "#".$subCatColor, |
"children" => $subsubnodes |
"children" => $subsubnodes |
); |
); |
} |
} |
$nodes[] = Array( |
$nodes[] = Array( |
"label" => $catName, |
"label" => $catName, |
"amount" => $row['value'], |
"amount" => $row['value'], |
"color" => "#000000", |
"color" => "#".$catColor, |
"children" => $subnodes |
"children" => $subnodes |
); |
); |
$total+= $row['value']; |
$total+= $row['value']; |
} |
} |
$data = Array( |
$data = Array( |
"label" => "Australian Federal Government Contract Spending", |
"label" => "Australian Federal Government Contract Spending", |
"amount" => $total, |
"amount" => $total, |
"color" => "#000000", |
"color" => "#000000", |
"children" => $nodes |
"children" => $nodes |
); |
); |
echo "var data =eval('('+'" . json_encode($data) . "'+')');"; |
echo "var data =eval('('+'" . json_encode($data) . "'+')');"; |
?> |
?> |
|
|
new BubbleTree({ |
new BubbleTree({ |
data: data, |
data: data, |
container: '.bubbletree' |
container: '.bubbletree' |
}); |
}); |
|
|
|
|
}); |
}); |
|
|
</script> |
</script> |
</head> |
</head> |
<body> |
<body> |
<div class="bubbletree-wrapper"> |
<div class="bubbletree-wrapper"> |
<div class="bubbletree"></div> |
<div class="bubbletree"></div> |
</div> |
</div> |
</body> |
</body> |
</html> |
</html> |
|
|