You are here

public function FrxSVGGraph::validSeries in Forena Reports 8

Same name in this branch
  1. 8 src/FrxPlugin/Template/FrxSVGGraph.php \Drupal\forena\Template\FrxSVGGraph::validSeries()
  2. 8 src/FrxPlugin/Renderer/FrxSVGGraph.php \Drupal\forena\FrxPlugin\Renderer\FrxSVGGraph::validSeries()

File

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

Class

FrxSVGGraph

Namespace

Drupal\forena\Template

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;
}