I am using chart.js to show some data, and everything was working fine when the code was this:
JavaScript/Blade
var pieDataAssignments = [
@for($i = 0;$i<count($name);$i++)
{
value: {!! count(array_filter($ass_c,create_function('$a','return $a=="'.$name[$i].'";')))!!},
color: 'pink',
highlight: "#eaa5a2",
label: 'Subject'
},
@endfor
];
Then I thought it was working, which it was, and I thought to start customising the Pie Chart.
Firstly I tried inserting the value for each variable individually, e.g.
color: {!! $colour[$i] !!},
etc...
That just prevented the pie chart from appearing, which led me to ponder my failure..
I then tried to insert everything into the first Blade call, like so:
Blade
{!!'
{
value:'.count(array_filter($ass_c,create_function('$a','return $a=="'.$name[$i].'";'))).',
color: "'.$colour[$i].'",
highlight: "#eaa5a2",
label: "hi"
},
'!!}
But still, it did not show up.
How can I go about looping JavaScript code and passing php variables at the same time? I don't know what else to try and I can't find anything online apart from telling me to do exactly what I tried.
Thank you in advance.