public function FrxSVGGraph::scrapeConfig in Forena Reports 8
Derive config variables from graph.
Overrides TemplateInterface::scrapeConfig
File
- src/
FrxPlugin/ Template/ FrxSVGGraph.php, line 190 - FrxSVGGraph php SVG Graph generator
Class
Namespace
Drupal\forena\TemplateCode
public function scrapeConfig(\SimpleXMLElement $xml) {
$this->weight = 0;
$nodes = $this->reportDocNode
->xpath('svg');
if ($nodes) {
$svg = $nodes[0];
$config = $this
->mergedAttributes($svg);
}
$table_nodes = $this->reportDocNode
->xpath('table');
$config['gen_table'] = $table_nodes ? 1 : 0;
// Determine graph type
$graph_type = isset($config['type']) ? $config['type'] : 'BarGraph';
$types = $this
->graphTypes();
$types = array_change_key_case($types);
$config['base_type'] = $types[strtolower($graph_type)]['type'];
$this
->extractTemplateHTML($this->reportDocDomNode, $config, array(
'svg',
'table',
));
if (!isset($config['key'])) {
$config['key'] = @$config['label'];
}
if (!isset($config['key'])) {
$config['key'] = @$config['seriesx'];
}
$key = $config['key'];
$dim = @$config['dim'];
$series = @(array) $config['series'];
if ($key) {
$keys = explode(' ', $key);
foreach ($keys as $k) {
$this
->addColumn('heading', $k, trim($k, '{}'), $config);
}
}
if ($series) {
foreach ($series as $col) {
$this
->addColumn('value', $col, trim($col, '{}'), $config);
}
}
// Get the data cells
if ($dim) {
$dims = (array) $dim;
foreach ($dims as $dim) {
$this
->addColumn('crosstab', $dim, trim($dim, '{}'), $config);
}
}
$config['style'] = $config['type'];
return $config;
}