diff --git a/libraries/svg_plot/pma_scatter_plot.php b/libraries/svg_plot/pma_scatter_plot.php index 10c0aea343..c7e8cfad15 100644 --- a/libraries/svg_plot/pma_scatter_plot.php +++ b/libraries/svg_plot/pma_scatter_plot.php @@ -119,12 +119,12 @@ class PMA_Scatter_Plot $this->_dataPoints = array(); if (! is_null($this->_userSpecifiedSettings)) { foreach (array_keys($this->_userSpecifiedSettings) as $key){ - $this->_settings[$key] = $this->_userSpecifiedSettings[$key]; - } + $this->_settings[$key] = $this->_userSpecifiedSettings[$key]; + } } if ($this->_settings['dataLabel'] == '') { - $labels = array_keys($this->_data[0]); - $this->_settings['dataLabel'] = $labels[0]; + $labels = array_keys($this->_data[0]); + $this->_settings['dataLabel'] = $labels[0]; } } @@ -143,7 +143,7 @@ class PMA_Scatter_Plot . ' height="' . $this->_settings['height'] . '">'; $output .= ''; $output .= ' - @@ -194,41 +194,38 @@ class PMA_Scatter_Plot // Currently assuming only numeric fields are selected $coordinates = array(); foreach ($data as $row) { - $coordinates[0][] = $row[$xField]; - $coordinates[1][] = $row[$yField]; - } + $coordinates[0][] = $row[$xField]; + $coordinates[1][] = $row[$yField]; + } for ($i = 0 ; $i < 2 ; $i++) { - $maxC = ($i == 0) ? 500 : 320; - if( !is_numeric($coordinates[$i][0])) { + if ( !is_numeric($coordinates[$i][0])) { $uniqueC = array_unique($coordinates[$i]); $countC = count(array_unique($coordinates[$i])); - $map = $tmp = array(); + $map = $tmp = array(); foreach ($uniqueC as $uc) { - $tmp[] = $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 $coordinates; + } + for ($j = 0 ; $j < count($coordinates[$i]) ; $j++) { + $coordinates[$i][$j] = $map[$coordinates[$i][$j]]; + } + } + else if (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 $coordinates; } /** @@ -246,7 +243,7 @@ class PMA_Scatter_Plot { $result = ''; // loop through the rows - for($i = 0 ; $i < count($data) ; $i++) { + for ($i = 0 ; $i < count($data) ; $i++) { $index = $color_number % sizeof($this->_settings['colors']); @@ -255,11 +252,10 @@ class PMA_Scatter_Plot $options = array('color' => $this->_settings['colors'][$index], 'id' => $i); $this->_dataPoints[] = $data_element; - $result .= $data_element->prepareRowAsSVG($options); + $result .= $data_element->prepareRowAsSVG($options); $color_number++; } - return $result; } }