Skip to content

Commit

Permalink
Remove the no more used and deprecated dol_print_graph function
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed Nov 20, 2018
1 parent 966a0b7 commit 1ecdaa5
Showing 1 changed file with 0 additions and 182 deletions.
182 changes: 0 additions & 182 deletions htdocs/core/lib/functions.lib.php
Expand Up @@ -2890,188 +2890,6 @@ function dol_substr($string, $start, $length, $stringencoding='', $trunconbytes=
}


/**
* Show a javascript graph.
* Do not use this function anymore. Use DolGraph class instead.
*
* @param string $htmlid Html id name
* @param int $width Width in pixel
* @param int $height Height in pixel
* @param array $data Data array
* @param int $showlegend 1 to show legend, 0 otherwise
* @param string $type Type of graph ('pie', 'barline')
* @param int $showpercent Show percent (with type='pie' only)
* @param string $url Param to add an url to click values
* @param int $combineother 0=No combine, 0.05=Combine if lower than 5%
* @param int $shownographyet Show graph to say there is not enough data
* @return void
* @deprecated
* @see DolGraph
*/
function dol_print_graph($htmlid,$width,$height,$data,$showlegend=0,$type='pie',$showpercent=0,$url='',$combineother=0.05,$shownographyet=0)
{
dol_syslog(__FUNCTION__ . " is deprecated", LOG_WARNING);

global $conf,$langs;
global $theme_datacolor; // To have var kept when function is called several times

if ($shownographyet)
{
print '<div class="nographyet" style="width:'.$width.'px;height:'.$height.'px;"></div>';
print '<div class="nographyettext">'.$langs->trans("NotEnoughDataYet").'</div>';
return;
}

if (empty($conf->use_javascript_ajax)) return;
$jsgraphlib='flot';
$datacolor=array();

// Load colors of theme into $datacolor array
$color_file = DOL_DOCUMENT_ROOT."/theme/".$conf->theme."/graph-color.php";
if (is_readable($color_file))
{
include_once $color_file;
if (isset($theme_datacolor))
{
$datacolor=array();
foreach($theme_datacolor as $val)
{
$datacolor[]="#".sprintf("%02x",$val[0]).sprintf("%02x",$val[1]).sprintf("%02x",$val[2]);
}
}
}
print '<div id="'.$htmlid.'" style="width:'.$width.'px;height:'.$height.'px;"></div>';

// We use Flot js lib
if ($jsgraphlib == 'flot')
{
if ($type == 'pie')
{
// data is array('series'=>array(serie1,serie2,...),
// 'seriestype'=>array('bar','line',...),
// 'seriescolor'=>array(0=>'#999999',1=>'#999999',...)
// 'xlabel'=>array(0=>labelx1,1=>labelx2,...));
// serieX is array('label'=>'label', data=>val)
print '
<script type="text/javascript">
$(function () {
var data = '.json_encode($data['series']).';
function plotWithOptions() {
$.plot($("#'.$htmlid.'"), data,
{
series: {
pie: {
show: true,
radius: 0.8,';
if ($combineother)
{
print '
combine: {
threshold: '.$combineother.'
},';
}
print '
label: {
show: true,
radius: 0.9,
formatter: function(label, series) {
var percent=Math.round(series.percent);
var number=series.data[0][1];
return \'';
print '<div style="font-size:8pt;text-align:center;padding:2px;color:black;">';
if ($url) print '<a style="color: #FFFFFF;" border="0" href="'.$url.'">';
print '\'+'.($showlegend?'number':'label+\' \'+number');
if (! empty($showpercent)) print '+\'<br/>\'+percent+\'%\'';
print '+\'';
if ($url) print '</a>';
print '</div>\';
},
background: {
opacity: 0.0,
color: \'#000000\'
},
}
}
},
zoom: {
interactive: true
},
pan: {
interactive: true
},';
if (count($datacolor))
{
print 'colors: '.(! empty($data['seriescolor']) ? json_encode($data['seriescolor']) : json_encode($datacolor)).',';
}
print 'legend: {show: '.($showlegend?'true':'false').', position: \'ne\' }
});
}
plotWithOptions();
});
</script>';
}
else if ($type == 'barline')
{
// data is array('series'=>array(serie1,serie2,...),
// 'seriestype'=>array('bar','line',...),
// 'seriescolor'=>array(0=>'#999999',1=>'#999999',...)
// 'xlabel'=>array(0=>labelx1,1=>labelx2,...));
// serieX is array('label'=>'label', data=>array(0=>y1,1=>y2,...)) with same nb of value than into xlabel
print '
<script type="text/javascript">
$(function () {
var data = [';
$i=0; $outputserie=0;
foreach($data['series'] as $serie)
{
if ($data['seriestype'][$i]=='line') { $i++; continue; };
if ($outputserie > 0) print ',';
print '{ bars: { stack: 0, show: true, barWidth: 0.9, align: \'center\' }, label: \''.dol_escape_js($serie['label']).'\', data: '.json_encode($serie['data']).'}'."\n";
$outputserie++; $i++;
}
if ($outputserie) print ', ';
//print '];
//var datalines = [';
$i=0; $outputserie=0;
foreach($data['series'] as $serie)
{
if (empty($data['seriestype'][$i]) || $data['seriestype'][$i]=='bar') { $i++; continue; };
if ($outputserie > 0) print ',';
print '{ lines: { show: true }, label: \''.dol_escape_js($serie['label']).'\', data: '.json_encode($serie['data']).'}'."\n";
$outputserie++; $i++;
}
print '];
var dataticks = '.json_encode($data['xlabel']).'
function plotWithOptions() {
$.plot(jQuery("#'.$htmlid.'"), data,
{
series: {
stack: 0
},
zoom: {
interactive: true
},
pan: {
interactive: true
},';
if (count($datacolor))
{
print 'colors: '.json_encode($datacolor).',';
}
print 'legend: {show: '.($showlegend?'true':'false').'},
xaxis: {ticks: dataticks}
});
}
plotWithOptions();
});
</script>';
}
else print 'BadValueForParameterType';
}
}

/**
* Truncate a string to a particular length adding '...' if string larger than length.
* If length = max length+1, we do no truncate to avoid having just 1 char replaced with '...'.
Expand Down

0 comments on commit 1ecdaa5

Please sign in to comment.