Charts
Charts copied to clipboard
[QUESTION] Chartjs legend position
Is there any way to change the position of legend?
Is there any way to change the position of legend?
hello,
I used it this way
$chart->options([ 'legend' => [ 'position' => 'bottom', ] ]);
Is there any way to change the position of legend?
hello, I used it this way
$chart->options([ 'legend' => [ 'position' => 'bottom', ] ]);
Thanks for posting this question and answer! I tried doing exactly what you did, @SantanuDatta, and my legend position is still top. Any other advice to get my legend to the bottom of the chart?
First I created a chart
php artisan make:chart {Name} {Library?}
then inside that chart function, I used it like this
public function __construct()
{
parent::__construct();
$this->options([
'responsive' => true,
'legend' => [
'position' => 'bottom',
],
'scales' => [
'yAxes' => [
[
'ticks' => [
'beginAtZero' => true,
],
'gridLines' => [
'display' => true,
'color' => 'rgba(0, 0, 0, 0.1)',
],
],
],
'xAxes' => [
[
'gridLines' => [
'display' => true,
],
],
],
],
]);
}
and the main work I did inside the controller and it worked for me