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

New features:

* To minimize the module footprint, all google chart non-hook function are now placed on google_charts.inc
parent d899167b
No related branches found
No related tags found
No related merge requests found
<?php
// $Id$
/**
* @author Bruno Massa http://drupal.org/user/67164
* @file google_charts.inc
* Use Google Charts on your site.
*/
/**
* Encode the Chart data into a Alphanumeric code, follwing the
* Google Chart API instruction. Its needed because there is a
* size limmit to URL strings. So we reduce the amount of characters.
*
* It basicly uses a scale of 61 levels to represent each chart
* value. If a more precise scale is needed, see
* _google_charts_codingextended(), which produces a 4000 levels,
* but also a bigger URL string.
*
* @param $values
* Array. A series of numeric data values
* @param $max
* Number. The biggest number to be the reference point
*/
function _google_charts_codingsimple($values, $max) {
// Set the list of characters and the size of the list
$simple_encoding = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
$strlen = strlen($simple_encoding) - 1;
// The final output is going to be build
$chart_data = 's:';
// For each chart value, encode it
// Note: Underscore represents a missing value
foreach ($values as $current_value) {
if ($current_value >= 0) {
$chart_data .= $simple_encoding[(round($strlen * $current_value / $max))];
}
else {
$chart_data .= '_';
}
}
return $chart_data;
}
function _google_charts_codingextended() {
}
......@@ -42,6 +42,9 @@ function google_charts_chartsinfo($op) {
* Array. The
*/
function google_charts_chartsapi(&$data) {
// Include the specific Google Chart API helper functions
include_once drupal_get_path('module', 'google_charts') .'/google_charts.inc';
// Convert the chat TYPE 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.
......@@ -81,43 +84,3 @@ function google_charts_chartsapi(&$data) {
// If its all ok, build the HTML img tag
return '<img src="http://chart.apis.google.com/chart?'. implode('&amp;', $chart) .'" />';
}
/**
* Encode the Chart data into a Alphanumeric code, follwing the
* Google Chart API instruction. Its needed because there is a
* size limmit to URL strings. So we reduce the amount of characters.
*
* It basicly uses a scale of 61 levels to represent each chart
* value. If a more precise scale is needed, see
* _google_charts_codingextended(), which produces a 4000 levels,
* but also a bigger URL string.
*
* @param $values
* Array. A series of numeric data values
* @param $max
* Number. The biggest number to be the reference point
*/
function _google_charts_codingsimple($values, $max) {
// Set the list of characters and the size of the list
$simple_encoding = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
$strlen = strlen($simple_encoding) - 1;
// The final output is going to be build
$chart_data = 's:';
// For each chart value, encode it
// Note: Underscore represents a missing value
foreach ($values as $current_value) {
if ($current_value >= 0) {
$chart_data .= $simple_encoding[(round($strlen * $current_value / $max))];
}
else {
$chart_data .= '_';
}
}
return $chart_data;
}
function _google_charts_codingextended() {
}
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