chart trait typo

This commit is contained in:
Cüneyt Şentürk 2021-09-03 00:14:26 +03:00
parent 59282c36f0
commit ac86fbb7b7

View File

@ -92,9 +92,9 @@ trait Charts
]; ];
} }
public function getLineChartOptions() public function getLineChartOptions($money_format = true)
{ {
return [ $options = [
'tooltips' => [ 'tooltips' => [
'backgroundColor' => '#000000', 'backgroundColor' => '#000000',
'titleFontColor' => '#ffffff', 'titleFontColor' => '#ffffff',
@ -104,7 +104,44 @@ trait Charts
'mode' => 'nearest', 'mode' => 'nearest',
'intersect' => 0, 'intersect' => 0,
'position' => 'nearest', 'position' => 'nearest',
'callbacks' => [ ],
'responsive' => true,
'scales' => [
'yAxes' => [[
'barPercentage' => 1.6,
'ticks' => [
'beginAtZero' => true,
'padding' => 10,
'fontColor' => '#9e9e9e',
],
'gridLines' => [
'drawBorder' => false,
'color' => 'rgba(29,140,248,0.1)',
'zeroLineColor' => 'transparent',
'borderDash' => [2],
'borderDashOffset' => [2],
],
]],
'xAxes' => [[
'barPercentage' => 1.6,
'ticks' => [
'suggestedMin' => 60,
'suggestedMax' => 125,
'padding' => 20,
'fontColor' => '#9e9e9e',
],
'gridLines' => [
'drawBorder' => false,
'color' => 'rgba(29,140,248,0.0)',
'zeroLineColor' => 'transparent',
],
]],
],
];
if ($money_format) {
// for Tooltip money format
$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: '" . config('money.' . setting('default.currency') . '.decimal_mark') . "',
@ -154,13 +191,10 @@ trait Charts
return formattedCurrency(tooltipItem.yLabel, moneySettings); return formattedCurrency(tooltipItem.yLabel, moneySettings);
}") }")
], ];
],
'scales' => [ // for Y variable money format
'yAxes' => [[ $options['scales']['yAxes'][0]['ticks']['callback'] = new Raw("function(value, index, values) {
'ticks' => [
'beginAtZero' => true,
'callback' => new Raw("function(value, index, values) {
const moneySettings = { const moneySettings = {
decimal: '" . config('money.' . setting('default.currency') . '.decimal_mark') . "', decimal: '" . config('money.' . setting('default.currency') . '.decimal_mark') . "',
thousands: '". config('money.' . setting('default.currency') . '.thousands_separator') . "', thousands: '". config('money.' . setting('default.currency') . '.thousands_separator') . "',
@ -208,41 +242,9 @@ trait Charts
}; };
return formattedCurrency(value, moneySettings); return formattedCurrency(value, moneySettings);
}"), }");
], }
]
], return $options;
'responsive' => true,
'scales' => [
'yAxes' => [[
'barPercentage' => 1.6,
'ticks' => [
'padding' => 10,
'fontColor' => '#9e9e9e',
],
'gridLines' => [
'drawBorder' => false,
'color' => 'rgba(29,140,248,0.1)',
'zeroLineColor' => 'transparent',
'borderDash' => [2],
'borderDashOffset' => [2],
],
]],
'xAxes' => [[
'barPercentage' => 1.6,
'ticks' => [
'suggestedMin' => 60,
'suggestedMax' => 125,
'padding' => 20,
'fontColor' => '#9e9e9e',
],
'gridLines' => [
'drawBorder' => false,
'color' => 'rgba(29,140,248,0.0)',
'zeroLineColor' => 'transparent',
],
]],
],
];
} }
} }