fxcosta / laravel-chartjs

Simple package to facilitate and automate the use of charts in Laravel 5.x using Chartjs v2 library
486 stars 112 forks source link

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

Open Granika opened 6 years ago

Granika commented 6 years ago

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 ], ], ], ]);

peterthomson commented 4 years ago

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.