You are here

function _chart_encode_data in Google Chart Tools: Image Charts 6

Same name and namespace in other branches
  1. 5 chart.module \_chart_encode_data()
  2. 7 chart.module \_chart_encode_data()

Encode an array of data.

Missing data placeholder 'NULL' is replaced the appropriate placeholder.

Return value

string

1 call to _chart_encode_data()
chart_build in ./chart.module
Build chart query data.

File

./chart.module, line 406
Provides Google chart API integration.

Code

function _chart_encode_data($data) {
  $output = '';
  if (count($data)) {
    foreach ($data as $k => $v) {
      if (is_array($v) || is_object($v)) {
        $output .= '|';
        $output .= _chart_encode_data($v);
      }
      else {
        if (is_numeric($v)) {
          $output .= $v . ',';
        }
        else {
          $output .= '-1,';
        }
      }
    }
  }
  return trim($output, '|,');
}