laravel-chartjs icon indicating copy to clipboard operation
laravel-chartjs copied to clipboard

How can I change y axis format into number_format()?

Open Granika opened this issue 6 years ago • 1 comments

Thank you for nice plugin. I have problem about changing y axis label into number_format(). can you help to solve this? this is my code

$chartjs2 = app()->chartjs ->name('Payment') ->type('line') ->size(['width' => 400, 'height' => 200]) ->labels(["", $this_month]) ->datasets([ [ "label" => "Payment This Month", 'backgroundColor' => "rgba(1, 212, 1, 0.31)", 'borderColor' => "rgba(38, 185, 154, 0.7)", "pointBorderColor" => "rgba(38, 185, 154, 0.7)", "pointBackgroundColor" => "rgba(38, 185, 154, 0.7)", "pointHoverBackgroundColor" => "#fff", "pointHoverBorderColor" => "rgba(220,220,220,1)", 'data' => ["", $total], ], ]) ->optionsRaw([ 'scales'=>[ 'yAxes'=>[ 'ticks'=>[ 'beginAtZero' => true ], ], ], ]);

Granika avatar Oct 01 '18 08:10 Granika

Chart.js and JavaScript doesn't come with a Laravel like number_format built in. You need a tool like Numeral.js or to write a custom function to format the number in the way that you want.

peterthomson avatar Feb 13 '20 02:02 peterthomson