Merge branch 'ent-1941-sql-charts' into 'develop'
Ent 1941 sql charts See merge request artica/pandorafms!1331
This commit is contained in:
commit
2b2c99cc42
|
@ -132,6 +132,7 @@ switch ($action) {
|
|||
$hide_notinit_agents = 0;
|
||||
$server_name = '';
|
||||
$server_id = 0;
|
||||
$dyn_height = 230;
|
||||
break;
|
||||
case 'save':
|
||||
default:
|
||||
|
@ -173,6 +174,7 @@ switch ($action) {
|
|||
$server_name = '';
|
||||
$server_id = 0;
|
||||
$get_data_editor = false;
|
||||
$dyn_height = 230;
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -196,6 +198,7 @@ switch ($action) {
|
|||
$show_in_two_columns = $style['show_in_two_columns'];
|
||||
$show_in_landscape = $style['show_in_landscape'];
|
||||
$hide_notinit_agents = $style['hide_notinit_agents'];
|
||||
$dyn_height = $style['dyn_height'];
|
||||
$type = $item['type'];
|
||||
$name = $item['name'];
|
||||
|
||||
|
@ -361,33 +364,16 @@ switch ($action) {
|
|||
$text = $item['text'];
|
||||
break;
|
||||
case 'sql':
|
||||
$description = $item['description'];
|
||||
$sql_query_report = $item['external_source'];
|
||||
$idCustom = $item['treport_custom_sql_id'];
|
||||
$header = $item['header_definition'];
|
||||
$historical_db = $item['historical_db'];
|
||||
$period = 0;
|
||||
break;
|
||||
case 'sql_graph_pie':
|
||||
$description = $item['description'];
|
||||
$sql_query_report = $item['external_source'];
|
||||
$idCustom = $item['treport_custom_sql_id'];
|
||||
$historical_db = $item['historical_db'];
|
||||
$period = 0;
|
||||
break;
|
||||
case 'sql_graph_vbar':
|
||||
$description = $item['description'];
|
||||
$sql_query_report = $item['external_source'];
|
||||
$idCustom = $item['treport_custom_sql_id'];
|
||||
$historical_db = $item['historical_db'];
|
||||
$period = 0;
|
||||
break;
|
||||
case 'sql_graph_hbar':
|
||||
$description = $item['description'];
|
||||
$sql_query_report = $item['external_source'];
|
||||
$idCustom = $item['treport_custom_sql_id'];
|
||||
$historical_db = $item['historical_db'];
|
||||
$period = 0;
|
||||
$top_n_value = $item['top_n_value'];
|
||||
break;
|
||||
case 'url':
|
||||
$description = $item['description'];
|
||||
|
@ -1283,6 +1269,16 @@ You can of course remove the warnings, that's why we include the source and do n
|
|||
</td>
|
||||
<td style="" id="sql_example"></td>
|
||||
</tr>
|
||||
|
||||
<tr id="row_max_items" style="" class="datos">
|
||||
<td style="font-weight:bold;"><?php echo __('Max items'); ?></td>
|
||||
<td style="">
|
||||
<?php
|
||||
html_print_input_text('max_items', $top_n_value, '', 7, 7);
|
||||
?>
|
||||
</td>
|
||||
<td style="" id="max_items_example"></td>
|
||||
</tr>
|
||||
|
||||
<?php
|
||||
if ($meta) {
|
||||
|
@ -1548,6 +1544,11 @@ You can of course remove the warnings, that's why we include the source and do n
|
|||
<td><?php html_print_checkbox('show_in_two_columns', 1, $show_in_two_columns);?></td>
|
||||
</tr>
|
||||
|
||||
<tr id="row_dyn_height" style="" class="datos">
|
||||
<td style="font-weight:bold;"><?php echo __('Height (dynamic graphs)');?></td>
|
||||
<td><?php html_print_input_text('dyn_height', $dyn_height, '', 7, 7);?></td>
|
||||
</tr>
|
||||
|
||||
<tr id="row_show_in_same_row" style="" class="datos">
|
||||
<td style="font-weight:bold;" class="datos">
|
||||
<?php
|
||||
|
@ -2766,6 +2767,7 @@ function chooseType() {
|
|||
$("#row_custom_graph").hide();
|
||||
$("#row_text").hide();
|
||||
$("#row_query").hide();
|
||||
$("#row_max_items").hide();
|
||||
$("#row_header").hide();
|
||||
$("#row_custom").hide();
|
||||
$("#row_url").hide();
|
||||
|
@ -2791,6 +2793,7 @@ function chooseType() {
|
|||
$("#row_exception_condition_value").hide();
|
||||
$("#row_exception_condition").hide();
|
||||
$("#row_show_in_two_columns").hide();
|
||||
$("#row_dyn_height").hide();
|
||||
$("#row_show_in_same_row").hide();
|
||||
$("#row_historical_db_check").hide();
|
||||
$("#row_lapse_calc").hide();
|
||||
|
@ -3061,37 +3064,24 @@ function chooseType() {
|
|||
case 'sql':
|
||||
$("#row_description").show();
|
||||
$("#row_query").show();
|
||||
$("#row_max_items").show();
|
||||
$("#row_header").show();
|
||||
$("#row_custom").show();
|
||||
$("#row_custom_example").show();
|
||||
$("#row_show_in_two_columns").show();
|
||||
$("#row_dyn_height").show();
|
||||
$("#row_servers").show();
|
||||
$("#row_historical_db_check").show();
|
||||
break;
|
||||
|
||||
case 'sql_graph_pie':
|
||||
$("#row_description").show();
|
||||
$("#row_query").show();
|
||||
$("#row_show_in_two_columns").show();
|
||||
$("#row_show_in_landscape").show();
|
||||
$("#row_servers").show();
|
||||
$("#row_historical_db_check").show();
|
||||
|
||||
break;
|
||||
|
||||
case 'sql_graph_hbar':
|
||||
$("#row_description").show();
|
||||
$("#row_query").show();
|
||||
$("#row_show_in_two_columns").show();
|
||||
$("#row_show_in_landscape").show();
|
||||
$("#row_servers").show();
|
||||
$("#row_historical_db_check").show();
|
||||
break;
|
||||
|
||||
case 'sql_graph_vbar':
|
||||
$("#row_description").show();
|
||||
$("#row_query").show();
|
||||
$("#row_max_items").show();
|
||||
$("#row_show_in_two_columns").show();
|
||||
$("#row_dyn_height").show();
|
||||
$("#row_show_in_landscape").show();
|
||||
$("#row_servers").show();
|
||||
$("#row_historical_db_check").show();
|
||||
|
|
|
@ -1194,6 +1194,7 @@ switch ($action) {
|
|||
$values['external_source'] = get_parameter('sql');
|
||||
}
|
||||
$values['historical_db'] = get_parameter('historical_db_check');
|
||||
$values['top_n_value'] = get_parameter('max_items');
|
||||
}
|
||||
else if ($values['type'] == 'url') {
|
||||
$values['external_source'] = get_parameter('url');
|
||||
|
@ -1211,6 +1212,7 @@ switch ($action) {
|
|||
$style['show_in_same_row'] = get_parameter('show_in_same_row', 0);
|
||||
$style['show_in_landscape'] = get_parameter('show_in_landscape', 0);
|
||||
$style['hide_notinit_agents'] = get_parameter('hide_notinit_agents', 0);
|
||||
$style['dyn_height'] = get_parameter('dyn_height', 230);
|
||||
|
||||
switch ($values['type']) {
|
||||
case 'event_report_agent':
|
||||
|
@ -1532,6 +1534,7 @@ switch ($action) {
|
|||
$values['external_source'] = get_parameter('sql');
|
||||
}
|
||||
$values['historical_db'] = get_parameter('historical_db_check');
|
||||
$values['top_n_value'] = get_parameter('max_items');
|
||||
}
|
||||
elseif ($values['type'] == 'url') {
|
||||
$values['external_source'] = get_parameter('url');
|
||||
|
@ -1549,6 +1552,7 @@ switch ($action) {
|
|||
$style['show_in_same_row'] = get_parameter('show_in_same_row', 0);
|
||||
$style['show_in_landscape'] = get_parameter('show_in_landscape', 0);
|
||||
$style['hide_notinit_agents'] = get_parameter('hide_notinit_agents', 0);
|
||||
$style['dyn_height'] = get_parameter('dyn_height', 230);
|
||||
|
||||
switch ($values['type']) {
|
||||
case 'event_report_agent':
|
||||
|
|
|
@ -3859,9 +3859,10 @@ function grafico_eventos_usuario ($width, $height) {
|
|||
*/
|
||||
function graph_custom_sql_graph ($id, $width, $height,
|
||||
$type = 'sql_graph_vbar', $only_image = false, $homeurl = '',
|
||||
$ttl = 1) {
|
||||
$ttl = 1, $max_num_elements = 8) {
|
||||
|
||||
global $config;
|
||||
$SQL_GRAPH_MAX_LABEL_SIZE = 20;
|
||||
|
||||
$report_content = db_get_row ('treport_content', 'id_rc', $id);
|
||||
if($id != null){
|
||||
|
@ -3920,18 +3921,38 @@ function graph_custom_sql_graph ($id, $width, $height,
|
|||
if (!empty($data_item["value"])) {
|
||||
$value = $data_item["value"];
|
||||
}
|
||||
$label = __('Data');
|
||||
if (!empty($data_item["label"])) {
|
||||
$label = $data_item["label"];
|
||||
}
|
||||
switch ($type) {
|
||||
case 'sql_graph_vbar': // vertical bar
|
||||
case 'sql_graph_hbar': // horizontal bar
|
||||
$data[$label."_".$count]['g'] = $value;
|
||||
break;
|
||||
case 'sql_graph_pie': // Pie
|
||||
$data[$label."_".$count] = $value;
|
||||
break;
|
||||
if ($count <= $max_num_elements) {
|
||||
$label = __('Data');
|
||||
if (!empty($data_item["label"])) {
|
||||
$label = io_safe_output($data_item["label"]);
|
||||
if (strlen($label) > $SQL_GRAPH_MAX_LABEL_SIZE) {
|
||||
$first_label = $label;
|
||||
$label = substr($first_label, 0, floor($SQL_GRAPH_MAX_LABEL_SIZE/2));
|
||||
$label .= '...';
|
||||
$label .= substr($first_label, floor(-$SQL_GRAPH_MAX_LABEL_SIZE/2));
|
||||
}
|
||||
}
|
||||
switch ($type) {
|
||||
case 'sql_graph_vbar': // vertical bar
|
||||
case 'sql_graph_hbar': // horizontal bar
|
||||
$data[$label."_".$count]['g'] = $value;
|
||||
break;
|
||||
case 'sql_graph_pie': // Pie
|
||||
$data[$label."_".$count] = $value;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
switch ($type) {
|
||||
case 'sql_graph_vbar': // vertical bar
|
||||
case 'sql_graph_hbar': // horizontal bar
|
||||
if (!isset($data[__('Other')]['g'])) $data[__('Other')]['g'] = 0;
|
||||
$data[__('Other')]['g'] += $value;
|
||||
break;
|
||||
case 'sql_graph_pie': // Pie
|
||||
if (!isset($data[__('Other')])) $data[__('Other')] = 0;
|
||||
$data[__('Other')] += $value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3949,16 +3970,50 @@ function graph_custom_sql_graph ($id, $width, $height,
|
|||
|
||||
switch ($type) {
|
||||
case 'sql_graph_vbar': // vertical bar
|
||||
return vbar_graph($flash_charts, $data, $width, $height, array(),
|
||||
array(), "", "", $homeurl, $water_mark,
|
||||
$config['fontpath'], $config['font_size'], false, $ttl, "", "white", false, false, "black");
|
||||
return vbar_graph(
|
||||
$flash_charts,
|
||||
$data,
|
||||
$width,
|
||||
$height,
|
||||
array(),
|
||||
array(),
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
$water_mark,
|
||||
$config['fontpath'],
|
||||
$config['font_size'],
|
||||
"",
|
||||
$ttl,
|
||||
$config['homeurl'],
|
||||
"white",
|
||||
false,
|
||||
false,
|
||||
"black"
|
||||
);
|
||||
break;
|
||||
case 'sql_graph_hbar': // horizontal bar
|
||||
return hbar_graph($flash_charts, $data, $width, $height, array(),
|
||||
array(), "", "", true, $homeurl, $water_mark,
|
||||
$config['fontpath'], $config['font_size'], false, $ttl,$config['homeurl'],
|
||||
'white',
|
||||
'black');
|
||||
return hbar_graph(
|
||||
$flash_charts,
|
||||
$data,
|
||||
$width,
|
||||
$height,
|
||||
array(),
|
||||
array(),
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
$water_mark,
|
||||
$config['fontpath'],
|
||||
$config['font_size'],
|
||||
false,
|
||||
$ttl,
|
||||
$config['homeurl'],
|
||||
'white',
|
||||
'black'
|
||||
);
|
||||
break;
|
||||
case 'sql_graph_pie': // Pie
|
||||
return pie3d_graph($flash_charts, $data, $width, $height, __("other"), $homeurl,
|
||||
|
|
|
@ -3294,7 +3294,8 @@ function reporting_sql_graph($report, $content, $type,
|
|||
$content["type"],
|
||||
true,
|
||||
ui_get_full_url(false, false, false, false),
|
||||
$ttl);
|
||||
$ttl,
|
||||
$content['top_n_value']);
|
||||
break;
|
||||
case 'data':
|
||||
break;
|
||||
|
@ -6766,7 +6767,9 @@ function reporting_set_conf_charts(&$width, &$height, &$only_image, $type,
|
|||
case 'dinamic':
|
||||
$only_image = false;
|
||||
$width = 900;
|
||||
$height = 230;
|
||||
$height = isset($content['style']['dyn_height'])
|
||||
? $content['style']['dyn_height']
|
||||
: 230;
|
||||
$ttl = 1;
|
||||
break;
|
||||
case 'static':
|
||||
|
|
|
@ -152,11 +152,29 @@ function slicesbar_graph($chart_data, $period, $width, $height, $colors,
|
|||
return "<img src='".$home_url."include/graphs/functions_pchart.php?static_graph=1&graph_type=slicebar&ttl=".$ttl."&id_graph=".$id_graph."' style='width:100%;'>";
|
||||
}
|
||||
|
||||
function vbar_graph($flash_chart, $chart_data, $width, $height,
|
||||
$color, $legend, $long_index, $no_data_image, $xaxisname = "",
|
||||
$yaxisname = "", $water_mark = "", $font = '', $font_size = '',
|
||||
$unit = '', $ttl = 1, $homeurl = '', $backgroundColor = 'white',
|
||||
$from_ux = false, $from_wux = false, $tick_color = 'white') {
|
||||
function vbar_graph(
|
||||
$flash_chart,
|
||||
$chart_data,
|
||||
$width,
|
||||
$height,
|
||||
$color,
|
||||
$legend,
|
||||
$long_index,
|
||||
$no_data_image,
|
||||
$xaxisname = "",
|
||||
$yaxisname = "",
|
||||
$water_mark = "",
|
||||
$font = '',
|
||||
$font_size = '',
|
||||
$unit = '',
|
||||
$ttl = 1,
|
||||
$homeurl = '',
|
||||
$backgroundColor = 'white',
|
||||
$from_ux = false,
|
||||
$from_wux = false,
|
||||
$tick_color = 'white'
|
||||
) {
|
||||
|
||||
setup_watermark($water_mark, $water_mark_file, $water_mark_url);
|
||||
|
||||
if (empty($chart_data)) {
|
||||
|
@ -170,24 +188,22 @@ function vbar_graph($flash_chart, $chart_data, $width, $height,
|
|||
$tick_color);
|
||||
}
|
||||
else {
|
||||
$new_chart_data = array();
|
||||
foreach ($chart_data as $key => $value) {
|
||||
if(strlen($key) > 20){
|
||||
|
||||
if(strpos($key, ' - ') != -1){
|
||||
$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);
|
||||
}
|
||||
$chart_data[$key2]['g'] = $chart_data[$key]['g'];
|
||||
unset($chart_data[$key]);
|
||||
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'] = $chart_data;
|
||||
$graph['data'] = $new_chart_data;
|
||||
$graph['width'] = $width;
|
||||
$graph['height'] = $height;
|
||||
$graph['color'] = $color;
|
||||
|
@ -703,7 +719,7 @@ function pie_graph($graph_type, $flash_chart, $chart_data, $width,
|
|||
setup_watermark($water_mark, $water_mark_file, $water_mark_url);
|
||||
|
||||
// This library allows only 8 colors
|
||||
$max_values = 5;
|
||||
$max_values = 9;
|
||||
|
||||
//Remove the html_entities
|
||||
$temp = array();
|
||||
|
|
Loading…
Reference in New Issue