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 grafico_modulo_sparse($params);
echo '</div>'; 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; $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']; $flash_charts = true;
if ($ttl == 2) {
if ($only_image) {
$flash_charts = false; $flash_charts = false;
} }
@ -3105,9 +3104,9 @@ function graph_custom_sql_graph ($id, $width, $height,
$ttl, $ttl,
$homeurl, $homeurl,
"white", "white",
true,
false, false,
false, "#c1c1c1"
"c1c1c1"
); );
break; break;
case 'sql_graph_hbar': // horizontal bar case 'sql_graph_hbar': // horizontal bar
@ -3129,7 +3128,7 @@ function graph_custom_sql_graph ($id, $width, $height,
$ttl, $ttl,
$homeurl, $homeurl,
'white', 'white',
'c1c1c1' '#c1c1c1'
); );
break; break;
case 'sql_graph_pie': // Pie case 'sql_graph_pie': // Pie

View File

@ -187,35 +187,27 @@ function vbar_graph(
$tick_color); $tick_color);
} }
else { else {
$new_chart_data = array(); $params['flash_chart'] = true;
foreach ($chart_data as $key => $value) { $params['chart_data'] = $chart_data;
if(strlen($key) > 20 && strpos($key, ' - ') !== false){ $params['width'] = $width;
$key_temp = explode(" - ",$key); $params['height'] = $height;
$key_temp[0] = $key_temp[0]." \n"; $params['color'] = $color;
$key_temp[1]= '...'.substr($key_temp[1],-15); $params['legend'] = $legend;
$key2 = $key_temp[0].$key_temp[1]; $params['long_index'] = $long_index;
io_safe_output($key2); $params['no_data_image'] = $no_data_image;
$new_chart_data[$key2]['g'] = $chart_data[$key]['g']; $params['xaxisname'] = $xaxisname;
} else { $params['yaxisname'] = $yaxisname;
$new_chart_data[$key] = $value; $params['water_mark'] = $water_mark;
} $params['font'] = $font;
} $params['font_size'] = $font_size;
$params['unit'] = $unit;
$graph = array(); $params['ttl'] = 2;
$graph['data'] = $new_chart_data; $params['homeurl'] = $homeurl;
$graph['width'] = $width; $params['backgroundColor'] = $backgroundColor;
$graph['height'] = $height; $params['from_ux'] = $from_ux;
$graph['color'] = $color; $params['from_wux'] = $from_wux;
$graph['legend'] = $legend; $params['tick_color'] = $tick_color;
$graph['xaxisname'] = $xaxisname; return generator_chart_to_pdf('vbar', $params);
$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."'>";
} }
} }
@ -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); $chart_data, $width, $height, $water_mark_url, $font, $font_size, $backgroundColor, $tick_color, $val_min, $val_max);
} }
else { else {
foreach ($chart_data as $key => $value) { $params['flash_chart'] = true;
$str_key = io_safe_output($key); $params['chart_data'] = $chart_data;
if(strlen($str_key) > 40){ $params['width'] = $width;
if(strpos($str_key, ' - ') != -1){ $params['height'] = $height;
$key_temp = explode(" - ",$str_key); $params['color'] = $color;
$key_temp[0] = $key_temp[0]." <br>"; $params['legend'] = $legend;
$key_temp[1]= '...'.substr($key_temp[1],-20); $params['long_index'] = $long_index;
$key2 = $key_temp[0].$key_temp[1]; $params['no_data_image'] = $no_data_image;
} $params['xaxisname'] = $xaxisname;
$chart_data[$key2]['g'] = $chart_data[$key]['g']; $params['yaxisname'] = $yaxisname;
unset($chart_data[$key]); $params['water_mark'] = $water_mark;
} $params['font'] = $font;
} $params['font_size'] = $font_size;
$params['unit'] = $unit;
$graph = array(); $params['ttl'] = 2;
$graph['data'] = $chart_data; $params['homeurl'] = $homeurl;
$graph['width'] = $width; $params['backgroundColor'] = $backgroundColor;
$graph['height'] = $height; $params['tick_color'] = $tick_color;
$graph['color'] = $color; $params['val_min'] = $val_min;
$graph['legend'] = $legend; $params['val_max'] = $val_max;
$graph['xaxisname'] = $xaxisname; return generator_chart_to_pdf('hbar', $params);
$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."'>";
} }
} }