Skip to content
This repository has been archived by the owner on Sep 10, 2021. It is now read-only.

Commit

Permalink
Improve formatting of tracker module scalar details view.
Browse files Browse the repository at this point in the history
The scalar details view displays rows of metrics with units.  This
commit rounds the float value of the scalars to 4 decimal places, aligns
all of the values to the right for display, and splits out the units to
a separate table column so they can also be right aligned for display.
If the values and units were left in the same column it would be more
difficult to align.
  • Loading branch information
mgrauer committed Aug 17, 2015
1 parent 79d41da commit 374637a
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion modules/tracker/models/pdo/ScalarModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public function getOtherValuesFromSubmission($scalarDao)

/** @var Zend_Db_Table_Row_Abstract $row */
foreach ($rows as $row) {
$scalarDaos[$row['metric_name']] = $row['value'].' '.$row['unit'];
$scalarDaos[$row['metric_name']] = array('value' => number_format((float)$row['value'], 4, '.', ''), 'unit' => $row['unit']);
}

return $scalarDaos;
Expand Down
2 changes: 1 addition & 1 deletion modules/tracker/public/css/scalar/scalar.details.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions modules/tracker/public/scss/scalar/scalar.details.scss
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ table {
font-weight: bold;
padding-right: 6px;
}
&.otherScalarTable td {
text-align: right;
}
}

div {
Expand Down
6 changes: 4 additions & 2 deletions modules/tracker/views/scalar/details.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,10 @@ if (count($this->extraParams)) {
* @var string $metricName
* @var float $value
*/
foreach ($this->otherValues as $metricName => $value) {
echo '<tr><th>'.$this->escape($metricName).':</th><td>'.$this->escape($value).'</td></tr>';
foreach ($this->otherValues as $metricName => $metricProperties) {
$metricValue = $metricProperties['value'];
$metricUnit = $metricProperties['unit'];
echo '<tr><th>'.$this->escape($metricName).':</th><td>'.$this->escape($metricValue).'</td><td>'.$this->escape($metricUnit).'</td></tr>';
}
?>
</tbody>
Expand Down

0 comments on commit 374637a

Please sign in to comment.