You are here

function ChartsGraphsOpenFlash::get_chart in Charts and Graphs 7

Same name and namespace in other branches
  1. 6.2 apis/charts_graphs_open_flash/charts_graphs_open_flash.class.inc \ChartsGraphsOpenFlash::get_chart()

Function that renders data.

Overrides ChartsGraphsCanvas::get_chart

File

apis/charts_graphs_open_flash/charts_graphs_open_flash.class.inc, line 224

Class

ChartsGraphsOpenFlash
Implementation of abstract class ChartsGraphsFlashCanvas for Open Charts Flash 2 library.

Code

function get_chart() {
  global $base_url;
  $unique = charts_graphs_random_hash();

  // Make current object a StdClass() for easier de-serialization
  $this->translated_type = $this
    ->_get_translated_chart_type();
  $arr = (array) $this;
  $generic = (object) $arr;

  //Keep for at least 30 seconds;
  cache_set($unique, $generic, 'cache', REQUEST_TIME + 30);
  $mod_path = drupal_get_path('module', $this
    ->getModuleName());
  $openflash_swf_uri = $base_url . '/' . $mod_path . '/open-flash-chart.swf';

  // TODO The second parameter to this function call should be an array.
  $data_URL = url('charts_graphs_open_flash/data/' . $unique, array(
    'absolute' => TRUE,
  ));

  /** For debugging
   * $ret = drupal_http_request( $data_URL );
   * echo "<pre>".print_r ( $ret,true)."</pre>";
   * exit();
   * */
  $wmode = $this
    ->get_wmode();
  $flashvars = array(
    'data-file' => 'SWFDATAURL',
    'preloader_color' => '#999999',
    'wmode' => $wmode,
  );
  $args = array(
    'params' => array(
      'width' => $this->width,
      'height' => $this->height,
      'wmode' => $wmode,
    ),
    'flashvars' => $flashvars,
  );
  $out = swf($openflash_swf_uri, $args);
  $out = str_replace('SWFDATAURL', $data_URL, $out);
  $element = array(
    '#markup' => $out,
  );
  return $element;
}