You are here

function FrxSVGGraph::generateCrossTab in Forena Reports 8

Generate a crosstab table.

Parameters

\SimpleXMLElement $xml: Preview data to generate report frx

array $config: Configuration array for reprot.

\DOMNode $div: Node of containing dif

string $group: Token to group on

string $dim: Token to use as dimension of crosstab

1 call to FrxSVGGraph::generateCrossTab()
FrxSVGGraph::generate in src/FrxPlugin/Template/FrxSVGGraph.php

File

src/FrxPlugin/Template/FrxSVGGraph.php, line 592
FrxSVGGraph php SVG Graph generator

Class

FrxSVGGraph

Namespace

Drupal\forena\Template

Code

function generateCrossTab($xml, &$config, &$div, $group, $dim) {
  $attrs = array();
  $table_frx['renderer'] = 'FrxCrosstab';
  $table_frx['group'] = is_array($group) ? implode(' ', $group) : $group;
  $table_frx['dim'] = $dim;
  $table = $this
    ->setFirstNode($div, 4, 'table', NULL, $attrs, $table_frx);
  $thead = $this
    ->setFirstNode($table, 6, 'thead');
  $throw = $this
    ->setFirstNode($thead, 8, 'tr');
  $tbody = $this
    ->setFirstNode($table, 6, 'tbody');
  $tdrow = $this
    ->setFirstNode($tbody, 8, 'tr', NULL, NULL, $attrs);
  if ($config['crosstab_columns']) {
    foreach ($config['crosstab_columns'] as $key => $col) {
      if ($col['type'] !== 'ignore') {
        if ($col['type'] == 'heading') {
          $tag = 'th';
        }
        else {
          $tag = 'td';
        }
        if ($col['type'] != 'crosstab') {
          $this
            ->addNode($throw, 10, $tag, $col['label']);
          $this
            ->addNode($tdrow, 10, $tag, $col['contents']);
        }
      }
    }
  }
}