From 1f20247ae388e1a7db2c2bb01326280745a12e20 Mon Sep 17 00:00:00 2001 From: Arturo Gonzalez Date: Thu, 26 Oct 2017 12:23:41 +0200 Subject: [PATCH] Added background color to bars charts --- pandora_console/include/graphs/fgraph.php | 4 ++-- .../include/graphs/flot/pandora.flot.js | 19 +++++-------------- .../include/graphs/functions_flot.php | 12 ++++++------ 3 files changed, 13 insertions(+), 22 deletions(-) diff --git a/pandora_console/include/graphs/fgraph.php b/pandora_console/include/graphs/fgraph.php index c36529b7f7..4e144bf08b 100644 --- a/pandora_console/include/graphs/fgraph.php +++ b/pandora_console/include/graphs/fgraph.php @@ -188,7 +188,7 @@ function vbar_graph($flash_chart, $chart_data, $width, $height, if ($flash_chart) { return flot_vcolumn_chart ($chart_data, $width, $height, $color, $legend, $long_index, $homeurl, $unit, $water_mark_url, - $homedir,$font,$font_size, $from_ux, $from_wux); + $homedir,$font,$font_size, $from_ux, $from_wux, $backgroundColor); } else { $graph = array(); @@ -636,7 +636,7 @@ function hbar_graph($flash_chart, $chart_data, $width, $height, if ($flash_chart) { return flot_hcolumn_chart( - $chart_data, $width, $height, $water_mark_url, $font, $font_size); + $chart_data, $width, $height, $water_mark_url, $font, $font_size, $backgroundColor); } else { $graph = array(); diff --git a/pandora_console/include/graphs/flot/pandora.flot.js b/pandora_console/include/graphs/flot/pandora.flot.js index 9024424ab0..277a060f43 100644 --- a/pandora_console/include/graphs/flot/pandora.flot.js +++ b/pandora_console/include/graphs/flot/pandora.flot.js @@ -309,7 +309,7 @@ function pandoraFlotPieCustom(graph_id, values, labels, width, } function pandoraFlotHBars(graph_id, values, labels, water_mark, - maxvalue, water_mark, separator, separator2, font, font_size) { + maxvalue, water_mark, separator, separator2, font, font_size, background_color) { var colors_data = ['#FC4444','#FFA631','#FAD403','#5BB6E5','#F2919D','#80BA27']; values = values.split(separator2); @@ -355,7 +355,7 @@ function pandoraFlotHBars(graph_id, values, labels, water_mark, grid: { hoverable: true, borderWidth: 1, - backgroundColor: { colors: ["#FFF", "#FFF"] } + backgroundColor: { colors: [background_color, background_color] } }, xaxis: { axisLabelUseCanvas: true, @@ -494,7 +494,7 @@ function showTooltip(x, y, color, contents) { }).appendTo("body").fadeIn(200); } -function pandoraFlotVBars(graph_id, values, labels, labels_long, legend, colors, water_mark, maxvalue, water_mark, separator, separator2, font, font_size , from_ux, from_wux) { +function pandoraFlotVBars(graph_id, values, labels, labels_long, legend, colors, water_mark, maxvalue, water_mark, separator, separator2, font, font_size , from_ux, from_wux, background_color) { values = values.split(separator2); legend = legend.split(separator); font = font.split("/").pop().split(".").shift(); @@ -585,7 +585,7 @@ function pandoraFlotVBars(graph_id, values, labels, labels_long, legend, colors, grid: { hoverable: true, borderWidth: 1, - backgroundColor: { colors: ["#FFF", "#FFF"] } + backgroundColor: { colors: [background_color, background_color] } } }; @@ -608,16 +608,7 @@ function pandoraFlotVBars(graph_id, values, labels, labels_long, legend, colors, $('#' + graph_id).VUseTooltip(); $('#' + graph_id).css("margin-left","auto"); $('#' + graph_id).css("margin-right","auto"); - //~ $('#' + graph_id).find('div.legend-tooltip').tooltip({ track: true }); - /* - $('#'+graph_id+' .xAxis .tickLabel') - .css('transform', 'rotate(-45deg)') - .css('max-width','100px') - .find('div') - .css('position', 'relative') - .css('top', '+10px') - .css('left', '-30px'); - */ + if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) $('#'+graph_id+' .xAxis .tickLabel') .find('div') diff --git a/pandora_console/include/graphs/functions_flot.php b/pandora_console/include/graphs/functions_flot.php index 319e69cab0..bfc7b37c3b 100644 --- a/pandora_console/include/graphs/functions_flot.php +++ b/pandora_console/include/graphs/functions_flot.php @@ -674,7 +674,7 @@ function flot_custom_pie_chart ($flash_charts, $graph_values, } // Returns a 3D column chart -function flot_hcolumn_chart ($graph_data, $width, $height, $water_mark, $font = '', $font_size = 7) { +function flot_hcolumn_chart ($graph_data, $width, $height, $water_mark, $font = '', $font_size = 7, $background_color = "white") { global $config; include_javascript_dependencies_flot_graph(); @@ -755,7 +755,7 @@ function flot_hcolumn_chart ($graph_data, $width, $height, $water_mark, $font = $return .= ""; @@ -763,7 +763,7 @@ function flot_hcolumn_chart ($graph_data, $width, $height, $water_mark, $font = } // Returns a 3D column chart -function flot_vcolumn_chart ($graph_data, $width, $height, $color, $legend, $long_index, $homeurl, $unit, $water_mark, $homedir, $font, $font_size, $from_ux, $from_wux) { +function flot_vcolumn_chart ($graph_data, $width, $height, $color, $legend, $long_index, $homeurl, $unit, $water_mark, $homedir, $font, $font_size, $from_ux, $from_wux, $background_color = 'white') { global $config; include_javascript_dependencies_flot_graph(); @@ -847,14 +847,14 @@ function flot_vcolumn_chart ($graph_data, $width, $height, $color, $legend, $lon if ($from_ux) { if($from_wux){ - $return .= "pandoraFlotVBars('$graph_id', '$values', '$labels', '$labels', '$legend', '$colors', false, $max, '$water_mark', '$separator', '$separator2','$font',$font_size, true, true)"; + $return .= "pandoraFlotVBars('$graph_id', '$values', '$labels', '$labels', '$legend', '$colors', false, $max, '$water_mark', '$separator', '$separator2','$font',$font_size, true, true, '$background_color')"; } else{ - $return .= "pandoraFlotVBars('$graph_id', '$values', '$labels', '$labels', '$legend', '$colors', false, $max, '$water_mark', '$separator', '$separator2','$font',$font_size, true, false)"; + $return .= "pandoraFlotVBars('$graph_id', '$values', '$labels', '$labels', '$legend', '$colors', false, $max, '$water_mark', '$separator', '$separator2','$font',$font_size, true, false, '$background_color')"; } } else { - $return .= "pandoraFlotVBars('$graph_id', '$values', '$labels', '$labels', '$legend', '$colors', false, $max, '$water_mark', '$separator', '$separator2','$font',$font_size, false, false)"; + $return .= "pandoraFlotVBars('$graph_id', '$values', '$labels', '$labels', '$legend', '$colors', false, $max, '$water_mark', '$separator', '$separator2','$font',$font_size, false, false, '$background_color')"; } $return .= "";