Fixed label shortener in hbar
This commit is contained in:
parent
199b81a79c
commit
835e791ef1
|
@ -653,13 +653,13 @@ function hbar_graph($flash_chart, $chart_data, $width, $height,
|
|||
else {
|
||||
|
||||
foreach ($chart_data as $key => $value) {
|
||||
if(strlen($key) > 40){
|
||||
if(strpos($key, ' - ') != -1){
|
||||
$key_temp = explode(" - ",$key);
|
||||
$key_temp[0] = $key_temp[0]." \n";
|
||||
$str_key = io_safe_output($key);
|
||||
if(strlen($str_key) > 40){
|
||||
if(strpos($str_key, ' - ') != -1){
|
||||
$key_temp = explode(" - ",$str_key);
|
||||
$key_temp[0] = $key_temp[0]." <br>";
|
||||
$key_temp[1]= '...'.substr($key_temp[1],-20);
|
||||
$key2 = $key_temp[0].$key_temp[1];
|
||||
io_safe_output($key2);
|
||||
}
|
||||
$chart_data[$key2]['g'] = $chart_data[$key]['g'];
|
||||
unset($chart_data[$key]);
|
||||
|
|
|
@ -419,28 +419,22 @@ function pandoraFlotHBars(graph_id, values, labels, water_mark,
|
|||
for (i = 0; i < labels_total.length; i++) {
|
||||
var label = labels_total[i][1];
|
||||
// var shortLabel = reduceText(label, 25);
|
||||
var title = '';
|
||||
// if (label !== shortLabel) {
|
||||
title = label;
|
||||
// label = shortLabel;
|
||||
// }
|
||||
|
||||
if(label.length > 30){
|
||||
if(label.indexOf(" - ")){
|
||||
var label_temp = label.split(" - ");
|
||||
}
|
||||
else if(label.indexOf(" ")){
|
||||
var label_temp = label.split(" ");
|
||||
}
|
||||
else{
|
||||
var label_temp = '';
|
||||
label_temp[0] = label.substring(0, (label.length/2));
|
||||
label_temp[1] = label.substring((label.length/2));
|
||||
}
|
||||
label = reduceText(label_temp[0], 20)+"<br>"+reduceText(label_temp[1], 20);
|
||||
var title = label;
|
||||
var margin_top = 0;
|
||||
if(label.length > 33){
|
||||
label = reduceText(label, 33);
|
||||
}
|
||||
|
||||
format.push([i,'<div style="font-size:'+font_size+'pt !important; word-break:keep-all; max-width: 150px;margin-right:20px;" title="'+title+'" class="'+font+'">'
|
||||
var div_attributes = 'style="font-size:'+font_size+'pt !important;'
|
||||
+ ' margin: 0; max-width: 150px;'
|
||||
+ 'margin-right:5px;';
|
||||
|
||||
if (label.indexOf("<br>") != -1) {
|
||||
div_attributes += "min-height: 2.5em;";
|
||||
}
|
||||
|
||||
div_attributes += '" title="'+title+'" class="'+font+'"';
|
||||
|
||||
format.push([i,'<div ' + div_attributes + '>'
|
||||
+ label
|
||||
+ '</div>']);
|
||||
}
|
||||
|
@ -2325,8 +2319,9 @@ function add_threshold (data_base, threshold_data, y_min, y_max,
|
|||
}
|
||||
|
||||
function reduceText (text, maxLength) {
|
||||
if(!text) return text;
|
||||
if (text.length <= maxLength) return text
|
||||
var firstSlideEnd = parseInt((maxLength - 3) / 2);
|
||||
var firstSlideEnd = parseInt((maxLength - 3)/1.6);
|
||||
var str_cut = text.substr(0, firstSlideEnd);
|
||||
return str_cut + '...' + text.substr(-firstSlideEnd - 3);
|
||||
return str_cut + '...<br>' + text.substr(-firstSlideEnd - 3);
|
||||
}
|
||||
|
|
|
@ -712,7 +712,7 @@ function flot_hcolumn_chart ($graph_data, $width, $height, $water_mark, $font =
|
|||
$data = array();
|
||||
|
||||
foreach ($graph_data as $label => $values) {
|
||||
$labels[] = $label;
|
||||
$labels[] = io_safe_output($label);
|
||||
$i--;
|
||||
|
||||
foreach ($values as $key => $value) {
|
||||
|
|
|
@ -4619,4 +4619,10 @@ form ul.form_flex li ul li{
|
|||
|
||||
.events_bar {
|
||||
margin:0 auto;
|
||||
}
|
||||
}
|
||||
|
||||
.tickLabel {
|
||||
white-space: nowrap;
|
||||
overflow-x: hidden;
|
||||
line-height: 1.05em!important;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue