mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-29 16:55:05 +02:00
Merge branch 'ent-8892-Widget-TopN-sale-mal' into 'develop'
Set better visual style for show top-n widgets See merge request artica/pandorafms!4851
This commit is contained in:
commit
e7a136e5f5
@ -454,11 +454,38 @@ class TopNWidget extends Widget
|
|||||||
}
|
}
|
||||||
|
|
||||||
$data_hbar = [];
|
$data_hbar = [];
|
||||||
|
$valueMax = 0;
|
||||||
|
$valueMin = 0;
|
||||||
|
$booleanModulesCount = 0;
|
||||||
|
$booleanModulesTypes = [
|
||||||
|
2,
|
||||||
|
6,
|
||||||
|
9,
|
||||||
|
18,
|
||||||
|
35,
|
||||||
|
];
|
||||||
|
|
||||||
foreach ($modules as $module) {
|
foreach ($modules as $module) {
|
||||||
$module['aliasAgent'] = ui_print_truncate_text($module['aliasAgent'], 20);
|
$module['aliasAgent'] = ui_print_truncate_text($module['aliasAgent'], 20);
|
||||||
$item_name = '';
|
|
||||||
$item_name = $module['aliasAgent'].' - '.$module['nameModule'];
|
$item_name = $module['aliasAgent'].' - '.$module['nameModule'];
|
||||||
$data_hbar[$item_name]['g'] = $module[$display];
|
$data_hbar[$item_name]['g'] = $module[$display];
|
||||||
|
// Calculation of max-min values for show in graph.
|
||||||
|
$calc = (ceil((5 * (float) $module[$display]) / 100) + $module[$display]);
|
||||||
|
// Set of max-min values for graph.
|
||||||
|
$valueMax = ((int) $module[$display] >= $valueMax) ? $calc : (int) $valueMax;
|
||||||
|
$valueMin = ((int) $module[$display] < $valueMin) ? $calc : (int) $valueMin;
|
||||||
|
// Count if all modules are booleans (for visual representation).
|
||||||
|
if (in_array($module['type_module'], $booleanModulesTypes) === true) {
|
||||||
|
$booleanModulesCount++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($booleanModulesCount === count($modules)) {
|
||||||
|
// All modules are booleans. By this, only are allowed 0 or 1.
|
||||||
|
$valueMax = 1;
|
||||||
|
} else if ((int) $valueMax === (int) $valueMin) {
|
||||||
|
// This change is for get more space between values.
|
||||||
|
$valueMax += 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
$height = (count($data_hbar) * 25 + 35);
|
$height = (count($data_hbar) * 25 + 35);
|
||||||
@ -480,7 +507,9 @@ class TopNWidget extends Widget
|
|||||||
1,
|
1,
|
||||||
$config['homeurl'],
|
$config['homeurl'],
|
||||||
'white',
|
'white',
|
||||||
'#DFDFDF'
|
'#DFDFDF',
|
||||||
|
$valueMin,
|
||||||
|
$valueMax
|
||||||
);
|
);
|
||||||
$output .= '</div>';
|
$output .= '</div>';
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user