2π
β
$chartOsData['data']['datasets']['data'][] = (int)$o->total;
$chartOsData['data']['datasets']['backgroundColor'][] = $tiposOs[$o->status];
Here youβre constructing datasets
as an object with the keys data
and backgroundColor
.
datasets: [
{
data: [300, 50, 100],
backgroundColor: [...],
}
]
Here youβre showing that datasets
should be an array containing one object with those keys.
The fix is simple: make datasets
an array:
$chartOsData['data']['datasets'][0]['data'][] = (int)$o->total;
$chartOsData['data']['datasets'][0]['backgroundColor'][] = $tiposOs[$o->status];
^^^
Source:stackexchange.com