Fixed Pie charts and legend. Tiquet: #3742

(cherry picked from commit 54c6de6a41b1b4dd3409b9fa941a91c2d1092210)
This commit is contained in:
m-lopez-f 2016-06-13 09:00:11 +02:00
parent 2303bc9356
commit 583a84b8d7
3 changed files with 15 additions and 15 deletions

View File

@ -1694,7 +1694,7 @@ function graphic_combined_module ($module_list, $weight_list, $period,
case CUSTOM_GRAPH_PIE: case CUSTOM_GRAPH_PIE:
return ring_graph($flash_charts, $graph_values, $width, $height, return ring_graph($flash_charts, $graph_values, $width, $height,
$others_str, $homeurl, $water_mark, $config['fontpath'], $others_str, $homeurl, $water_mark, $config['fontpath'],
($config['font_size']+1), 1, false, $color, false); ($config['font_size']+1), $ttl, false, $color, false);
break; break;
} }
} }

View File

@ -741,36 +741,37 @@ function ring_graph($flash_chart, $chart_data, $width,
$total_modules = $chart_data['total_modules']; $total_modules = $chart_data['total_modules'];
unset($chart_data['total_modules']); unset($chart_data['total_modules']);
$max_values = 9;
//Remove the html_entities //Remove the html_entities
$n = 0; $n = 0;
$temp = array(); $temp = array();
$coloretes = array(); $coloretes = array();
foreach ($chart_data as $key => $value) { foreach ($chart_data as $key => $value) {
$temp[io_safe_output($key)] = $value['value']; if ($n < $max_values) {
$legend[] = io_safe_output($key) .": " . $value['value'] . " " .$value['unit']; $temp[io_safe_output($key)] = $value['value'];
//~ $coloretes[$n] = $colors[$n]['color']; $legend[] = io_safe_output($key) .": " . $value['value'] . " " .$value['unit'];
//~ $n++; }
$n++;
} }
$chart_data = $temp; $chart_data = $temp;
$chart_data_trunc = array(); $chart_data_trunc = array();
$coloretes = array(); $coloretes = array();
$n = 1; $n = 1;
foreach ($chart_data as $key => $value) { //~ foreach ($chart_data as $key => $value) {
if ($n < $max_values) { //~ if ($n < $max_values) {
$chart_data_trunc[$key] = $value; //~ $chart_data_trunc[$key] = $value;
} //~ }
//~ else { //~ else {
//~ if (!isset($chart_data_trunc[$others_str])) { //~ if (!isset($chart_data_trunc[$others_str])) {
//~ $chart_data_trunc[$others_str] = 0; //~ $chart_data_trunc[$others_str] = 0;
//~ } //~ }
//~ $chart_data_trunc[$others_str] += $value; //~ $chart_data_trunc[$others_str] += $value;
//~ } //~ }
$n++; //~ $n++;
} //~ }
$chart_data = $chart_data_trunc; //~ $chart_data = $chart_data_trunc;
//TODO SET THE LEGEND POSITION //TODO SET THE LEGEND POSITION

View File

@ -62,7 +62,7 @@ $ttl = get_parameter('ttl', 1);
$graph = unserialize_in_temp($id_graph, true, $ttl); $graph = unserialize_in_temp($id_graph, true, $ttl);
if (!isset($graph)) { if (!$graph) {
exit; exit;
} }
@ -1111,7 +1111,6 @@ function pch_bullet_chart($graph_type, $data, $legend,
/* Create and populate the pData object */ /* Create and populate the pData object */
$MyData = new pData(); $MyData = new pData();
html_debug($data,true);
foreach ($data as $key => $dat) { foreach ($data as $key => $dat) {
$MyData->addPoints($dat, $key); $MyData->addPoints($dat, $key);
} }