2👍
✅
However, instead of manually calling json_encode, you may use the @json Blade directive. The @json directive accepts the same arguments as PHP’s json_encode function.
Please like this json_encode in laravel blade
<script>
var ctx = document.getElementById('lineChart').getContext('2d');
var myChart = new Chart(ctx, {
type: 'bar',
data: {
labels: @json($title),
datasets: [{
label: '# ',
data: @json($learning),
backgroundColor: ["#3e95cd"],
borderWidth: 1
}]
},
options: {
scales: {
yAxes: [{
ticks: {
beginAtZero: true
}
}]
}
}
});
</script>
Source:stackexchange.com