More value heuristics
--- a/displayContract.php
+++ b/displayContract.php
@@ -28,9 +28,17 @@
echo "<br>";
}
}
-echo '<a href="https://www.tenders.gov.au/?event=public.advancedsearch.keyword&keyword=CN'.$_REQUEST['CNID'].'"> View original record @ tenders.gov.au</a>';
+echo '<br><a href="https://www.tenders.gov.au/?event=public.advancedsearch.keyword&keyword=CN'.$_REQUEST['CNID'].'"> View original record @ tenders.gov.au</a><br>';
mysql_free_result($result);
+
+$query = "SELECT * FROM `heuristic_results` where CNID = ".$_REQUEST['CNID'];
+$result = mysql_query($query);
+if (!$result) echo mysql_error().$query;
+while ($r = mysql_fetch_array($result, MYSQL_ASSOC)) {
+ echo "<b>{$r['heuristic_name']}</b>: {$r['heuristic_value']} (raw value: {$r['raw_value']}, mean: {$r['mean']}, stddev: {$r['stddev']})<br>";
+}
+
include_footer();
?>
--- a/heuristics/dateHeuristics.php
+++ b/heuristics/dateHeuristics.php
@@ -20,27 +20,32 @@
$averageContractPeriod;
function getAverageContractPeriod()
{
- global $averageContractPeriod;
+ global $averageContractPeriod, $stddevContractPeriod;
if (!$averageContractPeriod) {
- $query = "select AVG(dateDiff(contractEnd,contractStart)) from contractnotice";
- $result = mysql_query($query);
- $r = mysql_fetch_array($result, MYSQL_BOTH);
- $averageContractPeriod = $r[0];
+ getStddevAverageContractPeriod();
}
return $averageContractPeriod;
}
$stddevContractPeriod;
function getstddevContractPeriod()
{
- global $stddevContractPeriod;
+ global $averageContractPeriod, $stddevContractPeriod;
if (!$stddevContractPeriod) {
- $query = "select STDDEV(dateDiff(contractEnd,contractStart)) from contractnotice";
- $result = mysql_query($query);
- $r = mysql_fetch_array($result, MYSQL_BOTH);
- $stddevContractPeriod = $r[0];
+ getStddevAverageContractPeriod();
}
return $stddevContractPeriod;
}
+function getStddevAverageContractPeriod()
+{
+ global $averageContractPeriod, $stddevContractPeriod;
+ $query = "select AVG(dateDiff(contractEnd,contractStart)),stddev(dateDiff(contractEnd,contractStart)) from contractnotice";
+ $result = mysql_query($query);
+ $r = mysql_fetch_array($result, MYSQL_BOTH);
+ $averageContractPeriod = $r[0];
+ $stddevContractPeriod = $r[1];
+}
+
+
//Reported late, 45 days? A late contract is a dodgy contract except maybe for variations?
$heuristics["DATE_REPORTED_LATE"] = Array(
"description" => "Reported late, 45 days?"
@@ -70,10 +75,7 @@
{
global $averageDaysLate;
if (!$averageDaysLate) {
- $query = "select AVG(dateDiff(publishDate,contractStart)) from contractnotice";
- $result = mysql_query($query);
- $r = mysql_fetch_array($result, MYSQL_BOTH);
- $averageDaysLate = $r[0];
+ getDaysLate();
}
return $averageDaysLate;
}
@@ -82,11 +84,19 @@
{
global $stddevDaysLate;
if (!$stddevDaysLate) {
- $query = "select STDDEV(dateDiff(publishDate,contractStart)) from contractnotice";
- $result = mysql_query($query);
- $r = mysql_fetch_array($result, MYSQL_BOTH);
- $stddevDaysLate = $r[0];
+ getDaysLate();
}
return $stddevDaysLate;
}
+function getDaysLate() {
+
+ global $averageDaysLate,$stddevDaysLate;
+
+ $query = "select AVG(dateDiff(publishDate,contractStart)), STDDEV(dateDiff(publishDate,contractStart)) from contractnotice";
+ $result = mysql_query($query);
+ $r = mysql_fetch_array($result, MYSQL_BOTH);
+ $averageDaysLate = $r[0];
+ $stddevDaysLate = $r[1];
+
+}
?>
--- a/heuristics/heuristics.inc.php
+++ b/heuristics/heuristics.inc.php
@@ -1,20 +1,25 @@
<?php
- include_once("../lib/common.inc.php");
+include_once ("../lib/common.inc.php");
$heuristics = Array();
//each heuristic adds self to description array
include ("dateHeuristics.php");
-//include("historyHeuristics.php");
-//include("metadataHeuristics.php");
-//include("valueHeuristics.php");
-// method signature heuristic($contractNoticeAsArray);
+//include ("historyHeuristics.php");
+//include ("metadataHeuristics.php");
+//include ("valueHeuristics.php");
function runHeuristic($heuristicName, $cn)
{
- $hresults = call_user_func($heuristicName, $cn);
- if (!isset($hresults["heuristic_value"]) || !isset($hresults["raw_value"]) || !isset($hresults["mean"]) || !isset($hresults["stddev"])) {
- print_r($hresults);
- die("Missing field in heurtistic $heuristicName result");
- }
- $query = "insert into heuristic_results values('$heuristicName',
+ // check if already ran
+ $query = "select count(*) from heuristic_results where heuristic_name = '$heuristicName' and CNID = '{$CN['CNID']}";
+ $result = mysql_query($query);
+ $r = mysql_fetch_array($result);
+ if ($r[0] == 0) {
+ // if not, run now
+ $hresults = call_user_func($heuristicName, $cn);
+ if (!isset($hresults["heuristic_value"]) || !isset($hresults["raw_value"]) || !isset($hresults["mean"]) || !isset($hresults["stddev"])) {
+ print_r($hresults);
+ die("Missing field in heurtistic $heuristicName result");
+ }
+ $query = "insert into heuristic_results values('$heuristicName',
'{$hresults["heuristic_value"]}',
'{$hresults["raw_value"]}',
'{$hresults["mean"]}',
@@ -25,9 +30,10 @@
'{$cn["agencyABN"]}',
'{$cn["supplierID"]}'
)";
- // save value and cn data via sql
- $result = mysql_query($query);
- if ($result) echo "Saved $heuristicName for {$cn["CNID"]} <br>\n";
- elseif (strpos(mysql_error() , "Duplicate entry") === false) echo $hresults . " failed insert.<br>" . mysql_error() . " <br> $query <br><br>\n";
+ // save value and cn data via sql
+ $result = mysql_query($query);
+ if ($result) echo "Saved $heuristicName for {$cn["CNID"]} <br>\n";
+ elseif (strpos(mysql_error() , "Duplicate entry") === false) echo $hresults . " failed insert.<br>" . mysql_error() . " <br> $query <br><br>\n";
+ }
}
?>
--- a/heuristics/historyHeuristics.php
+++ b/heuristics/historyHeuristics.php
@@ -1,25 +1,126 @@
-<?php
- // "unusual for agency/supplier due to previous low number of transactions "
-$heuristics["HISTORY_LOW_TRANSACTIONS"] = Array(
- "description" => "unusual for agency/supplier due to previous low number of transactions "
+<?php
+$heuristics["HISTORY_LOW_TRANSACTIONS_AGENCY"] = Array(
+ "description" => "unusual for agency due to previous low number of transactions "
);
-function HISTORY_LOW_TRANSACTIONS($cn)
+function HISTORY_LOW_TRANSACTIONS_AGENCY($cn)
{
- $averageContractPeriod = getAverageContractPeriod();
- $diff = strtotime($cn['contractStart']) - strtotime($cn['publishDate']);
- $days = intval($diff / 24);
- return ($days > 45 ? 1 : 0);
+ $thisAgencyTransactions = getAgencyTransactions($cn['agencyName']);
+ $averageAgencyTransactions = getAverageAgencyTransactions();
+ $stddevAgencyTransactions = getstddevAgencyTransactions();
+ $diff = strtotime($cn['contractEnd']) - strtotime($cn['contractStart']);
+ $days = intval($diff / (60 * 60 * 24));
+ $value = abs($days - $averageAgencyTransactions) / $stddevAgencyTransactions;
+ return Array(
+ "heuristic_value" => $value,
+ "raw_value" => $days,
+ "mean" => $averageAgencyTransactions,
+ "stddev" => $stddevAgencyTransactions
+ );
}
- /* - unusual value for time of year
- - compare to all other records in last 2 weeks
- - ie. many large contracts in june so takes more to standout*/
-
- $heuristics["HISTORY_HIGH_VALUE_FOR_MONTH"] = Array(
- "description" => "unusual value for time of year");
-function HISTORY_HIGH_VALUE_FOR_MONTH($cn)
+$agencyTransactions = Array();
+function getAgencyTransactions($agencyName)
{
- $averageContractPeriod = getAverageContractPeriod();
- $diff = strtotime($cn['contractStart']) - strtotime($cn['publishDate']);
- $days = intval($diff / 24);
- return ($days > 45 ? 1 : 0);
+ global $agencyTransactions;
+ if (!$agencyTransactions[$agencyName]) {
+ $query = 'select count(*) from contractnotice where agencyName = "' . $agencyName . '"';
+ $result = mysql_query($query);
+ $r = mysql_fetch_array($result, MYSQL_BOTH);
+ $agencyTransactions[$agencyName] = $r[0];
+ }
+ return $agencyTransactions[$agencyName];
}
+$averageAgencyTransactions;
+function getAverageAgencyTransactions()
+{
+ global $averageAgencyTransactions;
+ if (!$averageAgencyTransactions) {
+ getStatsAgencyTransactions();
+ }
+ return $averageAgencyTransactions;
+}
+$stddevAgencyTransactions;
+function getstddevAgencyTransactions()
+{
+ global $stddevAgencyTransactions;
+ if (!$stddevAgencyTransactions) {
+ getStatsAgencyTransactions();
+ }
+ return $stddevAgencyTransactions;
+}
+function getStatsAgencyTransactions()
+{
+ global $averageAgencyTransactions, $stddevAgencyTransactions;
+ $query = "select avg(count), STDDEV(count) from (select count(*) as count
+ from contractnotice group by agencyName) as a;";
+ $result = mysql_query($query);
+ $r = mysql_fetch_array($result, MYSQL_BOTH);
+ $averageAgencyTransactions = $r[0];
+ $stddevAgencyTransactions = $r[1];
+}
+$heuristics["HISTORY_LOW_TRANSACTIONS_SUPPLIER"] = Array(
+ "description" => "unusual for supplier due to previous low number of transactions "
+);
+function HISTORY_LOW_TRANSACTIONS_SUPPLIER($cn)
+{
+ $thisSupplierTransactions = getSupplierTransactions($cn['supplierName'], $cn['supplierABN']);
+ $averageSupplierTransactions = getAverageSupplierTransactions();
+ $stddevSupplierTransactions = getstddevSupplierTransactions();
+ $diff = strtotime($cn['contractEnd']) - strtotime($cn['contractStart']);
+ $days = intval($diff / (60 * 60 * 24));
+ $value = abs($days - $averageSupplierTransactions) / $stddevSupplierTransactions;
+ return Array(
+ "heuristic_value" => $value,
+ "raw_value" => $days,
+ "mean" => $averageSupplierTransactions,
+ "stddev" => $stddevSupplierTransactions
+ );
+}
+$supplierTransactions = Array();
+function getSupplierTransactions($supplierName, $supplierABN)
+{
+ global $supplierTransactions;
+ if ($supplierABN != 0 && $supplierABN != "") {
+ if (!$supplierTransactions[$supplierABN]) {
+ $query = 'select count(*) from contractnotice where supplierABN = "' . $supplierABN . '"';
+ $result = mysql_query($query);
+ $r = mysql_fetch_array($result, MYSQL_BOTH);
+ $supplierTransactions[$supplierABN] = $r[0];
+ }
+ return $supplierTransactions[$supplierABN];
+ }
+ if (!$supplierTransactions[$supplierName]) {
+ $query = 'select count(*) from contractnotice where supplierName = "' . $supplierName . '"';
+ $result = mysql_query($query);
+ $r = mysql_fetch_array($result, MYSQL_BOTH);
+ $supplierTransactions[$supplierName] = $r[0];
+ }
+ return $supplierTransactions[$supplierName];
+}
+$averageSupplierTransactions;
+function getAverageSupplierTransactions()
+{
+ global $averageSupplierTransactions;
+ if (!$averageSupplierTransactions) {
+ getStatsSupplierTransactions();
+ }
+ return $averageSupplierTransactions;
+}
+$stddevSupplierTransactions;
+function getstddevSupplierTransactions()
+{
+ global $stddevSupplierTransactions;
+ if (!$stddevSupplierTransactions) {
+ getStatsSupplierTransactions();
+ }
+ return $stddevSupplierTransactions;
+}
+function getStatsSupplierTransactions()
+{
+ global $averageSupplierTransactions, $stddevSupplierTransactions;
+ $query = 'select avg(count), stddev(count) from (select IF(supplierABN != "",supplierABN,supplierName) as supplierID, count(*) as count from contractnotice group by supplierID) as a;';
+ $result = mysql_query($query);
+ $r = mysql_fetch_array($result, MYSQL_BOTH);
+ $averageSupplierTransactions = $r[0];
+ $stddevSupplierTransactions = $r[1];
+}
+
--- a/heuristics/metadataHeuristics.php
+++ b/heuristics/metadataHeuristics.php
@@ -1,12 +1,59 @@
<?php
- /*- duplicated description
- - most duplicated overall, most duplicated per agency/category/supplier etc. */
- $heuristics["METADATA_DUPLICATED_DESCRIPTION"] = Array(
- "description" => "unusual value for time of year");
+/* all
+ SELECT description, count(*) as count
+FROM `contractnotice`
+group by description having count > 1 order by count
+*/
+/*- duplicated description
+ - most duplicated overall, most duplicated per agency/category/supplier etc. */
+$heuristics["METADATA_DUPLICATED_DESCRIPTION"] = Array(
+ "description" => ""
+);
function METADATA_DUPLICATED_DESCRIPTION($cn)
{
- $averageContractPeriod = getAverageContractPeriod();
- $diff = strtotime($cn['contractStart']) - strtotime($cn['publishDate']);
- $days = intval($diff / 24);
- return ($days > 45 ? 1 : 0);
+ $averageDuplicatedDescriptions = getAverageDuplicatedDescriptions();
+ $stddevDuplicatedDescriptions = getstddevDuplicatedDescriptions();
+ $query = 'select count(*) from contractnotice where description = "' . $agencyName . '"';
+ $result = mysql_query($query);
+ $r = mysql_fetch_array($result, MYSQL_BOTH);
+ $dupeDesc = $r[0];
+ if ($dupeDesc == 1) $value = 0;
+ else $value = abs($dupeDesc - $averageDuplicatedDescriptions) / $stddevDuplicatedDescriptions;
+ return Array(
+ "heuristic_value" => $value,
+ "raw_value" => $dupeDesc,
+ "mean" => $averageDuplicatedDescriptions,
+ "stddev" => $stddevDuplicatedDescriptions
+ );
}
+$averageDuplicatedDescriptions;
+function getAverageDuplicatedDescriptions()
+{
+ global $averageDuplicatedDescriptions;
+ if (!$averageDuplicatedDescriptions) {
+ getStatsDuplicatedDescriptions();
+ }
+ return $averageDuplicatedDescriptions;
+}
+$stddevDuplicatedDescriptions;
+function getstddevDuplicatedDescriptions()
+{
+ global $stddevDuplicatedDescriptions;
+ if (!$stddevDuplicatedDescriptions) {
+ getStatsDuplicatedDescriptions();
+ }
+ return $stddevDuplicatedDescriptions;
+}
+function getStatsDuplicatedDescriptions()
+{
+ $query = "select avg(count),STDDEV(count) from (
+ SELECT description, count(*) as count
+FROM `contractnotice`
+group by description having count > 1
+ ) as a;";
+ $result = mysql_query($query);
+ $r = mysql_fetch_array($result, MYSQL_BOTH);
+ $averageDuplicatedDescriptions = $r[0];
+ $stddevDuplicatedDescriptions = $r[1];
+}
+
--- a/heuristics/readme.txt
+++ /dev/null
@@ -1,11 +1,1 @@
-heuristicResults
-heuristic = BY_DATE...
-value = 0.0
-cnPubDate =
-lastUpdated = 1/1/1970
-contractNotice =
-agency =
-supplier =
-work out total value by summing value
-
--- a/heuristics/runHeuristics.php
+++ b/heuristics/runHeuristics.php
@@ -1,5 +1,8 @@
<?php
include_once("heuristics.inc.php");
+$query = "SELECT *, agency.abn as agencyABN, IF(supplierABN != '',supplierABN,supplierName) as supplierID
+FROM contractnotice JOIN agency ON contractnotice.agencyName=agency.agencyName";
+
$query = "SELECT *, agency.abn as agencyABN, IF(supplierABN != '',supplierABN,supplierName) as supplierID
FROM contractnotice JOIN agency ON contractnotice.agencyName=agency.agencyName
WHERE DATE(importDate) = (select * from (SELECT DATE(importDate)
--- a/heuristics/valueHeuristics.php
+++ b/heuristics/valueHeuristics.php
@@ -1,8 +1,8 @@
-
- - large contract value
- - chi-square test for outliers / standard dev from mean/median
- - percent of total contracts for supplier/agency
- $heuristics["METADATA_DUPLICATED_DESCRIPTION"] = Array(
+<?php
+ /* - large contract value
+ - standard dev from mean/median
+ - percent of total contracts for supplier/agency*/
+ $heuristics["VALUE_LARGE_CONTRACT_OVERALL"] = Array(
"description" => "unusual value for time of year");
function METADATA_DUPLICATED_DESCRIPTION($cn)
{
@@ -12,12 +12,15 @@
return ($days > 45 ? 1 : 0);
}
- - peculiar value
+ /* - peculiar value
- Just under 80k, amplified if other contracts with same supplier are just under
- - unusual variation amount
- - absolute value; large reductions as well as large increases
-
- $heuristics["METADATA_DUPLICATED_DESCRIPTION"] = Array(
+ */
+ $heuristics["VALUE_NEAR_THRESHOLD"] = Array(
+ "description" => "unusual value for time of year");
+ /*
+ - unusual variation amount - absolute value; large reductions as well as large increases
+ */
+ $heuristics["VALUE_LARGE_VARIATION"] = Array(
"description" => "unusual value for time of year");
function METADATA_DUPLICATED_DESCRIPTION($cn)
{
@@ -26,3 +29,30 @@
$days = intval($diff / 24);
return ($days > 45 ? 1 : 0);
}
+
+/* - unusual value for time of year
+ - compare to all other records in last 2 weeks
+ - ie. many large contracts in june so takes more to standout*/
+$heuristics["VALUE_HIGH_FOR_MONTH"] = Array(
+ "description" => "unusual value for time of year"
+);
+function VALUE_HIGH_FOR_MONTH($cn, $monthAsInt)
+{
+ $averageContractPeriod = getAverageContractPeriod();
+ $diff = strtotime($cn['contractStart']) - strtotime($cn['publishDate']);
+ $days = intval($diff / 24);
+ return ($days > 45 ? 1 : 0);
+}
+$monthlyValueAverage = Array();
+function getAgencyTransactions($agencyName)
+{
+ global $agencyTransactions;
+ if (!$agencyTransactions[$agencyName]) {
+ $query = 'select count(*) from contractnotice where agencyName = "' . $agencyName . '"';
+ $result = mysql_query($query);
+ $r = mysql_fetch_array($result, MYSQL_BOTH);
+ $agencyTransactions[$agencyName] = $r[0];
+ }
+ return $agencyTransactions[$agencyName];
+}
+?>
--- /dev/null
+++ b/heuristics/viewHeuristicsColormap.php
@@ -1,1 +1,60 @@
+<?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
+// return the interpolated value between pBegin and pEnd
+function interpolate($pBegin, $pEnd, $pStep, $pMax)
+{
+ if ($pBegin < $pEnd) {
+ return (($pEnd - $pBegin) * ($pStep / $pMax)) + $pBegin;
+ }
+ else {
+ return (($pBegin - $pEnd) * (1 - ($pStep / $pMax))) + $pEnd;
+ }
+}
+function Gradient($HexFrom, $HexTo, $ColorSteps)
+{
+ $theColorBegin = hexdec($HexFrom);
+ $theColorEnd = hexdec($HexTo);
+ $theNumSteps = intval($ColorSteps);
+ $theR0 = ($theColorBegin & 0xff0000) >> 16;
+ $theG0 = ($theColorBegin & 0x00ff00) >> 8;
+ $theB0 = ($theColorBegin & 0x0000ff) >> 0;
+ $theR1 = ($theColorEnd & 0xff0000) >> 16;
+ $theG1 = ($theColorEnd & 0x00ff00) >> 8;
+ $theB1 = ($theColorEnd & 0x0000ff) >> 0;
+ $GradientColors = array();
+ // generate gradient swathe now
+ for ($i = 0; $i <= $theNumSteps; $i++) {
+ $theR = interpolate($theR0, $theR1, $i, $theNumSteps);
+ $theG = interpolate($theG0, $theG1, $i, $theNumSteps);
+ $theB = interpolate($theB0, $theB1, $i, $theNumSteps);
+ $theVal = ((($theR << 8) | $theG) << 8) | $theB;
+ $GradientColors[] = sprintf("%06X", $theVal);
+ }
+ return $GradientColors;
+}
+$Gradients = Gradient("66FF00" , "FF0000" , 10);
+
+$query = "select max(sum) from (SELECT sum(heuristic_value)
+as sum FROM heuristic_results group by CNID) as a";
+$result = mysql_query($query);
+$r = mysql_fetch_array($result, MYSQL_BOTH);
+$maxVal = $r[0];
+
+$query = "SELECT sum(heuristic_value) as sum, CNID
+FROM `heuristic_results` group by CNID order by sum DESC LIMIT 300";
+$result = mysql_query($query);
+if (!$result) echo mysql_error().$query;
+while ($r = mysql_fetch_array($result, MYSQL_BOTH)) {
+ echo '<div style="background: #'.$Gradients[floor(($r['sum']/$maxVal) * 10)].';">';
+ echo '<a title="'.$r['sum'].'" href="../displayContract.php?CNID='.$r['CNID'].'">X</a>';
+ echo "</div>";
+}
+?>
--- /dev/null
+++ b/heuristics/viewHeuristicsDistribution.php
@@ -1,1 +1,82 @@
+<?php
+/*// most interesting
+SELECT sum(heuristic_value) as sum, CNID
+FROM `heuristic_results` group by CNID order by sum DESC limit 30
+
+// spread of values
+select floor(sum) as val,count(*) from (SELECT sum(heuristic_value)
+as sum FROM heuristic_results group by CNID) as a group by val*/
+
+ /* CAT:Spline chart */
+
+ /* pChart library inclusions */
+ include("../lib/pChart2.1.0/class/pData.class.php");
+ include("../lib/pChart2.1.0/class/pDraw.class.php");
+ include("../lib/pChart2.1.0/class/pImage.class.php");
+
+$series = Array();
+
+ include_once("../lib/common.inc.php");
+$query = "select heuristic_name, floor(heuristic_value) as val,count(*) from heuristic_results group by heuristic_name, val";
+$result = mysql_query($query);
+if (!$result) echo mysql_error().$query;
+while ($r = mysql_fetch_array($result, MYSQL_BOTH)) {
+ $series[$r["heuristic_name"]][$r["val"]] = $r[2];
+}
+
+ /* Create and populate the pData object */
+ $MyData = new pData();
+ $labels = Array();
+ foreach ($series as $value) {
+ $labels = $labels+array_keys($value);
+ }
+ $labels = Array(0,1,2,3,4,5);
+foreach ($series as $seriesName => $seriesEntry) {
+ $data;
+ foreach ($labels as $label) {
+ $data[$label] = ($seriesEntry[$label] ? $seriesEntry[$label] : 0);
+ }
+
+$MyData->addPoints($data,$seriesName);
+ }
+ $MyData->setAxisName(0,"# of records");
+ $MyData->addPoints($labels,"Labels");
+ $MyData->setSerieDescription("Labels","Bins");
+ $MyData->setAbscissa("Labels");
+
+ /* Create the pChart object */
+ $myPicture = new pImage(700,230,$MyData);
+
+ /* Turn of Antialiasing */
+ $myPicture->Antialias = FALSE;
+
+ /* Add a border to the picture */
+ $myPicture->drawRectangle(0,0,699,229,array("R"=>0,"G"=>0,"B"=>0));
+
+ /* Write the chart title */
+ $myPicture->setFontProperties(array("FontName"=>"../lib/pChart2.1.0/fonts/Forgotte.ttf","FontSize"=>11));
+ $myPicture->drawText(150,35,"Record distribution",array("FontSize"=>20,"Align"=>TEXT_ALIGN_BOTTOMMIDDLE));
+
+ /* Set the default font */
+ $myPicture->setFontProperties(array("FontName"=>"../lib/pChart2.1.0/fonts/pf_arma_five.ttf","FontSize"=>6));
+
+ /* Define the chart area */
+ $myPicture->setGraphArea(60,40,650,200);
+
+ /* Draw the scale */
+ $scaleSettings = array("XMargin"=>10,"YMargin"=>0,"Floating"=>TRUE,"GridR"=>200,"GridG"=>200,"GridB"=>200,"DrawSubTicks"=>TRUE,"CycleBackground"=>TRUE);
+ $myPicture->drawScale($scaleSettings);
+
+ /* Turn on Antialiasing */
+ $myPicture->Antialias = TRUE;
+
+ /* Draw the line chart */
+ $myPicture->drawSplineChart();
+
+ /* Write the chart legend */
+ $myPicture->drawLegend(540,20,array("Style"=>LEGEND_NOBORDER,"Mode"=>LEGEND_VERTICAL));
+
+ /* Render the picture (choose the best way) */
+ $myPicture->autoOutput("pictures/example.drawSplineChart.simple.png");
+?>
--- /dev/null
+++ b/lib/pChart2.1.0/GPLv3.txt
@@ -1,1 +1,676 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The GNU General Public License is a free, copyleft license for
+software and other kinds of works.
+
+ The licenses for most software and other practical works are designed
+to take away your freedom to share and change the works. By contrast,
+the GNU General Public License is intended to guarantee your freedom to
+share and change all versions of a program--to make sure it remains free
+software for all its users. We, the Free Software Foundation, use the
+GNU General Public License for most of our software; it applies also to
+any other work released this way by its authors. You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+them if you wish), that you receive source code or can get it if you
+want it, that you can change the software or use pieces of it in new
+free programs, and that you know you can do these things.
+
+ To protect your rights, we need to prevent others from denying you
+these rights or asking you to surrender the rights. Therefore, you have
+certain responsibilities if you distribute copies of the software, or if
+you modify it: responsibilities to respect the freedom of others.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must pass on to the recipients the same
+freedoms that you received. You must make sure that they, too, receive
+or can get the source code. And you must show them these terms so they
+know their rights.
+
+ Developers that use the GNU GPL protect your rights with two steps:
+(1) assert copyright on the software, and (2) offer you this License
+giving you legal permission to copy, distribute and/or modify it.
+
+ For the developers' and authors' protection, the GPL clearly explains
+that there is no warranty for this free software. For both users' and
+authors' sake, the GPL requires that modified versions be marked as
+changed, so that their problems will not be attributed erroneously to
+authors of previous versions.
+
+ Some devices are designed to deny users access to install or run
+modified versions of the software inside them, although the manufacturer
+can do so. This is fundamentally incompatible with the aim of
+protecting users' freedom to change the software. The systematic
+pattern of such abuse occurs in the area of products for individuals to
+use, which is precisely where it is most unacceptable. Therefore, we
+have designed this version of the GPL to prohibit the practice for those
+products. If such problems arise substantially in other domains, we
+stand ready to extend this provision to those domains in future versions
+of the GPL, as needed to protect the freedom of users.
+
+ Finally, every program is threatened constantly by software patents.
+States should not allow patents to restrict development and use of
+software on general-purpose computers, but in those that do, we wish to
+avoid the special danger that patents applied to a free program could
+make it effectively proprietary. To prevent this, the GPL assures that
+patents cannot be used to render the program non-free.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ TERMS AND CONDITIONS
+
+ 0. Definitions.
+
+ "This License" refers to version 3 of the GNU General Public License.
+
+ "Copyright" also means copyright-like laws that apply to other kinds of
+works, such as semiconductor masks.
+
+ "The Program" refers to any copyrightable work licensed under this
+License. Each licensee is addressed as "you". "Licensees" and
+"recipients" may be individuals or organizations.
+
+ To "modify" a work means to copy from or adapt all or part of the work
+in a fashion requiring copyright permission, other than the making of an
+exact copy. The resulting work is called a "modified version" of the
+earlier work or a work "based on" the earlier work.
+
+ A "covered work" means either the unmodified Program or a work based
+on the Program.
+
+ To "propagate" a work means to do anything with it that, without
+permission, would make you directly or secondarily liable for
+infringement under applicable copyright law, except executing it on a
+computer or modifying a private copy. Propagation includes copying,
+distribution (with or without modification), making available to the
+public, and in some countries other activities as well.
+
+ To "convey" a work means any kind of propagation that enables other
+parties to make or receive copies. Mere interaction with a user through
+a computer network, with no transfer of a copy, is not conveying.
+
+ An interactive user interface displays "Appropriate Legal Notices"
+to the extent that it includes a convenient and prominently visible
+feature that (1) displays an appropriate copyright notice, and (2)
+tells the user that there is no warranty for the work (except to the
+extent that warranties are provided), that licensees may convey the
+work under this License, and how to view a copy of this License. If
+the interface presents a list of user commands or options, such as a
+menu, a prominent item in the list meets this criterion.
+
+ 1. Source Code.
+
+ The "source code" for a work means the preferred form of the work
+for making modifications to it. "Object code" means any non-source
+form of a work.
+
+ A "Standard Interface" means an interface that either is an official
+standard defined by a recognized standards body, or, in the case of
+interfaces specified for a particular programming language, one that
+is widely used among developers working in that language.
+
+ The "System Libraries" of an executable work include anything, other
+than the work as a whole, that (a) is included in the normal form of
+packaging a Major Component, but which is not part of that Major
+Component, and (b) serves only to enable use of the work with that
+Major Component, or to implement a Standard Interface for which an