Skip to content

Commit

Permalink
typo
Browse files Browse the repository at this point in the history
  • Loading branch information
cuneytsenturk committed Sep 2, 2021
1 parent cc73dee commit 59282c3
Showing 1 changed file with 21 additions and 24 deletions.
45 changes: 21 additions & 24 deletions app/Traits/Charts.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@

namespace App\Traits;

use Akaunting\Money\Money;

use App\Utilities\Chartjs;

use Balping\JsonRaw\Raw;

trait Charts
Expand Down Expand Up @@ -108,7 +105,7 @@ public function getLineChartOptions()
'intersect' => 0,
'position' => 'nearest',
'callbacks' => [
'label' => new Raw("function(tooltipItem, data) {
'label' => new Raw("function(tooltipItem, data) {
const moneySettings = {
decimal: '" . config('money.' . setting('default.currency') . '.decimal_mark') . "',
thousands: '". config('money.' . setting('default.currency') . '.thousands_separator') . "',
Expand All @@ -129,7 +126,7 @@ function toStr(value) {
function numbersToCurrency(numbers, precision) {
var exp = Math.pow(10, precision);
var float = parseFloat(numbers) / exp;
return float.toFixed(fixed(precision));
};
Expand All @@ -138,18 +135,18 @@ function joinIntegerAndDecimal (integer, decimal, separator) {
};
if (typeof input === 'number') {
input = input.toFixed(fixed(opt.precision));
input = input.toFixed(fixed(opt.precision));
};
var negative = input.indexOf('-') >= 0 ? '-' : '';
var numbers = toStr(input).replace(/\D+/g, '') || '0';
var currency = numbersToCurrency(numbers, opt.precision);
var parts = toStr(currency).split('.');
var integer = parts[0].replace(/(\d)(?=(?:\d{3})+\b)/gm, opt.thousands);;
var integer = parts[0].replace(/(\d)(?=(?:\d{3})+\b)/gm, opt.thousands);
var decimal = parts[1];
if(opt.isPrefix == 1) {
return opt.symbol + negative + joinIntegerAndDecimal(integer, decimal, opt.decimal)
if (opt.isPrefix == 1) {
return opt.symbol + negative + joinIntegerAndDecimal(integer, decimal, opt.decimal);
}
return negative + joinIntegerAndDecimal(integer, decimal, opt.decimal) + opt.symbol;
Expand All @@ -163,53 +160,53 @@ function joinIntegerAndDecimal (integer, decimal, separator) {
'yAxes' => [[
'ticks' => [
'beginAtZero' => true,
'callback' => new Raw("function(value, index, values) {
'callback' => new Raw("function(value, index, values) {
const moneySettings = {
decimal: '" . config('money.' . setting('default.currency') . '.decimal_mark') . "',
thousands: '". config('money.' . setting('default.currency') . '.thousands_separator') . "',
symbol: '" . config('money.' . setting('default.currency') . '.symbol') . "',
isPrefix: '" . config('money.' . setting('default.currency') . '.symbol_first') . "',
precision: '" . config('money.' . setting('default.currency') . '.precision') . "',
};
const formattedCurrency = function (input, opt = moneySettings) {
function fixed (precision) {
return Math.max(0, Math.min(precision, 20));
};
function toStr(value) {
return value ? value.toString() : '';
};
function numbersToCurrency(numbers, precision) {
var exp = Math.pow(10, precision);
var float = parseFloat(numbers) / exp;
return float.toFixed(fixed(precision));
};
function joinIntegerAndDecimal (integer, decimal, separator) {
return decimal ? integer + separator + decimal : integer;
};
if (typeof input === 'number') {
input = input.toFixed(fixed(opt.precision));
input = input.toFixed(fixed(opt.precision));
};
var negative = input.indexOf('-') >= 0 ? '-' : '';
var numbers = toStr(input).replace(/\D+/g, '') || '0';
var currency = numbersToCurrency(numbers, opt.precision);
var parts = toStr(currency).split('.');
var integer = parts[0].replace(/(\d)(?=(?:\d{3})+\b)/gm, opt.thousands);;
var integer = parts[0].replace(/(\d)(?=(?:\d{3})+\b)/gm, opt.thousands);
var decimal = parts[1];
if(opt.isPrefix == 1) {
return opt.symbol + negative + joinIntegerAndDecimal(integer, decimal, opt.decimal)
if (opt.isPrefix == 1) {
return opt.symbol + negative + joinIntegerAndDecimal(integer, decimal, opt.decimal);
} else {
return negative + joinIntegerAndDecimal(integer, decimal, opt.decimal) + opt.symbol;
}
};
return formattedCurrency(value, moneySettings);
}"),
],
Expand All @@ -222,7 +219,7 @@ function joinIntegerAndDecimal (integer, decimal, separator) {
'ticks' => [
'padding' => 10,
'fontColor' => '#9e9e9e',
]],
],
'gridLines' => [
'drawBorder' => false,
'color' => 'rgba(29,140,248,0.1)',
Expand Down

0 comments on commit 59282c3

Please sign in to comment.