Skip to content
Browse files

Fixed some issues and added support for plotting strings

  • Loading branch information...
1 parent f64dffd commit 64425ccb66a518fe7c38bfd1c5f09d2e35afce3e @ammaryasir ammaryasir committed Jun 10, 2011
Showing with 98 additions and 34 deletions.
  1. +39 −10 libraries/svg_plot/pma_scatter_plot.php
  2. +14 −8 libraries/tbl_select.lib.php
  3. +45 −16 tbl_zoom_select.php
View
49 libraries/svg_plot/pma_scatter_plot.php
@@ -122,6 +122,10 @@ private function _handleOptions()
$this->_settings[$key] = $this->_userSpecifiedSettings[$key];
}
}
+ if ($this->_settings['dataLabel'] == '') {
+ $labels = array_keys($this->_data[0]);
+ $this->_settings['dataLabel'] = $labels[0];
+ }
}
/**
@@ -186,20 +190,45 @@ public function asSVG()
*/
private function _scaleDataSet($data,$xField,$yField)
{
+
// Currently assuming only numeric fields are selected
- $cx = $cy = array();
+ $coordinates = array();
foreach ($data as $row) {
- $cx[] = $row[$xField];
- $cy[] = $row[$yField];
+ $coordinates[0][] = $row[$xField];
+ $coordinates[1][] = $row[$yField];
}
- $maxX = max($cx);
- $maxY = max($cy);
- for($i = 0; $i < count($cx) ; $i++){
- $cx[$i] = 20 + 500 * $cx[$i] / $maxX;
- $cy[$i] = 320 * (1 - $cy[$i] / $maxY) + 20;
-
+ for ($i = 0 ; $i < 2 ; $i++) {
+
+ $maxC = ($i == 0) ? 500 : 320;
+
+ if( !is_numeric($coordinates[$i][0])) {
+ $uniqueC = array_unique($coordinates[$i]);
+ $countC = count(array_unique($coordinates[$i]));
+ $map = $tmp = array();
+ foreach ($uniqueC as $uc) {
+ $tmp[] = $uc;
+ }
+ for ($j = 0 ; $j < $countC ; $j++) {
+ $map[$tmp[$j]] = 20 + $j * $maxC / $countC;
+ }
+ for($j = 0 ; $j < count($coordinates[$i]) ; $j++) {
+ $coordinates[$i][$j] = $map[$coordinates[$i][$j]];
+ }
+
+ }
+ elseif (is_numeric($coordinates[$i][0])) {
+
+ $maxC = max($coordinates[$i]);
+ for($j = 0 ; $j < count($coordinates[$i]) ; $j++) {
+
+ if ($i == 0)
+ $coordinates[$i][$j] = 20 + 500 * $coordinates[$i][$j] / $maxC;
+ else
+ $coordinates[$i][$j] = 20 + 320 * (1 - $coordinates[$i][$j] / $maxC);
+ }
+ }
}
- return array($cx,$cy);
+ return $coordinates;
}
/**
View
22 libraries/tbl_select.lib.php
@@ -174,7 +174,6 @@ function PMA_getForeignFields_Values($foreigners, $foreignData, $field, $tbl_fie
$str = '';
if ($foreigners && isset($foreigners[$field]) && is_array($foreignData['disp_row'])) {
-
// f o r e i g n k e y s
$str .= ' <select name="fields[' . $i . ']">' . "\n";
// go back to first row
@@ -188,11 +187,17 @@ function PMA_getForeignFields_Values($foreigners, $foreignData, $field, $tbl_fie
$str .= ' </select>' . "\n";
}
elseif ($foreignData['foreign_link'] == true) {
-
- $str .= '<input type="text" name="fields[' . $i . '] "';
- 'id="field_' . md5($field) . '[' . $i .']"
- class="textfield" />' ; ?>
-
+ if(isset($fields[$i]) && is_string($fields[$i])){
+ $str .= '<input type="text" name="fields[' . $i . '] " value="' . $fields[$i] . '"';
+ 'id="field_' . md5($field) . '[' . $i .']"
+ class="textfield"/>' ;
+ }
+ else{
+ $str .= '<input type="text" name="fields[' . $i . '] "';
+ 'id="field_' . md5($field) . '[' . $i .']"
+ class="textfield" />' ;
+ }
+ ?>
<?php $str .= '<script type="text/javascript">';
// <![CDATA[
$str .= <<<EOT
@@ -358,7 +363,7 @@ function PMA_SVG_scatter_plot($data, &$settings)
if (empty($data)) {
// empty data
- return __('No data found for plot.');
+ return '';
} else {
$scatter_plot = new PMA_Scatter_Plot($data, $settings);
@@ -369,8 +374,9 @@ function PMA_SVG_scatter_plot($data, &$settings)
}
}
}
+ return $scatter_plot->asSVG();
}
- return $scatter_plot->asSVG();
+
}
View
61 tbl_zoom_select.php
@@ -140,15 +140,16 @@
<input type="hidden" name="back" value="tbl_select.php" />
<input type="hidden" name="flag" id="id_flag" value=<?php echo $flag; ?> />
+
<fieldset id="zoom_fieldset_table_qbe">
-<?php if(isset($zoom_submit)){ ?>
+<?php if(isset($zoom_submit) && !empty($scatter_plot)){ ?>
- <legend><?php echo __('Display GIS Visualization'); ?></legend>
+ <legend><?php echo __('Display Plot'); ?></legend>
<div id="placeholder" style="width:<?php echo($settings['width'] + 20); ?>px;height:<?php echo($settings['height'] + 20); ?>px;border:1px solid #484;float:right">
<?php echo $scatter_plot; ?>
</div>
-
+
<?php } ?>
<legend><?php echo __('Do a "query by example" (wildcard: "%") for two columns') ?></legend>
<table class="data">
@@ -184,29 +185,57 @@
if (strncasecmp($tbl_fields_type[$i], 'enum', 4) == 0) {
foreach ($GLOBALS['cfg']['EnumOperators'] as $fc) {
- echo "\n" . ' '
- . '<option value="' . htmlspecialchars($fc) . '">'
- . htmlspecialchars($fc) . '</option>';
+ if(isset($zoomFunc[$i]) && $zoomFunc[$i] == htmlspecialchars($fc)){
+ echo "\n" . ' '
+ . '<option value="' . htmlspecialchars($fc) . '" Selected>'
+ . htmlspecialchars($fc) . '</option>';
+ }
+ else {
+ echo "\n" . ' '
+ . '<option value="' . htmlspecialchars($fc) . '">'
+ . htmlspecialchars($fc) . '</option>';
+ }
}
} elseif (preg_match('@char|blob|text|set@i', $tbl_fields_type[$i])) {
foreach ($GLOBALS['cfg']['TextOperators'] as $fc) {
- echo "\n" . ' '
- . '<option value="' . htmlspecialchars($fc) . '">'
- . htmlspecialchars($fc) . '</option>';
+ if(isset($zoomFunc[$i]) && $zoomFunc[$i] == $fc){
+ echo "\n" . ' '
+ . '<option value="' . htmlspecialchars($fc) . '" Selected>'
+ . htmlspecialchars($fc) . '</option>';
+ }
+ else {
+ echo "\n" . ' '
+ . '<option value="' . htmlspecialchars($fc) . '">'
+ . htmlspecialchars($fc) . '</option>';
+ }
}
} else {
foreach ($GLOBALS['cfg']['NumOperators'] as $fc) {
- echo "\n" . ' '
- . '<option value="' . htmlspecialchars($fc) . '">'
- . htmlspecialchars($fc) . '</option>';
+ if(isset($zoomFunc[$i]) && $zoomFunc[$i] == $fc){
+ echo "\n" . ' '
+ . '<option value="' . htmlspecialchars($fc) . '" Selected>'
+ . htmlspecialchars($fc) . '</option>';
+ }
+ else {
+ echo "\n" . ' '
+ . '<option value="' . htmlspecialchars($fc) . '">'
+ . htmlspecialchars($fc) . '</option>';
+ }
}
} // end if... else...
if ($tbl_fields_null[$i]) {
foreach ($GLOBALS['cfg']['NullOperators'] as $fc) {
- echo "\n" . ' '
- . '<option value="' . htmlspecialchars($fc) . '">'
- . htmlspecialchars($fc) . '</option>';
+ if(isset($zoomFunc[$i]) && $zoomFunc[$i] == $fc){
+ echo "\n" . ' '
+ . '<option value="' . htmlspecialchars($fc) . '" Selected>'
+ . htmlspecialchars($fc) . '</option>';
+ }
+ else {
+ echo "\n" . ' '
+ . '<option value="' . htmlspecialchars($fc) . '">'
+ . htmlspecialchars($fc) . '</option>';
+ }
}
}
?>
@@ -217,7 +246,6 @@
$field = $inputs[$i];
$foreignData = PMA_getForeignData($foreigners, $field, false, '', '');
-
if (isset($fields))
echo PMA_getForeignFields_Values($foreigners, $foreignData, $field, $tbl_fields_type, $i ,$db, $table, $titles, $GLOBALS['cfg']['ForeignKeyMaxLimit'], $fields);
else
@@ -263,6 +291,7 @@
</table>
+
</fieldset>
<fieldset class="tblFooters">
<input type="hidden" name="max_number_of_fields"

0 comments on commit 64425cc

Please sign in to comment.
Something went wrong with that request. Please try again.