public static function Util::viewsData in Charts 8
Same name and namespace in other branches
- 8.4 src/Util/Util.php \Drupal\charts\Util\Util::viewsData()
- 8.3 src/Util/Util.php \Drupal\charts\Util\Util::viewsData()
- 5.0.x src/Util/Util.php \Drupal\charts\Util\Util::viewsData()
Parameters
$view:
$labelValues:
$labelField:
$color:
Return value
array
1 call to Util::viewsData()
File
- src/
Util/ Util.php, line 14
Class
Namespace
Drupal\charts\UtilCode
public static function viewsData($view, $labelValues, $labelField, $color) {
$data = array();
foreach ($view->result as $id => $row) {
$numberFields = 0;
$rowData = array();
foreach ($labelValues as $fieldId => $rowDataValue) {
$rowData[$numberFields] = array(
'value' => $view->field[$fieldId]
->getValue($row),
'label_field' => $view->field[$labelField]
->getValue($row),
'label' => $view->field[$fieldId]
->label(),
// 'label' => $view->display_handler->display['id'], to use display_id
'color' => $color[$fieldId],
);
$numberFields++;
}
$data[$id] = $rowData;
}
return $data;
}