You are here

public function FrxChart::xmlToValues in Forena Reports 7.3

Same name and namespace in other branches
  1. 6.2 plugins/FrxChart.inc \FrxChart::xmlToValues()
  2. 7.2 plugins/FrxChart.inc \FrxChart::xmlToValues()
1 call to FrxChart::xmlToValues()
FrxChart::render in renderers/FrxChart.inc

File

renderers/FrxChart.inc, line 89
FrxChart Base class for chart generation implementations. @author davidmetzler

Class

FrxChart
@file FrxChart Base class for chart generation implementations. @author davidmetzler

Code

public function xmlToValues($path, $data_path, $label_path = '', $pairs = FALSE) {
  $do = Frx::Data();
  $data = $do
    ->currentContext();
  $values = array();
  if (is_object($data)) {
    $nodes = $data
      ->xpath($path);
    if ($nodes) {
      foreach ($nodes as $i => $node) {
        $do
          ->push($node, $this->id);
        $val = $this->teng
          ->replace($data_path, TRUE);
        if ($label_path) {
          $key = strip_tags($this->teng
            ->replace($label_path, FALSE));
        }
        else {
          $key = $i;
        }
        if ($pairs && $label_path) {
          $values[] = array(
            floatval($key),
            floatval($val),
          );
        }
        else {
          $values[$key] = $val;
        }
        $do
          ->pop();
      }
    }
  }
  return $values;
}