function d3_views_plugin_style_d3::aggregate in d3.js 7
Wrapper function to determine the methods to use, and execute it.
File
- modules/
d3_views/ views/ plugins/ d3_views_plugin_style_d3.inc, line 195 - Contains the d3 style plugin.
Class
- d3_views_plugin_style_d3
- Style plugin to render a d3 visualization
Code
function aggregate() {
$vis =& $this
->getVis();
$map = $this->controller->mapping
->getMapping();
$fields = $this->controller
->getFields();
// Loop through mapping to get aggregation settings.
foreach ($map as $key => $values) {
// Has subfields.
if (is_array($values)) {
// Convert the settings to numeric to match the already numeric array.
$numeric = !empty($fields[$key]['_info']['data_type']) && $fields[$key]['_info']['data_type'] == '2dnnv';
$index = 0;
foreach ($values as $k => $v) {
// We have to pas the field name to the getAggregation function, whereas
// we need to pass the index to the aggregation function.
// Only if it's a numeric array.
if (($aggregation = $this
->getAggregation($key, $k)) && method_exists($this, $aggregation . 'Multiple')) {
$k = $numeric ? $index : $k;
$vis[$key] = $this
->{$aggregation . 'Multiple'}($vis[$key], $k);
}
$index++;
}
}
else {
if (($aggregation = $this
->getAggregation($key)) && method_exists($this, $aggregation)) {
$vis[$key] = $this
->{$aggregation}($vis[$key]);
}
}
}
}