-
-
+
diff --git a/msq.php b/msq.php
index 0e4e2bf..3f947f9 100644
--- a/msq.php
+++ b/msq.php
@@ -1,15 +1,88 @@
$max) $max = $v;
+ }
+
+ $range = ($max - $min);
+ $r = 0; $g = 0; $b = 0; $percent = 0; $intensity = 0.6;
+
+ foreach ($data as $k => $v)
+ {
+ $percent = ($v - $min) / $range;
+
+ if ($percent < 0.33)
+ {
+ $r = 1.0;
+ $g = min(1.0, ($percent * 3));
+ $b = 0.0;
+ }
+ else if ($percent < 0.66)
+ {
+ $r = min(1.0, ((0.66 - $percent) * 3));
+ $g = 1.0;
+ $b = 0.0;
+ }
+ else
+ {
+ $r = 0.0;
+ $g = min(1.0, ((1.0 - $percent) * 3));
+ $b = 1.0 - $g;
+ }
+
+ $r = $r * $intensity + (1.0 - $intensity);
+ $g = $g * $intensity + (1.0 - $intensity);
+ $b = $b * $intensity + (1.0 - $intensity);
+
+ $colorTable[$k] = array('r' => $r, 'g' => $g, 'b' => $b);
+ }
+
+ return $colorTable;
+
+ //for ($r = 0; $r < $rows; $r++)
+ //{
+ //for ($c = 0; $c < $cols; $c++)
+ //{
+ //$v = $data[($r) * $rows + $c];
+ //if ($v < $min) $min = $v;
+ //else if ($v > $max) $max = $v;
+ //}
+ //}
+}
+
+function msqTable($name, $data, $x, $y)
{
$rows = count($y);
$cols = count($x);
+ //echo "ROWS: $rows, $cols";
+ //var_dump($x, "YYYYYYYYY", $y);
+
if ($rows * $cols != count($data))
{
echo '
' . $name . ' column/row count mismatched with data count.
';
@@ -19,20 +92,27 @@ function msqTable($name, $x, $y, $data)
echo '
'; //TODO Some kind of CSS to indicate color shading?
echo "$name";
- for ($r = 1; $r <= $rows; $r++)
+ //$colorTable = msqTableColor($data, $rows, $cols);
+
+ for ($r = 0; $r < $rows; $r++)
{
echo "" . $y[$r] . " | ";
- for ($c = 1; $c <= $cols; $c++)
+ for ($c = 0; $c < $cols; $c++)
{
- if ($r == 1) echo "" . $data[$c] . " | ";
- else echo "" . $data[($r - 1) * $rows + $c] . " | ";
+ //if ($r == 0) echo "" . $data[$c] . " | ";
+ //else
+ $r = 0; //$colorTable[$r * $rows + $c]['r'];
+ $g = 1; //$colorTable[$r * $rows + $c]['g'];
+ $b = 0; //firefo$colorTable[$r * $rows + $c]['b'];
+ //echo "" . $data[$r * $rows + $c] . " | ";
+ echo "" . $data[$r * $rows + $c] . " | ";
}
echo "
";
}
echo " | ";
- for ($c = 1; $c <= $cols; $c++)
+ for ($c = 0; $c < $cols; $c++)
{
- echo "" . $y[$c] . " | ";
+ echo "" . $x[$c] . " | ";
}
echo "
";
echo "
";
@@ -51,7 +131,6 @@ function parseMSQ($xml)
//Strip out invalid xmlns
//TODO This should really happen on upload...
$xml = preg_replace('/xmlns=".*?"/', '', $xml);
-
$msq = simplexml_load_string($xml);
if ($msq)
@@ -88,11 +167,10 @@ function parseMSQ($xml)
$numRows = (int)$constant['rows'];
$x = msqAxis($msq->xpath('//constant[@name="' . $value['x'] . '"]')[0]);
$y = msqAxis($msq->xpath('//constant[@name="' . $value['y'] . '"]')[0]);
- var_dump($x);
- echo count($x) . ',' . count($y) . ' vs ' . "$numCols,$numRows";
+
if ((count($x) == $numCols) && (count($y) == $numRows))
{
- $tableData = preg_split("/\s+/", $constant, PREG_SPLIT_NO_EMPTY); //, $limit);
+ $tableData = preg_split("/\s+/", trim($constant));//, PREG_SPLIT_NO_EMPTY); //, $limit);
msqTable($value['name'], $tableData, $x, $y);
}
}
@@ -109,4 +187,4 @@ function parseMSQ($xml)
}
}
-?>
\ No newline at end of file
+?>
diff --git a/msqur.css b/msqur.css
index 06d6748..811e88b 100644
--- a/msqur.css
+++ b/msqur.css
@@ -53,6 +53,7 @@ div.footer {
table {
border-collapse: collapse;
border: 1px solid #CCC;
+ /*width: 100%;*/
}
table caption {
@@ -68,8 +69,10 @@ table td:hover {
}
table th, table td {
- padding: 0.5em;
+ padding: 4px;
border: 1px dotted #333;
+ font-size: smaller;
+ text-align: center;
}
/* eh, need to switch top/bottom border dep. on where the header is */
diff --git a/warn.gif b/warn.gif
new file mode 100644
index 0000000..35d42e8
Binary files /dev/null and b/warn.gif differ