fix: [UI] Round percentage change in periodic summary

pull/8601/head
Jakub Onderka 2022-09-21 14:14:07 +02:00
parent a545966ce3
commit 2873a8da4c
2 changed files with 3 additions and 4 deletions

View File

@ -56,7 +56,7 @@ class TrendingTool
$trendAnalysis[$previousTimestamp][$tag] = [
'occurrence' => 0,
'raw_change' => -$amount,
'percent_change' => 100 * (-$amount / $amount),
'percent_change' => round(100 * (-$amount / $amount), 2),
'change_sign' => -$amount > 0 ? 1 : (-$amount < 0 ? -1 : 0),
];
}

View File

@ -92,7 +92,6 @@ if (!function_exists('computeLinePositions')) {
return $conf;
}
}
?>
<div style="display: flex; column-gap: 20px; justify-content: space-around; margin-bottom: 40px;">
@ -255,7 +254,7 @@ if (!function_exists('computeLinePositions')) {
<tr>
<td><?= h($clusteredTags[$previousPeriod][$tagName]['occurrence'] ?? '-') ?></td>
<td><?= h($clusteredTags[$previousPeriod][$tagName]['raw_change'] ?? '-') ?></td>
<td><?= h($clusteredTags[$previousPeriod][$tagName]['percent_change'] ?? '-') ?>%</td>
<td><?= h($clusteredTags[$previousPeriod][$tagName]['percent_change'] ?? '-') ?>&nbsp;%</td>
<td style="font-size: large; color: <?= $trendColorMapping[$clusteredTags[$previousPeriod][$tagName]['change_sign'] ?? '?'] ?>"><?= $trendIconMapping[$clusteredTags[$previousPeriod][$tagName]['change_sign'] ?? '?'] ?></td>
</tr>
</tbody>
@ -267,7 +266,7 @@ if (!function_exists('computeLinePositions')) {
<tr>
<td><?= h($clusteredTags[$currentPeriod][$tagName]['occurrence'] ?? '-') ?></td>
<td><?= h($clusteredTags[$currentPeriod][$tagName]['raw_change'] ?? '-') ?></td>
<td><?= h($clusteredTags[$currentPeriod][$tagName]['percent_change'] ?? '-') ?>%</td>
<td><?= h($clusteredTags[$currentPeriod][$tagName]['percent_change'] ?? '-') ?>&nbsp;%</td>
<td style="font-size: large; color: <?= $trendColorMapping[$clusteredTags[$currentPeriod][$tagName]['change_sign'] ?? '?'] ?>"><?= $trendIconMapping[$clusteredTags[$currentPeriod][$tagName]['change_sign'] ?? '?'] ?></td>
</tr>
</tbody>