
Add a custom chartjs module to integrate chart.js with Drupal. Extend the membership report by a bar chart, and the membership history report by a line chart. Change-Id: Ifb134b632e593c88d81b44e97cb1a2c73626f0a8
56 lines
1.3 KiB
Plaintext
56 lines
1.3 KiB
Plaintext
<?php
|
|
|
|
/**
|
|
* Implements hook_libraries_info().
|
|
*
|
|
* @see Libraries module.
|
|
*/
|
|
function chartjs_libraries_info() {
|
|
$libraries['chartjs'] = array(
|
|
'name' => 'Chart.js',
|
|
'vendor url' => 'http://www.chartjs.org/',
|
|
'download url' => 'https://github.com/nnnick/Chart.js/archive/v1.0.1.tar.gz',
|
|
// 'version callback' => 'short_circuit_version',
|
|
'version arguments' => array(
|
|
'file' => 'Chart.js',
|
|
'pattern' => '/Version: (\d+\.+\d+\.+\d+)/',
|
|
'lines' => 4,
|
|
),
|
|
'files' => array(
|
|
'js' => array(
|
|
'Chart.js',
|
|
),
|
|
),
|
|
);
|
|
return $libraries;
|
|
}
|
|
|
|
/**
|
|
* Implements hook_element_info()
|
|
*/
|
|
function chartjs_element_info() {
|
|
require_once 'chartjs_elements.inc';
|
|
return _chartjs_element_info();
|
|
}
|
|
|
|
/**
|
|
* Implements hook_theme()
|
|
*/
|
|
function chartjs_theme($existing, $type, $theme, $path) {
|
|
require_once 'chartjs_elements.inc';
|
|
return _chartjs_theme($existing, $type, $theme, $path);
|
|
}
|
|
|
|
/**
|
|
* Construct a new dataset with defaults
|
|
*/
|
|
function chartjs_create_dataset($data = array()) {
|
|
$dataSet = new stdClass();
|
|
$dataSet->label = 'Dataset label';
|
|
$dataSet->fillColor = 'rgba(128,197,229,1)';
|
|
$dataSet->strokeColor = 'rgba(128,197,229,1)';
|
|
$dataSet->highlightFill = 'rgba(0,153,218,1)';
|
|
$dataSet->highlightStroke = 'rgba(0,153,218,1)';
|
|
$dataSet->data = $data;
|
|
return $dataSet;
|
|
} |