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

View File

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

View File

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

View File

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

View File

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

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long