如何解决Laravel中的htmlspecialchars()错误?

I facing the error below in Laravel:

htmlspecialchars() expects parameter 1 to be string, array given

Which is appearing when I return data as array

$yAxis = array_reverse($data_array['counter']);
$xAxis = array_reverse($data_array['date']);

Instead of

$yAxis = collect($graphData)->pluck('counter');
$xAxis = collect($graphData)->pluck('date'); 

Actually, I can't return data as collection because I am modifying before passing to view, so how to pass an array or convert it into a collection to fix the issue.

I would really appreciate if you could kindly guide me. Thank you so much.