Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

francocsanchez's avatar

chartjs-plugin-datalabels

Hi, I need use pluing chartjs-plugin-datalabels. I use laravel charts My code:

$localidadPaciente = Paciente::Completos()->cantidadLocalidad();

	$labels2 = Arr::pluck($localidadPaciente,'nombre');
	$dataset2 = Arr::pluck($localidadPaciente,'localidad_cantidad');

	$localidadChart = new PacienteLocalidadChart;
	$localidadChart->labels($labels2);
	$localidadChart->dataset('Cantidad', 'bar', $dataset2)->options([
		'borderColor'=>'rgba(255,77,0, 0.7)',
		'backgroundColor' => 'rgba(255,77,0, 0.1)'
	]);;

	$localidadChart->options([
		'responsive' => true,
		'rotation'	=> 0,
		'tooltips' => ['enabled'=>true],
		'legend' => ['display' => false],
		'scales' => [
			'yAxes'=> [[
				'display'=>true,
				'ticks'=> ['beginAtZero'=> true],
				'gridLines'=> ['display'=> true],
			]],
			'xAxes'=> [[
				'display'=>true,
				'categoryPercentage'=> 0.9,
				'barPercentage' => 1,
				'gridLines' => ['display' => false],
				'ticks'=> [
					'fontSize'=> 12,
					'minRotation'=> 90,
					'maxRotation'=> 90
				]
			]],
		],
		'layout' => [
			'padding'=> [
				'left' => 0,
				'right'=> 0,
				'top'=> 0,
				'bottom'=> 0
			]
		]
	]);

How to use this pluing? https://github.com/chartjs/chartjs-plugin-datalabels

0 likes
2 replies

Please or to participate in this conversation.