Fixed chart currency options..

This commit is contained in:
Cüneyt Şentürk 2022-01-11 23:19:53 +03:00
parent 319952e19e
commit da5f1988c2

View File

@ -94,6 +94,12 @@ trait Charts
public function getLineChartOptions($money_format = true) public function getLineChartOptions($money_format = true)
{ {
$decimal_mark = str_replace("'", "\\'", config('money.' . setting('default.currency') . '.decimal_mark'));
$thousands_separator = str_replace("'", "\\'", config('money.' . setting('default.currency') . '.thousands_separator'));
$symbol = str_replace("'", "\\'", config('money.' . setting('default.currency') . '.symbol'));
$symbol_first = str_replace("'", "\\'", config('money.' . setting('default.currency') . '.symbol_first'));
$precision = str_replace("'", "\\'", config('money.' . setting('default.currency') . '.precision'));
$options = [ $options = [
'tooltips' => [ 'tooltips' => [
'backgroundColor' => '#000000', 'backgroundColor' => '#000000',
@ -144,11 +150,11 @@ trait Charts
$options['tooltips']['callbacks'] = [ $options['tooltips']['callbacks'] = [
'label' => new Raw("function(tooltipItem, data) { 'label' => new Raw("function(tooltipItem, data) {
const moneySettings = { const moneySettings = {
decimal: '" . config('money.' . setting('default.currency') . '.decimal_mark') . "', decimal: '" . $decimal_mark . "',
thousands: '". config('money.' . setting('default.currency') . '.thousands_separator') . "', thousands: '". $thousands_separator . "',
symbol: '" . config('money.' . setting('default.currency') . '.symbol') . "', symbol: '" . $symbol . "',
isPrefix: '" . config('money.' . setting('default.currency') . '.symbol_first') . "', isPrefix: '" . $symbol_first . "',
precision: '" . config('money.' . setting('default.currency') . '.precision') . "', precision: '" . $precision . "',
}; };
const formattedCurrency = function (input, opt = moneySettings) { const formattedCurrency = function (input, opt = moneySettings) {
@ -200,11 +206,11 @@ trait Charts
// for Y variable money format // for Y variable money format
$options['scales']['yAxes'][0]['ticks']['callback'] = new Raw("function(value, index, values) { $options['scales']['yAxes'][0]['ticks']['callback'] = new Raw("function(value, index, values) {
const moneySettings = { const moneySettings = {
decimal: '" . config('money.' . setting('default.currency') . '.decimal_mark') . "', decimal: '" . $decimal_mark . "',
thousands: '". config('money.' . setting('default.currency') . '.thousands_separator') . "', thousands: '". $thousands_separator . "',
symbol: '" . config('money.' . setting('default.currency') . '.symbol') . "', symbol: '" . $symbol . "',
isPrefix: '" . config('money.' . setting('default.currency') . '.symbol_first') . "', isPrefix: '" . $symbol_first . "',
precision: '" . config('money.' . setting('default.currency') . '.precision') . "', precision: '" . $precision . "',
}; };
const formattedCurrency = function (input, opt = moneySettings) { const formattedCurrency = function (input, opt = moneySettings) {