Created
March 6, 2012 21:53
-
-
Save SebCorbin/1989168 to your computer and use it in GitHub Desktop.
Using highcharts with Drupal 7
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function ($) { | |
Drupal.behaviors.mymodule_charts = { | |
attach:function () { | |
if (Drupal.settings.mymodule.charts) { | |
for (var chart in Drupal.settings.mymodule.charts) { | |
new Highcharts.Chart(Drupal.settings.mymodule.charts[chart]); | |
} | |
} | |
} | |
}; | |
})(jQuery); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Page callback | |
*/ | |
function mymodule_stats() { | |
drupal_add_js(drupal_get_path('module', 'mymodule') . '/highcharts.js'); | |
drupal_add_js(drupal_get_path('module', 'mymodule') . '/mymodule.js'); | |
// Charting | |
$id = 'mychart'; | |
$settings = array( | |
'chart' => array( | |
'renderTo' => 'chart-' . $id, | |
), | |
'xAxis' => array( | |
'categories' => array(1, 2, 3, 4, 5, 6, 7, 8, 9), | |
), | |
'title' => array( | |
'text' => 'Some title', | |
), | |
'series' => array( | |
array( | |
'name' => 'Data label', | |
'data' => array(1, 3, 7, 5, 6, 8, 9, 2, 3, 6), | |
), | |
), | |
'credits' => array( | |
'enabled' => FALSE, | |
), | |
); | |
drupal_add_js(array(array('charts' => array($id => $settings)), 'setting'); | |
$content .= '<div id="chart-'. $id .'"></div>'; | |
return $content; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello,
I need some help I want to build a chart from only one content Type with many author and sort by Autor for each Year. I'm using Hightchart with drupal but the result I get is not good. So can I have your advise?
CT (Statisitque) - Fields [Value(Integer), Date(Month & Year), Author()]