function apachesolr_stats_encodedata in Apache Solr Statistics 6.3
Same name and namespace in other branches
- 6 apachesolr_stats.module \apachesolr_stats_encodedata()
- 7 apachesolr_stats.module \apachesolr_stats_encodedata()
Encode data using Chart's simple encoding. See http://code.google.com/apis/chart/formats.html#simple
Parameters
array $chd: an array of integer values to encode.
integer $chd_min: an integer with the smallest value to encode.
integer $chd_max: an integer with the greatest value to encode.
Return value
string a string representing the Google Charts API simple encoding of the data.
2 calls to apachesolr_stats_encodedata()
- apachesolr_stats_chart in ./
apachesolr_stats.module - Generate an IMG tag with the URL to generate a chart using Google Charts API.
- apachesolr_stats_facet_usage_graph in ./
apachesolr_stats.module - Returns the <img> tag for a Google chart with the facet usage
File
- ./
apachesolr_stats.module, line 447 - Keeps and reports statistics about Apache Solr usage and performance.
Code
function apachesolr_stats_encodedata($chd, $chd_min, $chd_max) {
$encoder_string = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
$encoded_values = '';
if (is_array($chd)) {
foreach ($chd as $value) {
$encoded_values .= substr($encoder_string, ($value - $chd_min) / $chd_max * 61, 1);
}
}
// Google does not like single-valued line charts; fix that.
if (strlen($encoded_values) == 1) {
$encoded_values = "99";
}
return $encoded_values;
}