When print Pie graph and not containt data, add image with text is 'no data to show'. Tiquet: #3010
(cherry picked from commit 0d73595776
)
This commit is contained in:
parent
bad24f658a
commit
4ec33a4c9a
Binary file not shown.
After Width: | Height: | Size: 21 KiB |
|
@ -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 () {
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue