Skip to content
Snippets Groups Projects
Commit e2e95b5f authored by Laurent Destailleur's avatar Laurent Destailleur
Browse files

phpcs

parent a5645b62
Branches
Tags
No related merge requests found
...@@ -65,7 +65,7 @@ class DolGraph ...@@ -65,7 +65,7 @@ class DolGraph
var $bgcolorgrid=array(255,255,255); // array(R,G,B) var $bgcolorgrid=array(255,255,255); // array(R,G,B)
var $datacolor; // array(array(R,G,B),...) var $datacolor; // array(array(R,G,B),...)
protected $_stringtoshow; // To store string to output graph into HTML page protected $stringtoshow; // To store string to output graph into HTML page
/** /**
...@@ -774,7 +774,7 @@ class DolGraph ...@@ -774,7 +774,7 @@ class DolGraph
// Generate file // Generate file
$graph->draw($file); $graph->draw($file);
$this->_stringtoshow='<!-- Build using '.$this->_library.' --><img src="'.$fileurl.'" title="'.dol_escape_htmltag($this->title?$this->title:$this->YLabel).'" alt="'.dol_escape_htmltag($this->title?$this->title:$this->YLabel).'">'; $this->stringtoshow='<!-- Build using '.$this->_library.' --><img src="'.$fileurl.'" title="'.dol_escape_htmltag($this->title?$this->title:$this->YLabel).'" alt="'.dol_escape_htmltag($this->title?$this->title:$this->YLabel).'">';
} }
...@@ -847,18 +847,18 @@ class DolGraph ...@@ -847,18 +847,18 @@ class DolGraph
} }
$tag=dol_escape_htmltag(dol_string_unaccent(dol_string_nospecial(basename($file),'_',array('-','.')))); $tag=dol_escape_htmltag(dol_string_unaccent(dol_string_nospecial(basename($file),'_',array('-','.'))));
$this->_stringtoshow ='<!-- Build using '.$this->_library.' -->'."\n"; $this->stringtoshow ='<!-- Build using '.$this->_library.' -->'."\n";
if (! empty($this->title)) $this->_stringtoshow.='<div align="center" class="dolgraphtitle'.(empty($this->cssprefix)?'':' dolgraphtitle'.$this->cssprefix).'">'.$this->title.'</div>'; if (! empty($this->title)) $this->stringtoshow.='<div align="center" class="dolgraphtitle'.(empty($this->cssprefix)?'':' dolgraphtitle'.$this->cssprefix).'">'.$this->title.'</div>';
$this->_stringtoshow.='<div id="placeholder_'.$tag.'" style="width:'.$this->width.'px;height:'.$this->height.'px;" class="dolgraph'.(empty($this->cssprefix)?'':' dolgraph'.$this->cssprefix).'"></div>'."\n"; $this->stringtoshow.='<div id="placeholder_'.$tag.'" style="width:'.$this->width.'px;height:'.$this->height.'px;" class="dolgraph'.(empty($this->cssprefix)?'':' dolgraph'.$this->cssprefix).'"></div>'."\n";
$this->_stringtoshow.='<script id="'.$tag.'">'."\n"; $this->stringtoshow.='<script id="'.$tag.'">'."\n";
$this->_stringtoshow.='$(function () {'."\n"; $this->stringtoshow.='$(function () {'."\n";
$i=$firstlot; $i=$firstlot;
while ($i < $nblot) while ($i < $nblot)
{ {
$this->_stringtoshow.=$serie[$i]; $this->stringtoshow.=$serie[$i];
$i++; $i++;
} }
$this->_stringtoshow.="\n"; $this->stringtoshow.="\n";
// Special case for Graph of type 'pie' // Special case for Graph of type 'pie'
if (isset($this->type[$firstlot]) && $this->type[$firstlot] == 'pie') if (isset($this->type[$firstlot]) && $this->type[$firstlot] == 'pie')
...@@ -871,7 +871,7 @@ class DolGraph ...@@ -871,7 +871,7 @@ class DolGraph
$showpointvalue=$this->showpointvalue; $showpointvalue=$this->showpointvalue;
$showpercent=$this->showpercent; $showpercent=$this->showpercent;
$this->_stringtoshow.= ' $this->stringtoshow.= '
function plotWithOptions_'.$tag.'() { function plotWithOptions_'.$tag.'() {
$.plot($("#placeholder_'.$tag.'"), d0, $.plot($("#placeholder_'.$tag.'"), d0,
{ {
...@@ -886,15 +886,15 @@ class DolGraph ...@@ -886,15 +886,15 @@ class DolGraph
var percent=Math.round(series.percent); var percent=Math.round(series.percent);
var number=series.data[0][1]; var number=series.data[0][1];
return \''; return \'';
$this->_stringtoshow.='<div style="font-size:8pt;text-align:center;padding:2px;color:white;">'; $this->stringtoshow.='<div style="font-size:8pt;text-align:center;padding:2px;color:white;">';
if ($urltemp) $this->_stringtoshow.='<a style="color: #FFFFFF;" border="0" href="'.$urltemp.'">'; if ($urltemp) $this->stringtoshow.='<a style="color: #FFFFFF;" border="0" href="'.$urltemp.'">';
$this->_stringtoshow.='\'+'; $this->stringtoshow.='\'+';
$this->_stringtoshow.=($showlegend?'':'label+\'<br/>\'+'); // Hide label if already shown in legend $this->stringtoshow.=($showlegend?'':'label+\'<br/>\'+'); // Hide label if already shown in legend
$this->_stringtoshow.=($showpointvalue?'number+':''); $this->stringtoshow.=($showpointvalue?'number+':'');
$this->_stringtoshow.=($showpercent?'\'<br/>\'+percent+\'%\'+':''); $this->stringtoshow.=($showpercent?'\'<br/>\'+percent+\'%\'+':'');
$this->_stringtoshow.='\''; $this->stringtoshow.='\'';
if ($urltemp) $this->_stringtoshow.='</a>'; if ($urltemp) $this->stringtoshow.='</a>';
$this->_stringtoshow.='</div>\'; $this->stringtoshow.='</div>\';
}, },
background: { background: {
opacity: 0.5, opacity: 0.5,
...@@ -911,9 +911,9 @@ class DolGraph ...@@ -911,9 +911,9 @@ class DolGraph
},'; },';
if (count($datacolor)) if (count($datacolor))
{ {
$this->_stringtoshow.='colors: '.(! empty($data['seriescolor']) ? json_encode($data['seriescolor']) : json_encode($datacolor)).','; $this->stringtoshow.='colors: '.(! empty($data['seriescolor']) ? json_encode($data['seriescolor']) : json_encode($datacolor)).',';
} }
$this->_stringtoshow.='legend: {show: '.($showlegend?'true':'false').', position: \'ne\' } $this->stringtoshow.='legend: {show: '.($showlegend?'true':'false').', position: \'ne\' }
}); });
}'."\n"; }'."\n";
} }
...@@ -921,7 +921,7 @@ class DolGraph ...@@ -921,7 +921,7 @@ class DolGraph
else else
{ {
// Add code to support tooltips // Add code to support tooltips
$this->_stringtoshow.=' $this->stringtoshow.='
function showTooltip_'.$tag.'(x, y, contents) { function showTooltip_'.$tag.'(x, y, contents) {
$(\'<div id="tooltip_'.$tag.'">\' + contents + \'</div>\').css({ $(\'<div id="tooltip_'.$tag.'">\' + contents + \'</div>\').css({
position: \'absolute\', position: \'absolute\',
...@@ -951,10 +951,10 @@ class DolGraph ...@@ -951,10 +951,10 @@ class DolGraph
var y = item.datapoint[1].toFixed(2); var y = item.datapoint[1].toFixed(2);
var z = item.series.xaxis.ticks[item.dataIndex].label; var z = item.series.xaxis.ticks[item.dataIndex].label;
'; ';
if ($this->showpointvalue > 0) $this->_stringtoshow.=' if ($this->showpointvalue > 0) $this->stringtoshow.='
showTooltip_'.$tag.'(item.pageX, item.pageY, item.series.label + "<br>" + z + " => " + y); showTooltip_'.$tag.'(item.pageX, item.pageY, item.series.label + "<br>" + z + " => " + y);
'; ';
$this->_stringtoshow.=' $this->stringtoshow.='
} }
} }
else { else {
...@@ -964,50 +964,50 @@ class DolGraph ...@@ -964,50 +964,50 @@ class DolGraph
}); });
'; ';
$this->_stringtoshow.='var stack = null, steps = false;'."\n"; $this->stringtoshow.='var stack = null, steps = false;'."\n";
$this->_stringtoshow.='function plotWithOptions_'.$tag.'() {'."\n"; $this->stringtoshow.='function plotWithOptions_'.$tag.'() {'."\n";
$this->_stringtoshow.='$.plot($("#placeholder_'.$tag.'"), [ '."\n"; $this->stringtoshow.='$.plot($("#placeholder_'.$tag.'"), [ '."\n";
$i=$firstlot; $i=$firstlot;
while ($i < $nblot) while ($i < $nblot)
{ {
if ($i > $firstlot) $this->_stringtoshow.=', '."\n"; if ($i > $firstlot) $this->stringtoshow.=', '."\n";
$color=sprintf("%02x%02x%02x",$this->datacolor[$i][0],$this->datacolor[$i][1],$this->datacolor[$i][2]); $color=sprintf("%02x%02x%02x",$this->datacolor[$i][0],$this->datacolor[$i][1],$this->datacolor[$i][2]);
$this->_stringtoshow.='{ '; $this->stringtoshow.='{ ';
if (! isset($this->type[$i]) || $this->type[$i] == 'bars') $this->_stringtoshow.='bars: { show: true, align: "'.($i==$firstlot?'center':'left').'", barWidth: 0.5 }, '; if (! isset($this->type[$i]) || $this->type[$i] == 'bars') $this->stringtoshow.='bars: { show: true, align: "'.($i==$firstlot?'center':'left').'", barWidth: 0.5 }, ';
if (isset($this->type[$i]) && $this->type[$i] == 'lines') $this->_stringtoshow.='lines: { show: true, fill: false }, '; if (isset($this->type[$i]) && $this->type[$i] == 'lines') $this->stringtoshow.='lines: { show: true, fill: false }, ';
$this->_stringtoshow.='color: "#'.$color.'", label: "'.(isset($this->Legend[$i]) ? dol_escape_js($this->Legend[$i]) : '').'", data: d'.$i.' }'; $this->stringtoshow.='color: "#'.$color.'", label: "'.(isset($this->Legend[$i]) ? dol_escape_js($this->Legend[$i]) : '').'", data: d'.$i.' }';
$i++; $i++;
} }
$this->_stringtoshow.="\n".' ], { series: { stack: stack, lines: { fill: false, steps: steps }, bars: { barWidth: 0.6 } }'."\n"; $this->stringtoshow.="\n".' ], { series: { stack: stack, lines: { fill: false, steps: steps }, bars: { barWidth: 0.6 } }'."\n";
// Xaxis // Xaxis
$this->_stringtoshow.=', xaxis: { ticks: ['."\n"; $this->stringtoshow.=', xaxis: { ticks: ['."\n";
$x=0; $x=0;
foreach($this->data as $key => $valarray) foreach($this->data as $key => $valarray)
{ {
if ($x > 0) $this->_stringtoshow.=', '."\n"; if ($x > 0) $this->stringtoshow.=', '."\n";
$this->_stringtoshow.= ' ['.$x.', "'.$valarray[0].'"]'; $this->stringtoshow.= ' ['.$x.', "'.$valarray[0].'"]';
$x++; $x++;
} }
$this->_stringtoshow.='] }'."\n"; $this->stringtoshow.='] }'."\n";
// Yaxis // Yaxis
$this->_stringtoshow.=', yaxis: { min: '.$this->MinValue.', max: '.($this->MaxValue).' }'."\n"; $this->stringtoshow.=', yaxis: { min: '.$this->MinValue.', max: '.($this->MaxValue).' }'."\n";
// Background color // Background color
$color1=sprintf("%02x%02x%02x",$this->bgcolorgrid[0],$this->bgcolorgrid[0],$this->bgcolorgrid[2]); $color1=sprintf("%02x%02x%02x",$this->bgcolorgrid[0],$this->bgcolorgrid[0],$this->bgcolorgrid[2]);
$color2=sprintf("%02x%02x%02x",$this->bgcolorgrid[0],$this->bgcolorgrid[1],$this->bgcolorgrid[2]); $color2=sprintf("%02x%02x%02x",$this->bgcolorgrid[0],$this->bgcolorgrid[1],$this->bgcolorgrid[2]);
$this->_stringtoshow.=', grid: { hoverable: true, backgroundColor: { colors: ["#'.$color1.'", "#'.$color2.'"] } }'."\n"; $this->stringtoshow.=', grid: { hoverable: true, backgroundColor: { colors: ["#'.$color1.'", "#'.$color2.'"] } }'."\n";
//$this->_stringtoshow.=', shadowSize: 20'."\n"; TODO Uncommet this //$this->stringtoshow.=', shadowSize: 20'."\n"; TODO Uncommet this
$this->_stringtoshow.='});'."\n"; $this->stringtoshow.='});'."\n";
$this->_stringtoshow.='}'."\n"; $this->stringtoshow.='}'."\n";
} }
$this->_stringtoshow.='plotWithOptions_'.$tag.'();'."\n"; $this->stringtoshow.='plotWithOptions_'.$tag.'();'."\n";
$this->_stringtoshow.='});'."\n"; $this->stringtoshow.='});'."\n";
$this->_stringtoshow.='</script>'."\n"; $this->stringtoshow.='</script>'."\n";
} }
...@@ -1019,7 +1019,7 @@ class DolGraph ...@@ -1019,7 +1019,7 @@ class DolGraph
*/ */
function show() function show()
{ {
return $this->_stringtoshow; return $this->stringtoshow;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment