$chart->columns(array(
//Each column key should correspond to a field in your data array
'name' => array(
//Tells the chart what type of data this is
'type' => 'array',
//The chart label for this column
'label' => 'Name'
),
'manager' => array(
//Tells the chart what type of data this is
'type' => 'string',
//The chart label for this column
'label' => 'Manager'
)
));
foreach($users as $user){
//$chart->addRow($user['User']);
$name = array();
$name['v'] = $user['User']['name'];
$name['f'] = $user['User']['name'].'<div class="text-muted text-info">'.$user['Role']['name'].'</div>';
$chart->addRow( array('name' => $name, 'manager' => $user['Manager']['name']) );
}
Update to handle 'array' column type. Use case: 'Org Chart Type', with
v
andf
format data. Example data (from the Google Charts page):From Controller, the following code works now: