[SQL charts reports] Added top n report to set the maximum number of elements

This commit is contained in:
fermin831 2018-03-01 16:49:50 +01:00
parent 6e62f4c023
commit b6688dda1c
3 changed files with 9 additions and 10 deletions

View File

@ -3925,7 +3925,7 @@ function graph_custom_sql_graph ($id, $width, $height,
$label = __('Data'); $label = __('Data');
if (!empty($data_item["label"])) { if (!empty($data_item["label"])) {
$label = io_safe_output($data_item["label"]); $label = io_safe_output($data_item["label"]);
if ((strlen($label) > $SQL_GRAPH_MAX_LABEL_SIZE) && ($type !== 'sql_graph_vbar')) { if (strlen($label) > $SQL_GRAPH_MAX_LABEL_SIZE) {
$first_label = $label; $first_label = $label;
$label = substr($first_label, 0, floor($SQL_GRAPH_MAX_LABEL_SIZE/2)); $label = substr($first_label, 0, floor($SQL_GRAPH_MAX_LABEL_SIZE/2));
$label .= '...'; $label .= '...';

View File

@ -3294,7 +3294,8 @@ function reporting_sql_graph($report, $content, $type,
$content["type"], $content["type"],
true, true,
ui_get_full_url(false, false, false, false), ui_get_full_url(false, false, false, false),
$ttl); $ttl,
$content['top_n_value']);
break; break;
case 'data': case 'data':
break; break;

View File

@ -190,14 +190,12 @@ function vbar_graph(
else { else {
$new_chart_data = array(); $new_chart_data = array();
foreach ($chart_data as $key => $value) { foreach ($chart_data as $key => $value) {
if(strlen($key) > 20){ if(strlen($key) > 20 && strpos($key, ' - ') != -1){
if(strpos($key, ' - ') != -1){
$key_temp = explode(" - ",$key); $key_temp = explode(" - ",$key);
$key_temp[0] = $key_temp[0]." \n"; $key_temp[0] = $key_temp[0]." \n";
$key_temp[1]= '...'.substr($key_temp[1],-15); $key_temp[1]= '...'.substr($key_temp[1],-15);
$key2 = $key_temp[0].$key_temp[1]; $key2 = $key_temp[0].$key_temp[1];
io_safe_output($key2); io_safe_output($key2);
}
$new_chart_data[$key2]['g'] = $chart_data[$key]['g']; $new_chart_data[$key2]['g'] = $chart_data[$key]['g'];
} else { } else {
$new_chart_data[$key] = $value; $new_chart_data[$key] = $value;