funnel horizontal bar
This commit is contained in:
parent
43b1be01d9
commit
83286d99be
@ -81,6 +81,8 @@ class box_funnel_of_prospection extends ModeleBoxes
|
|||||||
$sql = "SELECT cls.rowid, cls.code, cls.percent, cls.label";
|
$sql = "SELECT cls.rowid, cls.code, cls.percent, cls.label";
|
||||||
$sql .= " FROM " . MAIN_DB_PREFIX . "c_lead_status as cls";
|
$sql .= " FROM " . MAIN_DB_PREFIX . "c_lead_status as cls";
|
||||||
$sql .= " WHERE active=1";
|
$sql .= " WHERE active=1";
|
||||||
|
$sql .= " Order by cls.rowid";
|
||||||
|
$sql .= " AND cls.code != 'LOST'";
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
if ($resql) {
|
if ($resql) {
|
||||||
$num = $this->db->num_rows($resql);
|
$num = $this->db->num_rows($resql);
|
||||||
@ -108,7 +110,6 @@ class box_funnel_of_prospection extends ModeleBoxes
|
|||||||
$colorseriesstat[$objp->rowid] = $badgeStatus6;
|
$colorseriesstat[$objp->rowid] = $badgeStatus6;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$colorseriesstat[$objp->rowid] = $badgeStatus2;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$i++;
|
$i++;
|
||||||
@ -167,14 +168,16 @@ class box_funnel_of_prospection extends ModeleBoxes
|
|||||||
$stringtoprint = '';
|
$stringtoprint = '';
|
||||||
$stringtoprint .= '<div class="div-table-responsive-no-min ">';
|
$stringtoprint .= '<div class="div-table-responsive-no-min ">';
|
||||||
$listofstatus = array_keys($listofoppstatus);
|
$listofstatus = array_keys($listofoppstatus);
|
||||||
|
$liststatus = array();
|
||||||
|
$data = array('');
|
||||||
foreach ($listofstatus as $status) {
|
foreach ($listofstatus as $status) {
|
||||||
$labelStatus = '';
|
$labelStatus = '';
|
||||||
if ($status != 7) {
|
if ($status != 7) {
|
||||||
$code = dol_getIdFromCode($this->db, $status, 'c_lead_status', 'rowid', 'code');
|
$code = dol_getIdFromCode($this->db, $status, 'c_lead_status', 'rowid', 'code');
|
||||||
if ($code) $labelStatus = $langs->transnoentitiesnoconv("OppStatus" . $code);
|
if ($code) $labelStatus = $langs->transnoentitiesnoconv("OppStatus" . $code);
|
||||||
if (empty($labelStatus)) $labelStatus = $listofopplabel[$status];
|
if (empty($labelStatus)) $labelStatus = $listofopplabel[$status];
|
||||||
|
$liststatus[] = $labelStatus;
|
||||||
$dataseries[] = array($labelStatus,(isset($valsamount[$status]) ? (float) $valsamount[$status] : 0));
|
$data[] = (isset($valsamount[$status]) ? (float) $valsamount[$status] : 0);
|
||||||
if (!$conf->use_javascript_ajax) {
|
if (!$conf->use_javascript_ajax) {
|
||||||
$stringtoprint .= '<tr class="oddeven">';
|
$stringtoprint .= '<tr class="oddeven">';
|
||||||
$stringtoprint .= '<td>' . $labelStatus . '</td>';
|
$stringtoprint .= '<td>' . $labelStatus . '</td>';
|
||||||
@ -183,16 +186,21 @@ class box_funnel_of_prospection extends ModeleBoxes
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$dataseries[] = $data;
|
||||||
if ($conf->use_javascript_ajax) {
|
if ($conf->use_javascript_ajax) {
|
||||||
include_once DOL_DOCUMENT_ROOT . '/core/class/dolgraph.class.php';
|
include_once DOL_DOCUMENT_ROOT . '/core/class/dolgraph.class.php';
|
||||||
$dolgraph = new DolGraph();
|
$dolgraph = new DolGraph();
|
||||||
|
$dolgraph->SetMinValue(0);
|
||||||
$dolgraph->SetData($dataseries);
|
$dolgraph->SetData($dataseries);
|
||||||
|
$dolgraph->SetLegend($liststatus);
|
||||||
$dolgraph->SetDataColor(array_values($colorseriesstat));
|
$dolgraph->SetDataColor(array_values($colorseriesstat));
|
||||||
//$dolgraph->SetLegend(array('PROSP',$dataseries['PROSP']));
|
|
||||||
$dolgraph->setShowLegend(2);
|
$dolgraph->setShowLegend(2);
|
||||||
$dolgraph->setShowPercent(1);
|
$dolgraph->setShowPercent(1);
|
||||||
$dolgraph->SetType(array('pie'));
|
$dolgraph->setTitle('FunnelOfProspection');
|
||||||
|
$dolgraph->SetType(array('horizontalbars'));
|
||||||
$dolgraph->SetHeight('200');
|
$dolgraph->SetHeight('200');
|
||||||
|
$dolgraph->SetWidth('600');
|
||||||
|
$dolgraph->mode='depth';
|
||||||
$dolgraph->draw('idgraphstatus');
|
$dolgraph->draw('idgraphstatus');
|
||||||
$stringtoprint .= $dolgraph->show($totaloppnb ? 0 : 1);
|
$stringtoprint .= $dolgraph->show($totaloppnb ? 0 : 1);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -104,8 +104,7 @@ class DolGraph
|
|||||||
$this->bgcolor = array(235, 235, 224);
|
$this->bgcolor = array(235, 235, 224);
|
||||||
|
|
||||||
$color_file = DOL_DOCUMENT_ROOT . '/theme/' . $conf->theme . '/theme_vars.inc.php';
|
$color_file = DOL_DOCUMENT_ROOT . '/theme/' . $conf->theme . '/theme_vars.inc.php';
|
||||||
if (is_readable($color_file))
|
if (is_readable($color_file)) {
|
||||||
{
|
|
||||||
include_once $color_file;
|
include_once $color_file;
|
||||||
if (isset($theme_bordercolor)) $this->bordercolor = $theme_bordercolor;
|
if (isset($theme_bordercolor)) $this->bordercolor = $theme_bordercolor;
|
||||||
if (isset($theme_datacolor)) $this->datacolor = $theme_datacolor;
|
if (isset($theme_datacolor)) $this->datacolor = $theme_datacolor;
|
||||||
@ -261,7 +260,7 @@ class DolGraph
|
|||||||
* Set type
|
* Set type
|
||||||
*
|
*
|
||||||
* @param array $type Array with type for each serie. Example: array('type1', 'type2', ...) where type can be:
|
* @param array $type Array with type for each serie. Example: array('type1', 'type2', ...) where type can be:
|
||||||
* 'pie', 'piesemicircle', 'polar', 'lines', 'linesnopoint', 'bars', 'horirontalbars'...
|
* 'pie', 'piesemicircle', 'polar', 'lines', 'linesnopoint', 'bars', 'horizontalbars'...
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function SetType($type)
|
public function SetType($type)
|
||||||
@ -466,10 +465,8 @@ class DolGraph
|
|||||||
// phpcs:enable
|
// phpcs:enable
|
||||||
global $theme_bgcolor, $theme_bgcoloronglet;
|
global $theme_bgcolor, $theme_bgcoloronglet;
|
||||||
|
|
||||||
if (!is_array($bg_color))
|
if (!is_array($bg_color)) {
|
||||||
{
|
if ($bg_color == 'onglet') {
|
||||||
if ($bg_color == 'onglet')
|
|
||||||
{
|
|
||||||
//print 'ee'.join(',',$theme_bgcoloronglet);
|
//print 'ee'.join(',',$theme_bgcoloronglet);
|
||||||
$this->bgcolor = $theme_bgcoloronglet;
|
$this->bgcolor = $theme_bgcoloronglet;
|
||||||
} else {
|
} else {
|
||||||
@ -492,10 +489,8 @@ class DolGraph
|
|||||||
// phpcs:enable
|
// phpcs:enable
|
||||||
global $theme_bgcolor, $theme_bgcoloronglet;
|
global $theme_bgcolor, $theme_bgcoloronglet;
|
||||||
|
|
||||||
if (!is_array($bg_colorgrid))
|
if (!is_array($bg_colorgrid)) {
|
||||||
{
|
if ($bg_colorgrid == 'onglet') {
|
||||||
if ($bg_colorgrid == 'onglet')
|
|
||||||
{
|
|
||||||
//print 'ee'.join(',',$theme_bgcoloronglet);
|
//print 'ee'.join(',',$theme_bgcoloronglet);
|
||||||
$this->bgcolorgrid = $theme_bgcoloronglet;
|
$this->bgcolorgrid = $theme_bgcoloronglet;
|
||||||
} else {
|
} else {
|
||||||
@ -535,10 +530,8 @@ class DolGraph
|
|||||||
$nblines = count($this->data);
|
$nblines = count($this->data);
|
||||||
$nbvalues = (empty($this->data[0]) ? 0 : count($this->data[0]) - 1);
|
$nbvalues = (empty($this->data[0]) ? 0 : count($this->data[0]) - 1);
|
||||||
|
|
||||||
for ($j = 0; $j < $nblines; $j++)
|
for ($j = 0; $j < $nblines; $j++) {
|
||||||
{
|
for ($i = 0; $i < $nbvalues; $i++) {
|
||||||
for ($i = 0; $i < $nbvalues; $i++)
|
|
||||||
{
|
|
||||||
$vals[$k] = $this->data[$j][$i + 1];
|
$vals[$k] = $this->data[$j][$i + 1];
|
||||||
$k++;
|
$k++;
|
||||||
}
|
}
|
||||||
@ -564,10 +557,8 @@ class DolGraph
|
|||||||
$nblines = count($this->data);
|
$nblines = count($this->data);
|
||||||
$nbvalues = (empty($this->data[0]) ? 0 : count($this->data[0]) - 1);
|
$nbvalues = (empty($this->data[0]) ? 0 : count($this->data[0]) - 1);
|
||||||
|
|
||||||
for ($j = 0; $j < $nblines; $j++)
|
for ($j = 0; $j < $nblines; $j++) {
|
||||||
{
|
for ($i = 0; $i < $nbvalues; $i++) {
|
||||||
for ($i = 0; $i < $nbvalues; $i++)
|
|
||||||
{
|
|
||||||
$vals[$k] = $this->data[$j][$i + 1];
|
$vals[$k] = $this->data[$j][$i + 1];
|
||||||
$k++;
|
$k++;
|
||||||
}
|
}
|
||||||
@ -589,8 +580,7 @@ class DolGraph
|
|||||||
if ($max != 0) $max++;
|
if ($max != 0) $max++;
|
||||||
$size = dol_strlen(abs(ceil($max)));
|
$size = dol_strlen(abs(ceil($max)));
|
||||||
$factor = 1;
|
$factor = 1;
|
||||||
for ($i = 0; $i < ($size - 1); $i++)
|
for ($i = 0; $i < ($size - 1); $i++) {
|
||||||
{
|
|
||||||
$factor *= 10;
|
$factor *= 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -615,8 +605,7 @@ class DolGraph
|
|||||||
if ($min != 0) $min--;
|
if ($min != 0) $min--;
|
||||||
$size = dol_strlen(abs(floor($min)));
|
$size = dol_strlen(abs(floor($min)));
|
||||||
$factor = 1;
|
$factor = 1;
|
||||||
for ($i = 0; $i < ($size - 1); $i++)
|
for ($i = 0; $i < ($size - 1); $i++) {
|
||||||
{
|
|
||||||
$factor *= 10;
|
$factor *= 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -635,20 +624,17 @@ class DolGraph
|
|||||||
*/
|
*/
|
||||||
public function draw($file, $fileurl = '')
|
public function draw($file, $fileurl = '')
|
||||||
{
|
{
|
||||||
if (empty($file))
|
if (empty($file)) {
|
||||||
{
|
|
||||||
$this->error = "Call to draw method was made with empty value for parameter file.";
|
$this->error = "Call to draw method was made with empty value for parameter file.";
|
||||||
dol_syslog(get_class($this) . "::draw " . $this->error, LOG_ERR);
|
dol_syslog(get_class($this) . "::draw " . $this->error, LOG_ERR);
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
if (!is_array($this->data))
|
if (!is_array($this->data)) {
|
||||||
{
|
|
||||||
$this->error = "Call to draw method was made but SetData was not called or called with an empty dataset for parameters";
|
$this->error = "Call to draw method was made but SetData was not called or called with an empty dataset for parameters";
|
||||||
dol_syslog(get_class($this) . "::draw " . $this->error, LOG_ERR);
|
dol_syslog(get_class($this) . "::draw " . $this->error, LOG_ERR);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (count($this->data) < 1)
|
if (count($this->data) < 1) {
|
||||||
{
|
|
||||||
$this->error = "Call to draw method was made but SetData was is an empty dataset";
|
$this->error = "Call to draw method was made but SetData was is an empty dataset";
|
||||||
dol_syslog(get_class($this) . "::draw " . $this->error, LOG_WARNING);
|
dol_syslog(get_class($this) . "::draw " . $this->error, LOG_WARNING);
|
||||||
}
|
}
|
||||||
@ -680,8 +666,7 @@ class DolGraph
|
|||||||
|
|
||||||
dol_syslog(get_class($this) . "::draw_jflot this->type=" . join(',', $this->type) . " this->MaxValue=" . $this->MaxValue);
|
dol_syslog(get_class($this) . "::draw_jflot this->type=" . join(',', $this->type) . " this->MaxValue=" . $this->MaxValue);
|
||||||
|
|
||||||
if (empty($this->width) && empty($this->height))
|
if (empty($this->width) && empty($this->height)) {
|
||||||
{
|
|
||||||
print 'Error width or height not set';
|
print 'Error width or height not set';
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -712,8 +697,7 @@ class DolGraph
|
|||||||
$x++;
|
$x++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($this->type[$firstlot]) && in_array($this->type[$firstlot], array('pie', 'piesemicircle', 'polar')))
|
if (isset($this->type[$firstlot]) && in_array($this->type[$firstlot], array('pie', 'piesemicircle', 'polar'))) {
|
||||||
{
|
|
||||||
foreach ($values as $x => $y) {
|
foreach ($values as $x => $y) {
|
||||||
if (isset($y)) $serie[$i] .= 'd' . $i . '.push({"label":"' . dol_escape_js($legends[$x]) . '", "data":' . $y . '});' . "\n";
|
if (isset($y)) $serie[$i] .= 'd' . $i . '.push({"label":"' . dol_escape_js($legends[$x]) . '", "data":' . $y . '});' . "\n";
|
||||||
}
|
}
|
||||||
@ -730,8 +714,7 @@ class DolGraph
|
|||||||
|
|
||||||
$this->stringtoshow = '<!-- Build using jflot -->' . "\n";
|
$this->stringtoshow = '<!-- Build using jflot -->' . "\n";
|
||||||
if (!empty($this->title)) $this->stringtoshow .= '<div class="center dolgraphtitle' . (empty($this->cssprefix) ? '' : ' dolgraphtitle' . $this->cssprefix) . '">' . $this->title . '</div>';
|
if (!empty($this->title)) $this->stringtoshow .= '<div class="center dolgraphtitle' . (empty($this->cssprefix) ? '' : ' dolgraphtitle' . $this->cssprefix) . '">' . $this->title . '</div>';
|
||||||
if (!empty($this->shownographyet))
|
if (!empty($this->shownographyet)) {
|
||||||
{
|
|
||||||
$this->stringtoshow .= '<div style="width:' . $this->width . 'px;height:' . $this->height . 'px;" class="nographyet"></div>';
|
$this->stringtoshow .= '<div style="width:' . $this->width . 'px;height:' . $this->height . 'px;" class="nographyet"></div>';
|
||||||
$this->stringtoshow .= '<div class="nographyettext margintoponly">' . $langs->trans("NotEnoughDataYet") . '...</div>';
|
$this->stringtoshow .= '<div class="nographyettext margintoponly">' . $langs->trans("NotEnoughDataYet") . '...</div>';
|
||||||
return;
|
return;
|
||||||
@ -745,12 +728,10 @@ class DolGraph
|
|||||||
$this->stringtoshow .= '<script id="' . $tag . '">' . "\n";
|
$this->stringtoshow .= '<script id="' . $tag . '">' . "\n";
|
||||||
$this->stringtoshow .= '$(function () {' . "\n";
|
$this->stringtoshow .= '$(function () {' . "\n";
|
||||||
$i = $firstlot;
|
$i = $firstlot;
|
||||||
if ($nblot < 0)
|
if ($nblot < 0) {
|
||||||
{
|
|
||||||
$this->stringtoshow .= '<!-- No series of data -->' . "\n";
|
$this->stringtoshow .= '<!-- No series of data -->' . "\n";
|
||||||
} else {
|
} else {
|
||||||
while ($i < $nblot)
|
while ($i < $nblot) {
|
||||||
{
|
|
||||||
$this->stringtoshow .= '<!-- Serie ' . $i . ' -->' . "\n";
|
$this->stringtoshow .= '<!-- Serie ' . $i . ' -->' . "\n";
|
||||||
$this->stringtoshow .= $serie[$i] . "\n";
|
$this->stringtoshow .= $serie[$i] . "\n";
|
||||||
$i++;
|
$i++;
|
||||||
@ -759,8 +740,7 @@ class DolGraph
|
|||||||
$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]) && in_array($this->type[$firstlot], array('pie', 'piesemicircle', 'polar')))
|
if (isset($this->type[$firstlot]) && in_array($this->type[$firstlot], array('pie', 'piesemicircle', 'polar'))) {
|
||||||
{
|
|
||||||
$datacolor = array();
|
$datacolor = array();
|
||||||
foreach ($this->datacolor as $val) {
|
foreach ($this->datacolor as $val) {
|
||||||
if (is_array($val)) $datacolor[] = "#" . sprintf("%02x%02x%02x", $val[0], $val[1], $val[2]); // If datacolor is array(R, G, B)
|
if (is_array($val)) $datacolor[] = "#" . sprintf("%02x%02x%02x", $val[0], $val[1], $val[2]); // If datacolor is array(R, G, B)
|
||||||
@ -814,8 +794,7 @@ class DolGraph
|
|||||||
pan: {
|
pan: {
|
||||||
interactive: true
|
interactive: true
|
||||||
},';
|
},';
|
||||||
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\' }
|
||||||
@ -876,8 +855,7 @@ class DolGraph
|
|||||||
$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 .= '{ ';
|
||||||
@ -899,8 +877,7 @@ class DolGraph
|
|||||||
// 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++;
|
||||||
@ -949,8 +926,7 @@ class DolGraph
|
|||||||
|
|
||||||
dol_syslog(get_class($this) . "::draw_chart this->type=" . join(',', $this->type) . " this->MaxValue=" . $this->MaxValue);
|
dol_syslog(get_class($this) . "::draw_chart this->type=" . join(',', $this->type) . " this->MaxValue=" . $this->MaxValue);
|
||||||
|
|
||||||
if (empty($this->width) && empty($this->height))
|
if (empty($this->width) && empty($this->height)) {
|
||||||
{
|
|
||||||
print 'Error width or height not set';
|
print 'Error width or height not set';
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -971,7 +947,8 @@ class DolGraph
|
|||||||
// Works with line but not with bars
|
// Works with line but not with bars
|
||||||
//if ($nblot > 2) $firstlot = ($nblot - 2); // We limit nblot to 2 because jflot can't manage more than 2 bars on same x
|
//if ($nblot > 2) $firstlot = ($nblot - 2); // We limit nblot to 2 because jflot can't manage more than 2 bars on same x
|
||||||
|
|
||||||
$serie = array(); $arrayofgroupslegend = array();
|
$serie = array();
|
||||||
|
$arrayofgroupslegend = array();
|
||||||
//var_dump($this->data);
|
//var_dump($this->data);
|
||||||
|
|
||||||
$i = $firstlot;
|
$i = $firstlot;
|
||||||
@ -1023,9 +1000,8 @@ 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 chart -->' . "\n";
|
$this->stringtoshow = '<!-- Build using chart -->' . "\n";
|
||||||
if (!empty($this->title)) $this->stringtoshow .= '<div class="center dolgraphtitle'.(empty($this->cssprefix) ? '' : ' dolgraphtitle'.$this->cssprefix).'">'.$this->title.'</div>';
|
if (!empty($this->title)&&$this->title!='FunnelOfProspection') $this->stringtoshow .= '<div class="center dolgraphtitle' . (empty($this->cssprefix) ? '' : ' dolgraphtitle' . $this->cssprefix) . '">' . $this->title . '</div>';
|
||||||
if (!empty($this->shownographyet))
|
if (!empty($this->shownographyet)) {
|
||||||
{
|
|
||||||
$this->stringtoshow .= '<div style="width:' . $this->width . (strpos($this->width, '%') > 0 ? '' : 'px') . '; height:' . $this->height . 'px;" class="nographyet"></div>';
|
$this->stringtoshow .= '<div style="width:' . $this->width . (strpos($this->width, '%') > 0 ? '' : 'px') . '; height:' . $this->height . 'px;" class="nographyet"></div>';
|
||||||
$this->stringtoshow .= '<div class="nographyettext margintoponly">' . $langs->trans("NotEnoughDataYet") . '...</div>';
|
$this->stringtoshow .= '<div class="nographyettext margintoponly">' . $langs->trans("NotEnoughDataYet") . '...</div>';
|
||||||
return;
|
return;
|
||||||
@ -1041,12 +1017,10 @@ class DolGraph
|
|||||||
|
|
||||||
$this->stringtoshow .= '<script id="' . $tag . '">' . "\n";
|
$this->stringtoshow .= '<script id="' . $tag . '">' . "\n";
|
||||||
$i = $firstlot;
|
$i = $firstlot;
|
||||||
if ($nblot < 0)
|
if ($nblot < 0) {
|
||||||
{
|
|
||||||
$this->stringtoshow .= '<!-- No series of data -->';
|
$this->stringtoshow .= '<!-- No series of data -->';
|
||||||
} else {
|
} else {
|
||||||
while ($i < $nblot)
|
while ($i < $nblot) {
|
||||||
{
|
|
||||||
//$this->stringtoshow .= '<!-- Series '.$i.' -->'."\n";
|
//$this->stringtoshow .= '<!-- Series '.$i.' -->'."\n";
|
||||||
//$this->stringtoshow .= $serie[$i]."\n";
|
//$this->stringtoshow .= $serie[$i]."\n";
|
||||||
$i++;
|
$i++;
|
||||||
@ -1055,8 +1029,7 @@ class DolGraph
|
|||||||
$this->stringtoshow .= "\n";
|
$this->stringtoshow .= "\n";
|
||||||
|
|
||||||
// Special case for Graph of type 'pie', 'piesemicircle', or 'polar'
|
// Special case for Graph of type 'pie', 'piesemicircle', or 'polar'
|
||||||
if (isset($this->type[$firstlot]) && (in_array($this->type[$firstlot], array('pie', 'polar', 'piesemicircle'))))
|
if (isset($this->type[$firstlot]) && (in_array($this->type[$firstlot], array('pie', 'polar', 'piesemicircle')))) {
|
||||||
{
|
|
||||||
$type = $this->type[$firstlot]; // pie or polar
|
$type = $this->type[$firstlot]; // pie or polar
|
||||||
$this->stringtoshow .= 'var options = {' . "\n";
|
$this->stringtoshow .= 'var options = {' . "\n";
|
||||||
$legendMaxLines = 0; // Does not work
|
$legendMaxLines = 0; // Does not work
|
||||||
@ -1077,7 +1050,8 @@ class DolGraph
|
|||||||
$this->stringtoshow .= 'elements: { arc: {' . "\n";
|
$this->stringtoshow .= 'elements: { arc: {' . "\n";
|
||||||
// Color of earch arc
|
// Color of earch arc
|
||||||
$this->stringtoshow .= 'backgroundColor: [';
|
$this->stringtoshow .= 'backgroundColor: [';
|
||||||
$i = 0; $foundnegativecolor = 0;
|
$i = 0;
|
||||||
|
$foundnegativecolor = 0;
|
||||||
foreach ($legends as $val) // Loop on each serie
|
foreach ($legends as $val) // Loop on each serie
|
||||||
{
|
{
|
||||||
if ($i > 0) $this->stringtoshow .= ', ' . "\n";
|
if ($i > 0) $this->stringtoshow .= ', ' . "\n";
|
||||||
@ -1155,8 +1129,10 @@ class DolGraph
|
|||||||
// Other cases, graph of type 'bars', 'lines', 'linesnopoint'
|
// Other cases, graph of type 'bars', 'lines', 'linesnopoint'
|
||||||
else {
|
else {
|
||||||
$type = 'bar';
|
$type = 'bar';
|
||||||
|
$isfunnel = false;
|
||||||
if (!isset($this->type[$firstlot]) || $this->type[$firstlot] == 'bars') $type = 'bar';
|
if (!isset($this->type[$firstlot]) || $this->type[$firstlot] == 'bars') $type = 'bar';
|
||||||
if (isset($this->type[$firstlot]) && $this->type[$firstlot] == 'horizontalbars') $type = 'horizontalBar';
|
if (isset($this->type[$firstlot]) && $this->type[$firstlot] == 'horizontalbars') $type = 'horizontalBar';
|
||||||
|
if ($this->title == 'FunnelOfProspection') $isfunnel = true;
|
||||||
if (isset($this->type[$firstlot]) && ($this->type[$firstlot] == 'lines' || $this->type[$firstlot] == 'linesnopoint')) $type = 'line';
|
if (isset($this->type[$firstlot]) && ($this->type[$firstlot] == 'lines' || $this->type[$firstlot] == 'linesnopoint')) $type = 'line';
|
||||||
|
|
||||||
$this->stringtoshow .= 'var options = { maintainAspectRatio: false, aspectRatio: 2.5, ';
|
$this->stringtoshow .= 'var options = { maintainAspectRatio: false, aspectRatio: 2.5, ';
|
||||||
@ -1164,6 +1140,10 @@ class DolGraph
|
|||||||
$this->stringtoshow .= 'legend: { display: false }, ';
|
$this->stringtoshow .= 'legend: { display: false }, ';
|
||||||
}
|
}
|
||||||
$this->stringtoshow .= 'scales: { xAxes: [{ ';
|
$this->stringtoshow .= 'scales: { xAxes: [{ ';
|
||||||
|
if ($isfunnel) {
|
||||||
|
$this->stringtoshow .= ' ticks: { beginAtZero: true}, display: false,';
|
||||||
|
|
||||||
|
}
|
||||||
//$this->stringtoshow .= 'type: \'time\', '; // Need Moment.js
|
//$this->stringtoshow .= 'type: \'time\', '; // Need Moment.js
|
||||||
$this->stringtoshow .= 'distribution: \'linear\'';
|
$this->stringtoshow .= 'distribution: \'linear\'';
|
||||||
if ($type == 'bar' && count($arrayofgroupslegend) > 0) {
|
if ($type == 'bar' && count($arrayofgroupslegend) > 0) {
|
||||||
@ -1175,7 +1155,6 @@ class DolGraph
|
|||||||
}
|
}
|
||||||
$this->stringtoshow .= ' }';
|
$this->stringtoshow .= ' }';
|
||||||
$this->stringtoshow .= '};';
|
$this->stringtoshow .= '};';
|
||||||
|
|
||||||
$this->stringtoshow .= '
|
$this->stringtoshow .= '
|
||||||
var ctx = document.getElementById("canvas_' . $tag . '").getContext("2d");
|
var ctx = document.getElementById("canvas_' . $tag . '").getContext("2d");
|
||||||
var chart = new Chart(ctx, {
|
var chart = new Chart(ctx, {
|
||||||
@ -1187,12 +1166,14 @@ class DolGraph
|
|||||||
labels: [';
|
labels: [';
|
||||||
|
|
||||||
$i = 0;
|
$i = 0;
|
||||||
|
if (!$isfunnel);{
|
||||||
foreach ($legends as $val) // Loop on each serie
|
foreach ($legends as $val) // Loop on each serie
|
||||||
{
|
{
|
||||||
if ($i > 0) $this->stringtoshow .= ', ';
|
if ($i > 0) $this->stringtoshow .= ', ';
|
||||||
$this->stringtoshow .= "'".dol_escape_js(dol_trunc($val, 32))."'";
|
$this->stringtoshow .= "'".dol_escape_js(dol_trunc($val, 32))."'";
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//var_dump($arrayofgroupslegend);
|
//var_dump($arrayofgroupslegend);
|
||||||
|
|
||||||
@ -1205,6 +1186,7 @@ class DolGraph
|
|||||||
$oldstacknum = -1;
|
$oldstacknum = -1;
|
||||||
while ($i < $nblot) // Loop on each serie
|
while ($i < $nblot) // Loop on each serie
|
||||||
{
|
{
|
||||||
|
$foundnegativecolor = 0;
|
||||||
$usecolorvariantforgroupby = 0;
|
$usecolorvariantforgroupby = 0;
|
||||||
// We used a 'group by' and we have too many colors so we generated color variants per
|
// We used a 'group by' and we have too many colors so we generated color variants per
|
||||||
if (is_array($arrayofgroupslegend[$i]) && count($arrayofgroupslegend[$i]) > 0) { // If we used a group by.
|
if (is_array($arrayofgroupslegend[$i]) && count($arrayofgroupslegend[$i]) > 0) { // If we used a group by.
|
||||||
@ -1245,9 +1227,26 @@ class DolGraph
|
|||||||
$color = 'rgb(' . $newcolor[0] . ', ' . $newcolor[1] . ', ' . $newcolor[2] . ', 0.9)';
|
$color = 'rgb(' . $newcolor[0] . ', ' . $newcolor[1] . ', ' . $newcolor[2] . ', 0.9)';
|
||||||
$bordercolor = 'rgb(' . $newcolor[0] . ', ' . $newcolor[1] . ', ' . $newcolor[2] . ')';
|
$bordercolor = 'rgb(' . $newcolor[0] . ', ' . $newcolor[1] . ', ' . $newcolor[2] . ')';
|
||||||
} else { // We do not use a 'group by'
|
} else { // We do not use a 'group by'
|
||||||
$color = 'rgb('.$this->datacolor[$i][0].', '.$this->datacolor[$i][1].', '.$this->datacolor[$i][2].', 0.9)';
|
if (is_array($this->datacolor[$i])) $color = 'rgb(' . $this->datacolor[$i][0] . ', ' . $this->datacolor[$i][1] . ', ' . $this->datacolor[$i][2] . ')'; // If datacolor is array(R, G, B)
|
||||||
|
else {
|
||||||
|
$tmp = str_replace('#', '', $this->datacolor[$i]);
|
||||||
|
if (strpos($tmp, '-') !== false) {
|
||||||
|
$foundnegativecolor++;
|
||||||
|
$color = '#FFFFFF'; // If $val is '-123'
|
||||||
|
} else {
|
||||||
|
$color = "#" . $tmp; // If $val is '123' or '#123'
|
||||||
$bordercolor = $color;
|
$bordercolor = $color;
|
||||||
//$color = (!empty($data['seriescolor']) ? json_encode($data['seriescolor']) : json_encode($datacolor));
|
}
|
||||||
|
if ($foundnegativecolor) {
|
||||||
|
if (is_array($this->datacolor[$i])) $color = 'null'; // If datacolor is array(R, G, B)
|
||||||
|
else {
|
||||||
|
$tmp = str_replace('#', '', $this->datacolor[$i]);
|
||||||
|
if (strpos($tmp, '-') !== false) $bordercolor = '#' . str_replace('-', '', $tmp); // If $val is '-123'
|
||||||
|
else $bordercolor = 'null'; // If $val is '123' or '#123'
|
||||||
|
}
|
||||||
|
$bordercolor == 'null' ? "'rgba(0,0,0,0.2)'" : "'" . $bordercolor . "'";
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($i > 0) $this->stringtoshow .= ', ';
|
if ($i > 0) $this->stringtoshow .= ', ';
|
||||||
@ -1257,7 +1256,12 @@ class DolGraph
|
|||||||
$this->stringtoshow .= 'label: \'' . dol_escape_js(dol_string_nohtmltag($textoflegend)) . '\', ';
|
$this->stringtoshow .= 'label: \'' . dol_escape_js(dol_string_nohtmltag($textoflegend)) . '\', ';
|
||||||
$this->stringtoshow .= 'pointStyle: \'' . ($this->type[$i] == 'linesnopoint' ? 'line' : 'circle') . '\', ';
|
$this->stringtoshow .= 'pointStyle: \'' . ($this->type[$i] == 'linesnopoint' ? 'line' : 'circle') . '\', ';
|
||||||
$this->stringtoshow .= 'fill: ' . ($type == 'bar' ? 'true' : 'false') . ', ';
|
$this->stringtoshow .= 'fill: ' . ($type == 'bar' ? 'true' : 'false') . ', ';
|
||||||
if ($type == 'bar') { $this->stringtoshow .= 'borderWidth: \'1\', '; }
|
if ($isfunnel){
|
||||||
|
$this->stringtoshow .= 'borderWidth: \'2\', ';
|
||||||
|
}
|
||||||
|
else if ($type == 'bar' || $type == 'horizontalBar') {
|
||||||
|
$this->stringtoshow .= 'borderWidth: \'1\', ';
|
||||||
|
}
|
||||||
$this->stringtoshow .= 'borderColor: \'' . $bordercolor . '\', ';
|
$this->stringtoshow .= 'borderColor: \'' . $bordercolor . '\', ';
|
||||||
$this->stringtoshow .= 'backgroundColor: \'' . $color . '\', ';
|
$this->stringtoshow .= 'backgroundColor: \'' . $color . '\', ';
|
||||||
if ($arrayofgroupslegend[$i]) $this->stringtoshow .= 'stack: \'' . $arrayofgroupslegend[$i]['stacknum'] . '\', ';
|
if ($arrayofgroupslegend[$i]) $this->stringtoshow .= 'stack: \'' . $arrayofgroupslegend[$i]['stacknum'] . '\', ';
|
||||||
@ -1301,8 +1305,7 @@ class DolGraph
|
|||||||
{
|
{
|
||||||
global $langs;
|
global $langs;
|
||||||
|
|
||||||
if ($shownographyet)
|
if ($shownographyet) {
|
||||||
{
|
|
||||||
$s = '<div class="nographyet" style="width:' . (preg_match('/%/', $this->width) ? $this->width : $this->width . 'px') . '; height:' . (preg_match('/%/', $this->height) ? $this->height : $this->height . 'px') . ';"></div>';
|
$s = '<div class="nographyet" style="width:' . (preg_match('/%/', $this->width) ? $this->width : $this->width . 'px') . '; height:' . (preg_match('/%/', $this->height) ? $this->height : $this->height . 'px') . ';"></div>';
|
||||||
$s .= '<div class="nographyettext margintoponly">';
|
$s .= '<div class="nographyettext margintoponly">';
|
||||||
if (is_numeric($shownographyet)) {
|
if (is_numeric($shownographyet)) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user