function apachesolr_stats_facet_usage_graph in Apache Solr Statistics 7
Same name and namespace in other branches
- 6.3 apachesolr_stats.module \apachesolr_stats_facet_usage_graph()
- 6 apachesolr_stats.module \apachesolr_stats_facet_usage_graph()
Returns the <img> tag for a Google chart with the facet usage
Parameters
array $facets: An array of calculated data to report.
Return value
string HTML for an IMG tag to a Google chart.
1 call to apachesolr_stats_facet_usage_graph()
- apachesolr_stats_generate_report_elements in ./
apachesolr_stats.module - Generates report elements for the given granularity.
File
- ./
apachesolr_stats.module, line 530 - Keeps and reports statistics about Apache Solr usage and performance.
Code
function apachesolr_stats_facet_usage_graph($facets) {
// Chart for field usage
$leyends = array();
$data = array();
$label_cutoff = 40;
$total_queries = $facets['any']['usage'];
foreach ($facets as $fieldname => $facet) {
$leyend = preg_replace("/^.*ilter by /", "", $facet['info']);
if (strlen($leyend) > $label_cutoff) {
$leyend = substr($leyend, 0, $label_cutoff) . "...";
}
$leyends[] = drupal_encode_path($leyend);
$data[] = $facet['usage'] / $total_queries * 100;
}
$chd = 's:' . apachesolr_stats_encodedata($data, 0, 100);
// array_reverse() in next line due to apachesolr_stats_encodedata() encoding data backwards
$chl = implode('|', array_reverse($leyends));
$height = 30 + sizeof($leyends) * 28;
// Percentage labels
$chm = "N*f0*%,000000,0,-1,11";
$chart = "<img src='http://chart.apis.google.com/chart?chxt=y&cht=bhs&chma=20,20,20,20&chd={$chd}&chs=350x{$height}&chds=0,100&chxl=0:|{$chl}&chm={$chm}' />";
return $chart;
}