Skip to content
Snippets Groups Projects
Commit 8c913542 authored by Bruno Massa's avatar Bruno Massa
Browse files

Misc:

* Since the include file is done before calling the render function, it doesnt need to be on the .module file
parent 2ddf964c
No related branches found
No related tags found
No related merge requests found
......@@ -73,6 +73,75 @@ function _fusioncharts_chart(&$chart, &$data) {
$chart['attributes']['caption'] = $data['#title'];
}
/**
* Immplementation of hook_charts_render().
*
* Its a Charts module hook. It transform the data into a HTML chart.
*
* @param &$data
* Array. The
*/
function _fusioncharts_charts_render(&$data) {
// Include the specific Google Chart API helper functions
include_once drupal_get_path('module', 'fusioncharts') .'/fusioncharts.inc';
// Convert the chat TYPE into the FusionCharts way.
// Since its a requirement to build the chart on Google, if the value
// was not found, return nothing and stop the execution.
$options = array(
'line2D' => '/swf/MSLine.swf',
'hbar2D' => '/swf/MSBar2D.swf',
'hbar3D' => '/swf/MSBar3D.swf',
'vbar2D' => '/swf/MSColumn2D.swf',
'vbar3D' => '/swf/MSColumn3D.swf',
'pie2D' => '/swf/Pie2D.swf',
'pie3D' => '/swf/Pie3D.swf',
);
if (empty($options[$data['#type']])) {
return t('This type is not possible using %chartplugin',
array('%chartplugin' => 'FusionCharts'));
}
$file = url(drupal_get_path('module', 'fusioncharts') . $options[$data['#type']]);
// Convert the chat SIZE into the FusionCharts way.
// Since its a requirement to build the chart on Google, if the value
// was not found, return nothing and stop the execution.
if (empty($data['#width']) or empty($data['#height'])) {
return '';
}
$width = $data['#width'];
$height = $data['#height'];
$chart = array(
'key' => 'chart',
'value' => array()
);
if ($message = _fusioncharts_chart($chart, $data)) {
return $message;
}
$series = '_fusioncharts_series';
if ($data['#type'] == 'pie2D' or $data['#type'] == 'pie3D') {
$series = '_fusioncharts_series_single';
}
if ($message = $series($chart, $data)) {
return $message;
}
$chart = '&dataXML='. str_replace('"', "'", format_xml_elements(array($chart)));
// Its the HTML tag to include the chart
return <<<FUSIONCHARTS
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000">
<param name="allowScriptAccess" value="always" />
<param name="FlashVars" value="$chart" />
<param name="quality" value="high" />
<embed src="$file" flashVars="$chart" width="$width" height="$height" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
</object>
FUSIONCHARTS;
}
/**
* Convert all Series-level data.
*
......
......@@ -20,7 +20,7 @@ function fusioncharts_charts_info() {
'fusioncharts' => array(
'file' => drupal_get_path('module', 'fusioncharts') .'/fusioncharts.inc',
'name' => t('FusionCharts'),
'render' => 'fusioncharts_charts_render',
'render' => '_fusioncharts_charts_render',
'types' => array(
'line2D' => t('Line 2D'),
'hbar2D' => t('Horizontal Bar 2D'),
......@@ -33,72 +33,3 @@ function fusioncharts_charts_info() {
),
);
}
/**
* Immplementation of hook_charts_render().
*
* Its a Charts module hook. It transform the data into a HTML chart.
*
* @param &$data
* Array. The
*/
function fusioncharts_charts_render(&$data) {
// Include the specific Google Chart API helper functions
include_once drupal_get_path('module', 'fusioncharts') .'/fusioncharts.inc';
// Convert the chat TYPE into the FusionCharts way.
// Since its a requirement to build the chart on Google, if the value
// was not found, return nothing and stop the execution.
$options = array(
'line2D' => '/swf/MSLine.swf',
'hbar2D' => '/swf/MSBar2D.swf',
'hbar3D' => '/swf/MSBar3D.swf',
'vbar2D' => '/swf/MSColumn2D.swf',
'vbar3D' => '/swf/MSColumn3D.swf',
'pie2D' => '/swf/Pie2D.swf',
'pie3D' => '/swf/Pie3D.swf',
);
if (empty($options[$data['#type']])) {
return t('This type is not possible using %chartplugin',
array('%chartplugin' => 'FusionCharts'));
}
$file = url(drupal_get_path('module', 'fusioncharts') . $options[$data['#type']]);
// Convert the chat SIZE into the FusionCharts way.
// Since its a requirement to build the chart on Google, if the value
// was not found, return nothing and stop the execution.
if (empty($data['#width']) or empty($data['#height'])) {
return '';
}
$width = $data['#width'];
$height = $data['#height'];
$chart = array(
'key' => 'chart',
'value' => array()
);
if ($message = _fusioncharts_chart($chart, $data)) {
return $message;
}
$series = '_fusioncharts_series';
if ($data['#type'] == 'pie2D' or $data['#type'] == 'pie3D') {
$series = '_fusioncharts_series_single';
}
if ($message = $series($chart, $data)) {
return $message;
}
$chart = '&dataXML='. str_replace('"', "'", format_xml_elements(array($chart)));
// Its the HTML tag to include the chart
return <<<FUSIONCHARTS
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000">
<param name="allowScriptAccess" value="always" />
<param name="FlashVars" value="$chart" />
<param name="quality" value="high" />
<embed src="$file" flashVars="$chart" width="$width" height="$height" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
</object>
FUSIONCHARTS;
}
......@@ -85,6 +85,34 @@ function _google_charts_data_codingsimple($value, $max) {
}
}
/**
* Immplementation of hook_charts_render().
*
* Its a Charts module hook. It transform the data into a HTML chart.
*
* @param &$data
* Array. The
*/
function _google_charts_render(&$data) {
// Include the specific Google Chart API helper functions
include_once drupal_get_path('module', 'google_charts') .'/google_charts.inc';
$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;
}
// If its all ok, build the HTML img tag
return '<img src="http://chart.apis.google.com/chart?'. implode('&amp;', $chart) .'" />';
}
/**
* Convert all Series-level data.
*
......
......@@ -20,7 +20,7 @@ function google_charts_charts_info() {
'google' => array(
'file' => drupal_get_path('module', 'google_charts') .'/google_charts.inc',
'name' => t('Google Chart'),
'render' => 'google_charts_charts_render',
'render' => '_google_charts_render',
'types' => array(
'line2D' => t('Line 2D'),
'hbar2D' => t('Horizontal Bar 2D'),
......@@ -33,31 +33,3 @@ function google_charts_charts_info() {
),
);
}
/**
* Immplementation of hook_charts_render().
*
* Its a Charts module hook. It transform the data into a HTML chart.
*
* @param &$data
* Array. The
*/
function google_charts_charts_render(&$data) {
// Include the specific Google Chart API helper functions
include_once drupal_get_path('module', 'google_charts') .'/google_charts.inc';
$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;
}
// If its all ok, build the HTML img tag
return '<img src="http://chart.apis.google.com/chart?'. implode('&amp;', $chart) .'" />';
}
......@@ -21,6 +21,31 @@ function _openflashchart_chart(&$chart, &$data) {
$chart->set_bg_colour($data['#color']);
}
/**
* Immplementation of hook_charts_render().
*
* Its a Charts module hook. It transform the data into a HTML chart.
*
* @param &$data
* Array. The
*/
function _openflashchart_charts_render(&$data) {
// Include the specific Open Flash Chart helper functions
include_once drupal_get_path('module', 'openflashchart') .'/openflashchart.inc';
$chart = new open_flash_chart_api();
if ($error = _openflashchart_chart($chart, $data)) {
return $error;
}
if ($error = _openflashchart_series($chart, $data)) {
return $error;
}
return $chart->render();
}
/**
* Convert all Series-level data.
*
......
......@@ -30,28 +30,3 @@ function openflashchart_charts_info() {
),
);
}
/**
* Immplementation of hook_charts_render().
*
* Its a Charts module hook. It transform the data into a HTML chart.
*
* @param &$data
* Array. The
*/
function _openflashchart_charts_render(&$data) {
// Include the specific Open Flash Chart helper functions
include_once drupal_get_path('module', 'openflashchart') .'/openflashchart.inc';
$chart = new open_flash_chart_api();
if ($error = _openflashchart_chart($chart, $data)) {
return $error;
}
if ($error = _openflashchart_series($chart, $data)) {
return $error;
}
return $chart->render();
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment