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

New features:

* On settings page, the example data is now a array with data series
* _charts_module_invoke_all() is about the same as module_invoke_all(), but will sum the array results instead merge_recursively
parent 3a5a6a6b
No related branches found
No related tags found
No related merge requests found
......@@ -6,6 +6,31 @@
* Transform DATA into INFORMATION using beautiful CHARTS.
*/
/**
* Invoke a hook in all enabled modules that implement it.
*
* Its copy of module_invoke_all()
* @see module_invoke_all()
*/
function _charts_module_invoke_all() {
$args = func_get_args();
$hook = $args[0];
unset($args[0]);
$return = array();
foreach (module_implements($hook) as $module) {
$function = $module .'_'. $hook;
$result = call_user_func_array($function, $args);
if (isset($result) && is_array($result)) {
$return += $result;
}
else if (isset($result)) {
$return[] = $result;
}
}
return $return;
}
/**
* Module settings page. Users can set the default layout
* of their charts.
......@@ -20,7 +45,9 @@ function _charts_settings() {
if (!empty($settings)) {
// Since the chart is an example, we should provide
// and example data.
$settings['data'] = array(10, 20, 55, 72, 35, 23);
$settings['data'] = array(
array(10, 20, 55, 72, 35, 23)
);
$form['chart'] = array(
'#value' => charts_chart($settings['basic']['provider'], $settings)
......@@ -28,11 +55,11 @@ function _charts_settings() {
}
// Basic info:
// - Provider: which is the Chart API that will be used, like Google,
// Open Flash Chart, FusionCharts...
// - Type: there are dozen types of charts, like 'Line', 'Bar',
// 'Scatter Plot', 'Pie'. And for each version, it can
// be in 3D or 2D, vertical or hotizontal.
// - provider: which is the Chart API that will be used, like Google,
// Open Flash Chart, FusionCharts...
// - charttypes: there are dozen types of charts, like 'Line', 'Bar',
// 'Scatter Plot', 'Pie'. And for each version, it can
// be in 3D or 2D, vertical or hotizontal...
$form['basic'] = array(
'#type' => 'fieldset',
'#title' => t('Basic'),
......@@ -47,7 +74,7 @@ function _charts_settings() {
'#type' => 'select',
'#title' => t('Chart provider'),
);
$options = module_invoke_all('chartsinfo', 'charttypes');
$options = _charts_module_invoke_all('chartsinfo', 'charttypes');
$form['basic']['charttype'] = array(
'#default_value' => empty($settings['basic']['charttype']) ? '' : $settings['basic']['charttype'],
'#options' => $options,
......
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