public function FrxSVGGraph::generateGraphData in Forena Reports 7.4
Re-architect the data into something that the graphing engine can work with
1 call to FrxSVGGraph::generateGraphData()
- FrxSVGGraph::prepareGraph in renderers/
FrxSVGGraph.inc
File
- renderers/
FrxSVGGraph.inc, line 40
Class
Code
public function generateGraphData(&$data, $series, $key) {
// Default controlling attributes
$counts = array();
$legend = array();
$this->graphOptions['structure']['value'] = array();
foreach ($series as $col) {
$this->graphOptions['structure']['value'][] = trim("{$col}", '{}');
}
$this->graphData = array();
foreach ($data as $row) {
Frx::Data()
->push($row, '_row');
$trow = array();
// Base group
$trow['key'] = $this->wrap_label ? wordwrap($this->teng
->replace($key, TRUE), $this->wrap_label) : $this->teng
->replace($key, TRUE);
// Dimensions
foreach ($series as $col) {
$val = $this->teng
->replace($col, TRUE);
if ($val != '' && $val !== NULL) {
$trow[trim("{$col}", '{}')] = $val;
@$counts[trim("{$col}", '{}')]++;
}
}
foreach ($this->field_sources as $k => $src) {
$trow[$k] = $this->teng
->replace($src, TRUE);
}
if (isset($this->field_sources['legend_entries'])) {
$legend_str = $trow['legend_entries'];
$legend[$legend_str] = $legend_str;
}
Frx::Data()
->pop();
$this->graphData[] = $trow;
}
$this->counts = $counts;
// Deal with rare case where legend are supposed to come from data
if (isset($this->field_sources['legend_entries'])) {
$this->graphOptions['legend_entries'] = array_values($legend);
}
}