Merge branch '2704_SQL_Horizontal_bar_graph_en_informe_corta_los_labels_si_son_muy_largos' into 'develop'

Fixed SQL graphs in reports

See merge request artica/pandorafms!1791
This commit is contained in:
vgilc 2018-10-25 12:11:41 +02:00
commit fb32ea240f
3 changed files with 100 additions and 67 deletions

View File

@ -126,6 +126,58 @@ if (file_exists ('languages/'.$user_language.'.mo')) {
echo grafico_modulo_sparse($params);
echo '</div>';
}
elseif($type_graph_pdf == 'hbar'){
echo '<div>';
echo hbar_graph(
$params['flash_chart'],
$params['chart_data'],
$params['width'],
$params['height'],
$params['color'],
$params['legend'],
$params['long_index'],
$params['no_data_image'],
$params['xaxisname'],
$params['yaxisname'],
$params['water_mark'],
$params['font'],
$params['font_size'],
$params['unit'],
$params['ttl'],
$params['homeurl'],
$params['backgroundColor'],
$params['tick_color'],
$params['val_min'],
$params['val_max']
);
echo '</div>';
}
elseif($type_graph_pdf == 'vbar'){
echo '<div>';
echo vbar_graph(
$params['flash_chart'],
$params['chart_data'],
$params['width'],
$params['height'],
$params['color'],
$params['legend'],
$params['long_index'],
$params['no_data_image'],
$params['xaxisname'],
$params['yaxisname'],
$params['water_mark'],
$params['font'],
$params['font_size'],
$params['unit'],
$params['ttl'],
$params['homeurl'],
$params['backgroundColor'],
$params['from_ux'],
$params['from_wux'],
$params['tick_color']
);
echo '</div>';
}
$config['font_size'] = $aux_font_size;
?>

View File

@ -3072,10 +3072,9 @@ function graph_custom_sql_graph ($id, $width, $height,
}
}
}
$flash_charts = $config['flash_charts'];
if ($only_image) {
$flash_charts = true;
if ($ttl == 2) {
$flash_charts = false;
}
@ -3105,9 +3104,9 @@ function graph_custom_sql_graph ($id, $width, $height,
$ttl,
$homeurl,
"white",
true,
false,
false,
"c1c1c1"
"#c1c1c1"
);
break;
case 'sql_graph_hbar': // horizontal bar
@ -3129,7 +3128,7 @@ function graph_custom_sql_graph ($id, $width, $height,
$ttl,
$homeurl,
'white',
'c1c1c1'
'#c1c1c1'
);
break;
case 'sql_graph_pie': // Pie

View File

@ -187,35 +187,27 @@ function vbar_graph(
$tick_color);
}
else {
$new_chart_data = array();
foreach ($chart_data as $key => $value) {
if(strlen($key) > 20 && strpos($key, ' - ') !== false){
$key_temp = explode(" - ",$key);
$key_temp[0] = $key_temp[0]." \n";
$key_temp[1]= '...'.substr($key_temp[1],-15);
$key2 = $key_temp[0].$key_temp[1];
io_safe_output($key2);
$new_chart_data[$key2]['g'] = $chart_data[$key]['g'];
} else {
$new_chart_data[$key] = $value;
}
}
$graph = array();
$graph['data'] = $new_chart_data;
$graph['width'] = $width;
$graph['height'] = $height;
$graph['color'] = $color;
$graph['legend'] = $legend;
$graph['xaxisname'] = $xaxisname;
$graph['yaxisname'] = $yaxisname;
$graph['water_mark'] = $water_mark_file;
$graph['font'] = $font;
$graph['font_size'] = $font_size;
$id_graph = serialize_in_temp($graph, null, $ttl);
return "<img src='" . $homeurl . "include/graphs/functions_pchart.php?static_graph=1&graph_type=vbar&ttl=".$ttl."&id_graph=".$id_graph."'>";
$params['flash_chart'] = true;
$params['chart_data'] = $chart_data;
$params['width'] = $width;
$params['height'] = $height;
$params['color'] = $color;
$params['legend'] = $legend;
$params['long_index'] = $long_index;
$params['no_data_image'] = $no_data_image;
$params['xaxisname'] = $xaxisname;
$params['yaxisname'] = $yaxisname;
$params['water_mark'] = $water_mark;
$params['font'] = $font;
$params['font_size'] = $font_size;
$params['unit'] = $unit;
$params['ttl'] = 2;
$params['homeurl'] = $homeurl;
$params['backgroundColor'] = $backgroundColor;
$params['from_ux'] = $from_ux;
$params['from_wux'] = $from_wux;
$params['tick_color'] = $tick_color;
return generator_chart_to_pdf('vbar', $params);
}
}
@ -312,37 +304,27 @@ function hbar_graph($flash_chart, $chart_data, $width, $height,
$chart_data, $width, $height, $water_mark_url, $font, $font_size, $backgroundColor, $tick_color, $val_min, $val_max);
}
else {
foreach ($chart_data as $key => $value) {
$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];
}
$chart_data[$key2]['g'] = $chart_data[$key]['g'];
unset($chart_data[$key]);
}
}
$graph = array();
$graph['data'] = $chart_data;
$graph['width'] = $width;
$graph['height'] = $height;
$graph['color'] = $color;
$graph['legend'] = $legend;
$graph['xaxisname'] = $xaxisname;
$graph['yaxisname'] = $yaxisname;
$graph['force_height'] = $force_height;
$graph['water_mark'] = $water_mark_file;
$graph['font'] = $font;
$graph['font_size'] = $font_size;
$graph['force_steps'] = $force_steps;
$id_graph = serialize_in_temp($graph, null, $ttl);
return "<img src='" . $homeurl . "include/graphs/functions_pchart.php?static_graph=1&graph_type=hbar&ttl=".$ttl."&id_graph=".$id_graph."'>";
$params['flash_chart'] = true;
$params['chart_data'] = $chart_data;
$params['width'] = $width;
$params['height'] = $height;
$params['color'] = $color;
$params['legend'] = $legend;
$params['long_index'] = $long_index;
$params['no_data_image'] = $no_data_image;
$params['xaxisname'] = $xaxisname;
$params['yaxisname'] = $yaxisname;
$params['water_mark'] = $water_mark;
$params['font'] = $font;
$params['font_size'] = $font_size;
$params['unit'] = $unit;
$params['ttl'] = 2;
$params['homeurl'] = $homeurl;
$params['backgroundColor'] = $backgroundColor;
$params['tick_color'] = $tick_color;
$params['val_min'] = $val_min;
$params['val_max'] = $val_max;
return generator_chart_to_pdf('hbar', $params);
}
}