phpcs
This commit is contained in:
parent
a5645b626c
commit
e2e95b5f8c
@ -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
|
|||||||
// 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
|
|||||||
}
|
}
|
||||||
$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
|
|||||||
$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
|
|||||||
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
|
|||||||
},';
|
},';
|
||||||
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
|
|||||||
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\',
|
||||||
@ -935,26 +935,26 @@ class DolGraph
|
|||||||
opacity: 0.80
|
opacity: 0.80
|
||||||
}).appendTo("body").fadeIn(20);
|
}).appendTo("body").fadeIn(20);
|
||||||
}
|
}
|
||||||
|
|
||||||
var previousPoint = null;
|
var previousPoint = null;
|
||||||
$("#placeholder_'.$tag.'").bind("plothover", function (event, pos, item) {
|
$("#placeholder_'.$tag.'").bind("plothover", function (event, pos, item) {
|
||||||
$("#x").text(pos.x.toFixed(2));
|
$("#x").text(pos.x.toFixed(2));
|
||||||
$("#y").text(pos.y.toFixed(2));
|
$("#y").text(pos.y.toFixed(2));
|
||||||
|
|
||||||
if (item) {
|
if (item) {
|
||||||
if (previousPoint != item.dataIndex) {
|
if (previousPoint != item.dataIndex) {
|
||||||
previousPoint = item.dataIndex;
|
previousPoint = item.dataIndex;
|
||||||
|
|
||||||
$("#tooltip").remove();
|
$("#tooltip").remove();
|
||||||
/* console.log(item); */
|
/* console.log(item); */
|
||||||
var x = item.datapoint[0].toFixed(2);
|
var x = item.datapoint[0].toFixed(2);
|
||||||
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
|
|||||||
});
|
});
|
||||||
';
|
';
|
||||||
|
|
||||||
$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,10 +1019,10 @@ class DolGraph
|
|||||||
*/
|
*/
|
||||||
function show()
|
function show()
|
||||||
{
|
{
|
||||||
return $this->_stringtoshow;
|
return $this->stringtoshow;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getDefaultGraphSizeForStats
|
* getDefaultGraphSizeForStats
|
||||||
*
|
*
|
||||||
@ -1033,18 +1033,18 @@ class DolGraph
|
|||||||
static function getDefaultGraphSizeForStats($direction,$defaultsize='')
|
static function getDefaultGraphSizeForStats($direction,$defaultsize='')
|
||||||
{
|
{
|
||||||
global $conf;
|
global $conf;
|
||||||
|
|
||||||
if ($direction == 'width')
|
if ($direction == 'width')
|
||||||
{
|
{
|
||||||
if (empty($conf->dol_optimize_smallscreen)) return ($defaultsize ? $defaultsize : '500');
|
if (empty($conf->dol_optimize_smallscreen)) return ($defaultsize ? $defaultsize : '500');
|
||||||
else return (empty($_SESSION['dol_screen_width']) ? '280' : ($_SESSION['dol_screen_width']-40));
|
else return (empty($_SESSION['dol_screen_width']) ? '280' : ($_SESSION['dol_screen_width']-40));
|
||||||
}
|
}
|
||||||
if ($direction == 'height')
|
if ($direction == 'height')
|
||||||
{
|
{
|
||||||
return (empty($conf->dol_optimize_smallscreen)?($defaultsize?$defaultsize:'200'):'160');
|
return (empty($conf->dol_optimize_smallscreen)?($defaultsize?$defaultsize:'200'):'160');
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user