jQuery Sparklines
Component ID
1833756
Component name
jQuery Sparklines
Component type
module
Maintenance status
Development status
Component security advisory coverage
not-covered
Component created
Component changed
Component body
There are already some drupal modules available for generating sparklines, eg sparkline generator and filter and Views Sparkline.
As both modules are not available for drupal 7, I wanted to write my own sparklines module using the jQuery Sparklines plugin.
This module provides a new theme function. This function requires the data you want to represent as sparklines and some options.
Examples
//$page is a render array. The examples are snippets from a bigger array
$sparkline_data = array(7,3,5,9,12);
//default line spark lines in a span element
$page['line_sparklines'] = array(
'#theme' => 'sparklines',
'#values' => $sparkline_data,
);
//example where type of spark lines are changed and the wrapping element is a div
$page['bar_sparklines'] = array(
'#theme' => 'sparklines',
'#values' => $sparkline_data,
'#type' => 'bar',
'#prefix' => '<div>',
'#suffix' => '</div>',
);
