fixed errors VC

This commit is contained in:
Daniel Barbero Martin 2020-01-24 15:13:42 +01:00
parent aea073b4d5
commit 5ec8c68aed
7 changed files with 106 additions and 137 deletions

View File

@ -168,7 +168,8 @@ function vbar_graph(
$backgroundColor='white', $backgroundColor='white',
$from_ux=false, $from_ux=false,
$from_wux=false, $from_wux=false,
$tick_color='white' $tick_color='white',
$base64=false
) { ) {
setup_watermark($water_mark, $water_mark_file, $water_mark_url); setup_watermark($water_mark, $water_mark_file, $water_mark_url);
@ -178,22 +179,23 @@ function vbar_graph(
if ($ttl == 2) { if ($ttl == 2) {
$params = [ $params = [
'chart_data' => $chart_data, 'chart_data' => $chart_data,
'width' => $width, 'width' => $width,
'height' => $height, 'height' => $height,
'color' => $color, 'color' => $color,
'legend' => $legend, 'legend' => $legend,
'long_index' => $long_index, 'long_index' => $long_index,
'homeurl' => $homeurl, 'homeurl' => $homeurl,
'unit' => $unit, 'unit' => $unit,
'water_mark_url' => $water_mark_url, 'water_mark_url' => $water_mark_url,
'homedir' => $homedir, 'homedir' => $homedir,
'font' => $font, 'font' => $font,
'font_size' => $font_size, 'font_size' => $font_size,
'from_ux' => $from_ux, 'from_ux' => $from_ux,
'from_wux' => $from_wux, 'from_wux' => $from_wux,
'backgroundColor' => $backgroundColor, 'backgroundColor' => $backgroundColor,
'tick_color' => $tick_color, 'tick_color' => $tick_color,
'return_img_base_64' => $base64,
]; ];
return generator_chart_to_pdf('vbar', $params); return generator_chart_to_pdf('vbar', $params);
} }
@ -345,7 +347,8 @@ function hbar_graph(
$backgroundColor='white', $backgroundColor='white',
$tick_color='white', $tick_color='white',
$val_min=null, $val_min=null,
$val_max=null $val_max=null,
$base64=false
) { ) {
setup_watermark($water_mark, $water_mark_file, $water_mark_url); setup_watermark($water_mark, $water_mark_file, $water_mark_url);
@ -355,16 +358,17 @@ function hbar_graph(
if ($ttl == 2) { if ($ttl == 2) {
$params = [ $params = [
'chart_data' => $chart_data, 'chart_data' => $chart_data,
'width' => $width, 'width' => $width,
'height' => $height, 'height' => $height,
'water_mark_url' => $water_mark_url, 'water_mark_url' => $water_mark_url,
'font' => $font, 'font' => $font,
'font_size' => $font_size, 'font_size' => $font_size,
'backgroundColor' => $backgroundColor, 'backgroundColor' => $backgroundColor,
'tick_color' => $tick_color, 'tick_color' => $tick_color,
'val_min' => $val_min, 'val_min' => $val_min,
'val_max' => $val_max, 'val_max' => $val_max,
'return_img_base_64' => $base64,
]; ];
return generator_chart_to_pdf('hbar', $params); return generator_chart_to_pdf('hbar', $params);
} }

View File

@ -1,6 +1,6 @@
/* global $ */ /* global $ */
/* exported pandoraFlotPie, pandoraFlotPieCustom */
// eslint-disable-next-line no-unused-vars
function pandoraFlotPie( function pandoraFlotPie(
graph_id, graph_id,
values, values,
@ -73,8 +73,9 @@ function pandoraFlotPie(
case "right": case "right":
case "inner": case "inner":
conf_pie.legend.container = $("#" + graph_id + "_legend"); conf_pie.legend.container = $("#" + graph_id + "_legend");
break;
default: default:
//TODO FOR TOP OR LEFT OR RIGHT // TODO FOR TOP OR LEFT OR RIGHT.
break; break;
} }
@ -85,7 +86,7 @@ function pandoraFlotPie(
// Events // Events
$("#" + graph_id).bind("plothover", pieHover); $("#" + graph_id).bind("plothover", pieHover);
$("#" + graph_id).bind("plotclick", pieClick); //$("#" + graph_id).bind("plotclick", pieClick);
$("#" + graph_id).bind("mouseout", resetInteractivity); $("#" + graph_id).bind("mouseout", resetInteractivity);
$("#" + graph_id).css("margin-left", "auto"); $("#" + graph_id).css("margin-left", "auto");
$("#" + graph_id).css("margin-right", "auto"); $("#" + graph_id).css("margin-right", "auto");
@ -125,6 +126,7 @@ function pandoraFlotPie(
} }
} }
// eslint-disable-next-line no-unused-vars
function pandoraFlotPieCustom( function pandoraFlotPieCustom(
graph_id, graph_id,
values, values,
@ -311,11 +313,11 @@ function pandoraFlotPieCustom(
} }
} }
// eslint-disable-next-line no-unused-vars
function pandoraFlotHBars( function pandoraFlotHBars(
graph_id, graph_id,
values, values,
labels, labels,
water_mark,
maxvalue, maxvalue,
water_mark, water_mark,
separator, separator,
@ -346,7 +348,7 @@ function pandoraFlotHBars(
var serie = values[i].split(separator); var serie = values[i].split(separator);
var aux = new Array(); var aux = new Array();
for (j = 0; j < serie.length; j++) { for (var j = 0; j < serie.length; j++) {
var aux2 = parseFloat(serie[j]); var aux2 = parseFloat(serie[j]);
aux.push([aux2, j]); aux.push([aux2, j]);
datas.push({ datas.push({
@ -358,16 +360,10 @@ function pandoraFlotHBars(
var labels_total = new Array(); var labels_total = new Array();
labels = labels.split(separator); labels = labels.split(separator);
i = 0; for (var i = 0; i < labels.length; i++) {
for (i = 0; i < labels.length; i++) {
labels_total.push([i, labels[i]]); labels_total.push([i, labels[i]]);
} }
var stack = 0,
bars = true,
lines = false,
steps = false;
var k = 0;
var options = { var options = {
series: { series: {
bars: { bars: {
@ -428,15 +424,14 @@ function pandoraFlotHBars(
$("#" + graph_id).HUseTooltip(); $("#" + graph_id).HUseTooltip();
$("#" + graph_id).css("margin-left", "auto"); $("#" + graph_id).css("margin-left", "auto");
$("#" + graph_id).css("margin-right", "auto"); $("#" + graph_id).css("margin-right", "auto");
//~ $('#' + graph_id).find('div.legend-tooltip').tooltip({ track: true });
function yFormatter(v, axis) { // v, axis;
format = new Array(); function yFormatter() {
for (i = 0; i < labels_total.length; i++) { var format = new Array();
for (var i = 0; i < labels_total.length; i++) {
var label = labels_total[i][1]; var label = labels_total[i][1];
// var shortLabel = reduceText(label, 25); // var shortLabel = reduceText(label, 25);
var title = label; var title = label;
var margin_top = 0;
if (label.length > 30) { if (label.length > 30) {
label = reduceText(label, 30); label = reduceText(label, 30);
} }
@ -460,9 +455,10 @@ function pandoraFlotHBars(
return format; return format;
} }
function xFormatter(v, axis) { // v, axis;
label = parseFloat(v); function xFormatter(v) {
text = label.toLocaleString(); var label = parseFloat(v);
var text = label.toLocaleString();
if (label >= 1000000) text = text.substring(0, 4) + "M"; if (label >= 1000000) text = text.substring(0, 4) + "M";
else if (label >= 100000) text = text.substring(0, 3) + "K"; else if (label >= 100000) text = text.substring(0, 3) + "K";
else if (label >= 1000) text = text.substring(0, 2) + "K"; else if (label >= 1000) text = text.substring(0, 2) + "K";
@ -500,7 +496,7 @@ $.fn.HUseTooltip = function() {
$("#tooltip").remove(); $("#tooltip").remove();
var x = item.datapoint[0]; var x = item.datapoint[0];
var y = item.datapoint[1]; // var y = item.datapoint[1];
var color = item.series.color; var color = item.series.color;
showTooltip(pos.pageX, pos.pageY, color, "<strong>" + x + "</strong>"); showTooltip(pos.pageX, pos.pageY, color, "<strong>" + x + "</strong>");
@ -523,7 +519,7 @@ $.fn.VUseTooltip = function() {
$("#tooltip").remove(); $("#tooltip").remove();
var x = item.datapoint[0]; // var x = item.datapoint[0];
var y = item.datapoint[1]; var y = item.datapoint[1];
var color = item.series.color; var color = item.series.color;
@ -555,6 +551,7 @@ function showTooltip(x, y, color, contents) {
.fadeIn(200); .fadeIn(200);
} }
// eslint-disable-next-line no-unused-vars
function pandoraFlotVBars( function pandoraFlotVBars(
graph_id, graph_id,
values, values,
@ -562,7 +559,6 @@ function pandoraFlotVBars(
labels_long, labels_long,
legend, legend,
colors, colors,
water_mark,
maxvalue, maxvalue,
water_mark, water_mark,
separator, separator,
@ -590,11 +586,11 @@ function pandoraFlotVBars(
: ["#FFA631", "#e63c52", "#f3b200", "#5BB6E5", "#F2919D", "#82b92e"]; : ["#FFA631", "#e63c52", "#f3b200", "#5BB6E5", "#F2919D", "#82b92e"];
var datas = new Array(); var datas = new Array();
for (i = 0; i < values.length; i++) { for (var i = 0; i < values.length; i++) {
var serie = values[i].split(separator); var serie = values[i].split(separator);
var aux = new Array(); var aux = new Array();
for (j = 0; j < serie.length; j++) { for (var j = 0; j < serie.length; j++) {
var aux2 = parseFloat(serie[j]); var aux2 = parseFloat(serie[j]);
aux.push([aux2, j]); aux.push([aux2, j]);
if (from_ux) { if (from_ux) {
@ -618,11 +614,6 @@ function pandoraFlotVBars(
labels_total.push([i, labels[i]]); labels_total.push([i, labels[i]]);
} }
var stack = 0,
bars = true,
lines = false,
steps = false;
var options = { var options = {
series: { series: {
bars: { bars: {
@ -650,9 +641,9 @@ function pandoraFlotVBars(
axisLabelFontFamily: font + "Font", axisLabelFontFamily: font + "Font",
axisLabelPadding: 100, axisLabelPadding: 100,
autoscaleMargin: 0.02, autoscaleMargin: 0.02,
tickFormatter: function(v, axis) { tickFormatter: function(v) {
label = parseFloat(v); var label = parseFloat(v);
text = label.toLocaleString(); var text = label.toLocaleString();
if (label >= 1000000) text = text.substring(0, 4) + "M"; if (label >= 1000000) text = text.substring(0, 4) + "M";
else if (label >= 100000) text = text.substring(0, 3) + "K"; else if (label >= 100000) text = text.substring(0, 3) + "K";
else if (label >= 1000) text = text.substring(0, 2) + "K"; else if (label >= 1000) text = text.substring(0, 2) + "K";
@ -718,7 +709,7 @@ function pandoraFlotVBars(
.css("top", "+0px") .css("top", "+0px")
.css("left", "-20px"); .css("left", "-20px");
// Format functions // Format functions
function xFormatter(v, axis) { function xFormatter() {
var format = new Array(); var format = new Array();
for (i = 0; i < labels_total.length; i++) { for (i = 0; i < labels_total.length; i++) {
var label = labels_total[i][1]; var label = labels_total[i][1];
@ -751,7 +742,8 @@ function pandoraFlotVBars(
return format; return format;
} }
function yFormatter(v, axis) { /*
function yFormatter(v) {
return ( return (
'<div class="' + '<div class="' +
font + font +
@ -768,6 +760,7 @@ function pandoraFlotVBars(
'<div style="font-size:' + font_size + 'pt !important;">' + v + "</div>" '<div style="font-size:' + font_size + 'pt !important;">' + v + "</div>"
); );
} }
*/
if (water_mark) { if (water_mark) {
set_watermark( set_watermark(
@ -778,6 +771,7 @@ function pandoraFlotVBars(
} }
} }
// eslint-disable-next-line no-unused-vars
function pandoraFlotSlicebar( function pandoraFlotSlicebar(
graph_id, graph_id,
values, values,
@ -919,6 +913,8 @@ function pandoraFlotSlicebar(
//current date //current date
var dateObj = new Date(); var dateObj = new Date();
var newdate = "";
var newdate2 = "";
if (full_legend != "") { if (full_legend != "") {
newdate = full_legend[item.seriesIndex]; newdate = full_legend[item.seriesIndex];
newdate2 = full_legend[item.seriesIndex + 1]; newdate2 = full_legend[item.seriesIndex + 1];
@ -968,8 +964,8 @@ function pandoraFlotSlicebar(
} }
// Format functions // Format functions
function xFormatter(v, axis) { function xFormatter(v) {
d = new Date(1000 * (v + datelimit)); var d = new Date(1000 * (v + datelimit));
var monthNames = [ var monthNames = [
"Jan", "Jan",
"Feb", "Feb",
@ -1000,6 +996,7 @@ function pandoraFlotSlicebar(
} }
} }
// eslint-disable-next-line no-unused-vars
function pandoraFlotArea( function pandoraFlotArea(
graph_id, graph_id,
values, values,
@ -1036,7 +1033,7 @@ function pandoraFlotArea(
var legend_color = params.legend_color; var legend_color = params.legend_color;
var update_legend = {}; var update_legend = {};
var force_integer = 0; var force_integer = 0;
var title = params.title; // var title = params.title;
var divisor = params.divisor; var divisor = params.divisor;
if (typeof divisor === "undefined") { if (typeof divisor === "undefined") {

View File

@ -615,8 +615,7 @@ function flot_hcolumn_chart($graph_data, $width, $height, $water_mark, $font='',
// Javascript code // Javascript code
$return .= "<script type='text/javascript'>"; $return .= "<script type='text/javascript'>";
$return .= "pandoraFlotHBars('$graph_id', '$values', '$labels', $return .= "pandoraFlotHBars('$graph_id', '$values', '$labels', $max, '$water_mark', '$separator', '$separator2', '$font', $font_size, '$background_color', '$tick_color', $val_min, $val_max)";
false, $max, '$water_mark', '$separator', '$separator2', '$font', $font_size, '$background_color', '$tick_color', $val_min, $val_max)";
$return .= '</script>'; $return .= '</script>';
return $return; return $return;
@ -708,12 +707,12 @@ function flot_vcolumn_chart($graph_data, $width, $height, $color, $legend, $long
$return .= "<script type='text/javascript'>"; $return .= "<script type='text/javascript'>";
if ($from_ux) { if ($from_ux) {
if ($from_wux) { if ($from_wux) {
$return .= "pandoraFlotVBars('$graph_id', '$values', '$labels', '$labels', '$legend', '$colors', false, $max, '$water_mark', '$separator', '$separator2','$font',$font_size, true, true, '$background_color', '$tick_color')"; $return .= "pandoraFlotVBars('$graph_id', '$values', '$labels', '$labels', '$legend', '$colors', $max, '$water_mark', '$separator', '$separator2','$font',$font_size, true, true, '$background_color', '$tick_color')";
} else { } else {
$return .= "pandoraFlotVBars('$graph_id', '$values', '$labels', '$labels', '$legend', '$colors', false, $max, '$water_mark', '$separator', '$separator2','$font',$font_size, true, false, '$background_color', '$tick_color')"; $return .= "pandoraFlotVBars('$graph_id', '$values', '$labels', '$labels', '$legend', '$colors', $max, '$water_mark', '$separator', '$separator2','$font',$font_size, true, false, '$background_color', '$tick_color')";
} }
} else { } else {
$return .= "pandoraFlotVBars('$graph_id', '$values', '$labels', '$labels', '$legend', '$colors', false, $max, '$water_mark', '$separator', '$separator2','$font',$font_size, false, false, '$background_color', '$tick_color')"; $return .= "pandoraFlotVBars('$graph_id', '$values', '$labels', '$labels', '$legend', '$colors', $max, '$water_mark', '$separator', '$separator2','$font',$font_size, false, false, '$background_color', '$tick_color')";
} }
$return .= '</script>'; $return .= '</script>';

View File

@ -12,6 +12,8 @@
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
/* globals jQuery, d3 */
// The recipient is the selector of the html element // The recipient is the selector of the html element
// The elements is an array with the names of the wheel elements // The elements is an array with the names of the wheel elements
// The matrix must be a 2 dimensional array with a row and a column for each element // The matrix must be a 2 dimensional array with a row and a column for each element
@ -2293,6 +2295,7 @@ function print_interior_circular_progress_bar(
})(); })();
} }
// eslint-disable-next-line no-unused-vars
function print_donut_graph( function print_donut_graph(
recipient, recipient,
width, width,
@ -2309,40 +2312,13 @@ function print_donut_graph(
svg.append("g").attr("class", "slices"); svg.append("g").attr("class", "slices");
var radius = 120; var heightLegend = 25 * module_data.length;
var increment_y = 60;
var increment_y_padding = 25; var maxRadius = (height - heightLegend) / 2;
var decrement_x_padding = 150;
if (width >= 500) { var radius = maxRadius;
radius = 180; if (maxRadius > width / 2) {
increment_y = 60; radius = width / 2;
increment_y_padding = 20;
decrement_x_padding = 40;
} else if (width >= 400) {
radius = 140;
increment_y = 40;
increment_y_padding = 20;
decrement_x_padding = 40;
} else if (width >= 300) {
radius = 100;
increment_y = 40;
increment_y_padding = 15;
decrement_x_padding = 40;
} else if (width >= 200) {
radius = 50;
increment_y = 40;
increment_y_padding = 15;
decrement_x_padding = 25;
} else if (width >= 100) {
radius = 20;
increment_y = 20;
increment_y_padding = 8;
decrement_x_padding = 25;
} else {
radius = 10;
increment_y = 10;
increment_y_padding = 3;
decrement_x_padding = 5;
} }
var arc = d3.svg var arc = d3.svg
@ -2365,37 +2341,22 @@ function print_donut_graph(
svg svg
.append("g") .append("g")
.append("rect") .append("rect")
.attr(
"transform",
"translate(" +
(width / 2 - (radius + decrement_x_padding)) +
"," +
(height / 2 - radius - increment_y) +
")"
)
.attr("fill", m_d.color) .attr("fill", m_d.color)
.attr("x", -20) .attr("x", 20)
.attr("y", -10) .attr("y", 20 * (key + 1))
.attr("width", 20) .attr("width", 25)
.attr("height", 10); .attr("height", 15);
svg svg
.append("g") .append("g")
.append("text") .append("text")
.attr("fill", resume_color) .attr("fill", resume_color)
.attr( .attr("transform", "translate(" + 40 + "," + 20 * (key + 1) + ")")
"transform", .attr("x", 15)
"translate(" + .attr("y", 10)
(width / 2 - (radius + decrement_x_padding) + 10) +
"," +
(height / 2 - radius - increment_y) +
")"
)
.text(m_d.tag_name) .text(m_d.tag_name)
.style("font-family", "smallfontFont") .style("font-family", "smallfontFont")
.style("font-size", "7pt"); .style("font-size", "7pt");
increment_y -= increment_y_padding;
}); });
function donutData() { function donutData() {
@ -2425,7 +2386,7 @@ function print_donut_graph(
.attr("class", "slice") .attr("class", "slice")
.attr( .attr(
"transform", "transform",
"translate(" + width / 2 + "," + (height - radius) + ")" "translate(" + width / 2 + "," + (height + heightLegend) / 2 + ")"
); );
slice slice

View File

@ -326,6 +326,7 @@ final class BarsGraph extends Item
} }
$moduleData = \get_bars_module_data($moduleId); $moduleData = \get_bars_module_data($moduleId);
array_pop($moduleData);
$waterMark = [ $waterMark = [
'file' => $config['homedir'].'/images/logo_vertical_water.png', 'file' => $config['homedir'].'/images/logo_vertical_water.png',
@ -358,12 +359,15 @@ final class BarsGraph extends Item
'', '',
$waterMark, $waterMark,
$config['fontpath'], $config['fontpath'],
6, $config['fontsize'],
'', '',
0, 2,
$config['homeurl'], $config['homeurl'],
$backGroundColor, $backGroundColor,
$gridColor $gridColor,
null,
null,
true
); );
} else { } else {
$graph = \vbar_graph( $graph = \vbar_graph(
@ -383,14 +387,15 @@ final class BarsGraph extends Item
'', '',
$waterMark, $waterMark,
$config['fontpath'], $config['fontpath'],
6, $config['fontsize'],
'', '',
0, 2,
$config['homeurl'], $config['homeurl'],
$backGroundColor, $backGroundColor,
true, true,
false, false,
$gridColor $gridColor,
true
); );
} }
@ -399,7 +404,10 @@ final class BarsGraph extends Item
\metaconsole_restore_db(); \metaconsole_restore_db();
} }
$data['html'] = $graph; $imgbase64 = 'data:image/jpg;base64,';
$imgbase64 .= $graph;
$data['html'] = $imgbase64;
return $data; return $data;
} }

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long