The set_labels() for chart_pie() works just fine if I hard code the labels as $my_labels=['one','two','three'];
$mychart = new \core\chart_pie();
$mychart->set_labels($my_labels);
However, if I try to dynamically generate the labels with a foreach loop . . .
$my_labels = array();
foreach($something as $data){
$my_labels[] = $data->name;
}
$mychart = new \core\chart_pie();
$mychart->set_labels($my_labels);
where I build the $my_labels array . . . the chart does not show up . . . with no error. I've tried encode_json/decode_json and I've tried created a "string" that mimics the square bracketed array but I get errors saying that "set_labels()" requires an array, not a string. So it obviously knows I am using an array but just doesn't like the particular format of the array.
I need to create the labels dynamically (as well as the variables).
Any thoughts?