You are here

function _google_charts_render in Charts 6

Same name and namespace in other branches
  1. 7 google_charts/google_charts.inc \_google_charts_render()

Implementation of hook_charts_render().

Its a Charts module hook. It transform the data into a HTML chart.

Parameters

&$data: Array. The

1 string reference to '_google_charts_render'
google_charts_charts_info in google_charts/google_charts.module
Implementation of hook_charts_info().

File

google_charts/google_charts.inc, line 107
@author Bruno Massa http://drupal.org/user/67164

Code

function _google_charts_render(&$data) {
  $chart = array();
  if ($message = _google_charts_chart($chart, $data)) {
    return $message;
  }

  // Convert the chat DATA into the Google Chart way.
  // Since its a requirement to build the chart on Google, if the value
  // was not found, return nothing and stop the execution.
  if ($message = _google_charts_series($chart, $data)) {
    return $message;
  }

  // Browsers tend to load images in sequence, so Google allow users to put a
  // number before the chart.apis.google.com so browsers think they can download
  // in simultaneously
  // @TODO
  //   static $count = 1;
  //   $count++;
  //   if ($count == 10)
  //   {
  //     $count = 0;
  //   }
  // If its all ok, build the HTML img tag
  return '<img src="http://chart.apis.google.com/chart?' . implode('&amp;', $chart) . '" alt= ""/>';
}