When print Pie graph and not containt data, add image with text is 'no data to show'. Tiquet: #3010

This commit is contained in:
m-lopez-f 2015-11-27 11:50:53 +01:00
parent 83f6dd4611
commit 0d73595776
3 changed files with 20 additions and 7 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

View File

@ -133,6 +133,7 @@ function pandoraFlotPieCustom(graph_id, values, labels, width,
var labels = labels.split(separator);
var legend = legend.split(separator);
var data = values.split(separator);
var no_data = 0;
if (colors != '') {
colors = colors.split(separator);
}
@ -142,8 +143,11 @@ function pandoraFlotPieCustom(graph_id, values, labels, width,
if (colors != '') {
color = colors_data[i];
}
var datos = data[i];
data[i] = { label: labels[i], data: parseFloat(data[i]), color: color };
if (!datos)
no_data++;
data[i] = { label: labels[i], data: parseFloat(data[i]), color: color}
}
var label_conf;
@ -184,7 +188,12 @@ function pandoraFlotPieCustom(graph_id, values, labels, width,
};
var plot = $.plot($('#'+graph_id), data, conf_pie);
if (no_data == data.length) {
$('#'+graph_id+' .overlay').remove();
$('#'+graph_id+' .base').remove();
$('#'+graph_id).prepend("<img style='width:50%;' src='images/no_data_toshow.png' />");
}
var legends = $('#'+graph_id+' .legendLabel');
var j = 0;
legends.each(function () {

View File

@ -505,12 +505,16 @@ function flot_custom_pie_chart ($flash_charts, $graph_values,
unset($graph_values['total_modules']);
foreach ($graph_values as $label => $value) {
if ($value['value'] > 1000000)
$legendvalue = sprintf("%sM", number_format($value['value'] / 1000000, 2));
else if ($value['value'] > 1000)
$legendvalue = sprintf("%sK", number_format($value['value'] / 1000, 2));
if ($value['value']) {
if ($value['value'] > 1000000)
$legendvalue = sprintf("%sM", number_format($value['value'] / 1000000, 2));
else if ($value['value'] > 1000)
$legendvalue = sprintf("%sK", number_format($value['value'] / 1000, 2));
else
$legendvalue = $value['value'];
}
else
$legendvalue = $value['value'];
$legendvalue = __('No data');
$values[] = $value['value'];
$legend[] = $label .": " . $legendvalue . " " .$value['unit'];
$labels[] = $label;