diff --git a/app/Generator/Chart/Basic/ChartJsGenerator.php b/app/Generator/Chart/Basic/ChartJsGenerator.php index c3980a5c5f..642c554337 100644 --- a/app/Generator/Chart/Basic/ChartJsGenerator.php +++ b/app/Generator/Chart/Basic/ChartJsGenerator.php @@ -81,6 +81,9 @@ class ChartJsGenerator implements GeneratorInterface if (isset($set['fill'])) { $currentSet['fill'] = $set['fill']; } + if (isset($set['currency_symbol'])) { + $currentSet['currency_symbol'] = $set['currency_symbol']; + } $chartData['datasets'][] = $currentSet; } diff --git a/app/Http/Controllers/Chart/AccountController.php b/app/Http/Controllers/Chart/AccountController.php index 0e37cba3da..ac8b516685 100644 --- a/app/Http/Controllers/Chart/AccountController.php +++ b/app/Http/Controllers/Chart/AccountController.php @@ -26,6 +26,7 @@ use FireflyIII\Models\TransactionType; use FireflyIII\Repositories\Account\AccountRepositoryInterface; use FireflyIII\Repositories\Budget\BudgetRepositoryInterface; use FireflyIII\Repositories\Category\CategoryRepositoryInterface; +use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface; use FireflyIII\Support\CacheProperties; use Illuminate\Support\Collection; use Log; @@ -501,11 +502,16 @@ class AccountController extends Controller } Log::debug('Regenerate chart.account.account-balance-chart from scratch.'); + /** @var CurrencyRepositoryInterface $repository */ + $repository = app(CurrencyRepositoryInterface::class); + $chartData = []; foreach ($accounts as $account) { + $currency = $repository->find(intval($account->getMeta('currency_id'))); $currentSet = [ - 'label' => $account->name, - 'entries' => [], + 'label' => $account->name, + 'currency_symbol' => $currency->symbol, + 'entries' => [], ]; $currentStart = clone $start; $range = Steam::balanceInRange($account, $start, clone $end); diff --git a/public/js/ff/charts.defaults.js b/public/js/ff/charts.defaults.js index 4679f6565b..3e56c2f55f 100644 --- a/public/js/ff/charts.defaults.js +++ b/public/js/ff/charts.defaults.js @@ -42,7 +42,8 @@ var defaultChartOptions = { callbacks: { label: function (tooltipItem, data) { "use strict"; - return data.datasets[tooltipItem.datasetIndex].label + ': ' + accounting.formatMoney(tooltipItem.yLabel); + return data.datasets[tooltipItem.datasetIndex].label + ': ' + + accounting.formatMoney(tooltipItem.yLabel, data.datasets[tooltipItem.datasetIndex].currency_symbol); } } } diff --git a/public/js/ff/charts.js b/public/js/ff/charts.js index cfc787fae6..7b88b064bd 100644 --- a/public/js/ff/charts.js +++ b/public/js/ff/charts.js @@ -91,7 +91,7 @@ function doubleYChart(URI, container) { "use strict"; var colorData = true; - var options = defaultChartOptions; + var options = $.extend(true, {}, defaultChartOptions); options.scales.yAxes = [ // y axis 0: { @@ -141,7 +141,7 @@ function doubleYNonStackedChart(URI, container) { "use strict"; var colorData = true; - var options = defaultChartOptions; + var options = $.extend(true, {}, defaultChartOptions); options.scales.yAxes = [ // y axis 0: {