You are here

function ChartsOpenFlash::get_chart in Charts and Graphs 6

Same name and namespace in other branches
  1. 7 apis/charts_openflash/charts_openflash.class.inc \ChartsOpenFlash::get_chart()

Function that renders data.

Overrides ChartCanvas::get_chart

File

apis/charts_openflash/charts_openflash.class.inc, line 200
Implementation of abstract class ChartCanvas for Open Charts Flash 2 library.

Class

ChartsOpenFlash
Implementation of abstract class ChartCanvas for Open Charts Flash 2 library.

Code

function get_chart() {
  $unique = chart_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', time() + 30);
  $mod_path = drupal_get_path('module', $this
    ->getModuleName());
  $openflash_swf_uri = $mod_path . '/open-flash-chart.swf';
  $openflash_swf_uri = url($openflash_swf_uri, array(
    'absolute' => TRUE,
  ));
  $data_URI = base_path() . '?q=charts_openflash/data/' . $unique;
  $data_URL = url($data_URI, 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_URI, $out);
  return $out;
}