Skip to content

Commit

Permalink
handle formatted numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
sgiehl committed Jun 14, 2018
1 parent 8de76fb commit 9059a5b
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions core/Visualization/Sparkline.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,17 @@ public function main() {
$sparkline = new \Davaxi\Sparkline();

$seconds = Piwik::translate('Intl_NSecondsShort');
$toRemove = array('%', str_replace('%s', '', $seconds));
$percent = Piwik::translate('Intl_NumberSymbolPercent');
$thousandSeparator = Piwik::translate('Intl_NumberSymbolGroup');
$decimalSeparator = Piwik::translate('Intl_NumberSymbolGroup');
$toRemove = array('%', $percent, str_replace('%s', '', $seconds));
$values = [];
foreach ($this->values as $value) {
// 50% and 50s should be plotted as 50
$value = str_replace($toRemove, '', $value);
// replace localized decimal separator
$value = str_replace(',', '.', $value);
$value = str_replace($thousandSeparator, '', $value);
$value = str_replace($decimalSeparator, '.', $value);
if ($value == '') {
$value = 0;
}
Expand Down

0 comments on commit 9059a5b

Please sign in to comment.