You are here

public function FrxSVGGraph::validSeries in Forena Reports 7.5

1 call to FrxSVGGraph::validSeries()
FrxSVGGraph::render in src/Renderer/FrxSVGGraph.php
Render the graph.

File

src/Renderer/FrxSVGGraph.php, line 319
FrxSVGGraph php SVG Graph generator

Class

FrxSVGGraph

Namespace

Drupal\forena\Renderer

Code

public function validSeries() {
  $valid = TRUE;
  $removed = array();
  if (is_array($this->graphOptions['structure']['value'])) {
    foreach ($this->graphOptions['structure']['value'] as $k => $series) {
      if (!isset($this->counts[$series])) {

        // remove empty series.
        unset($this->graphOptions['structure']['value'][$k]);
        $removed[] = $k;
      }
    }
    if ($removed) {
      $this->graphOptions['structure']['value'] = array_values($this->graphOptions['structure']['value']);
      foreach ($this->graphOptions as $option => $data) {
        if (is_array($data)) {
          $modified = FALSE;
          foreach ($removed as $k) {
            if (isset($data[$k])) {
              unset($this->graphOptions[$option][$k]);
              $modified = TRUE;
            }
          }
          if ($modified) {
            $this->graphOptions[$option] = array_values($this->graphOptions[$option]);
          }
        }
      }
      if (!$this->graphOptions['structure']['value']) {
        $valid = FALSE;
      }
    }
  }
  return $valid;
}