function ChartsOpenFlash::get_chart in Charts and Graphs 7
Same name and namespace in other branches
- 6 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 139
Class
Code
function get_chart() {
$unique = chart_graphs_random_hash();
// Make current object a StdClass() for easier de-serialization
$arr = (array) $this;
$generic = (object) $arr;
cache_set($unique, $generic, 'cache', time() + 30);
//Keep for at least 30 seconds;
$mod_path = drupal_get_path('module', $this
->getModuleName());
$openflash_swf_uri = base_path() . $mod_path . '/open-flash-chart.swf';
$data_URI = base_path() . '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();
**/
$swfobj_mod_path = drupal_get_path('module', 'swfobject_api');
$swfobj_js = $swfobj_mod_path . '/swfobject.js';
$expressInst = base_path() . $swfobj_mod_path . '/expressInstall.swf';
$chart_div_id = "drp_charts_graphs_" . $this
->getUnique_ID();
drupal_add_js($swfobj_js, 1);
return <<<HTML
<script type="text/javascript">
swfobject.embedSWF(
"{<span class="php-variable">$openflash_swf_uri</span>}", "{<span class="php-variable">$chart_div_id</span>}", "{<span class="php-variable">$this</span>-><span class="php-function-or-constant property member-of-self">width</span>}", "{<span class="php-variable">$this</span>-><span class="php-function-or-constant property member-of-self">height</span>}",
"9.0.0", "{<span class="php-variable">$expressInst</span>}",
{"data-file":"{<span class="php-variable">$data_URI</span>}"}
);
</script>
<div id="{<span class="php-variable">$chart_div_id</span>}"></div>
HTML;
}