diff --git a/htdocs/core/class/dolgraph.class.php b/htdocs/core/class/dolgraph.class.php index 5b477ace9c8..694b785e63c 100644 --- a/htdocs/core/class/dolgraph.class.php +++ b/htdocs/core/class/dolgraph.class.php @@ -1127,7 +1127,20 @@ class DolGraph $this->stringtoshow .= ''."\n"; } - + /** + * Output HTML string to total value + * + * @return string HTML string to total value + */ + public function total() + { + $value = 0; + foreach($this->data as $valarray) // Loop on each x + { + $value += $valarray[1]; + } + return $value; + } /** * Output HTML string to show graph diff --git a/htdocs/product/stats/card.php b/htdocs/product/stats/card.php index 5ca7992be31..24387ef8b73 100644 --- a/htdocs/product/stats/card.php +++ b/htdocs/product/stats/card.php @@ -4,6 +4,7 @@ * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2005 Eric Seigne * Copyright (C) 2013 Juanjo Menent + * Copyright (C) 2019 Thibault FOUCART * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -351,6 +352,7 @@ if ($result || empty($id)) $url = DOL_URL_ROOT.'/viewimage.php?modulepart='.$graphfiles[$key]['modulepart'].'&entity='.$object->entity.'&file='.urlencode($graphfiles[$key]['file']); $px->draw($dir."/".$graphfiles[$key]['file'], $url); + $graphfiles[$key]['total'] = $px->total(); $graphfiles[$key]['output'] = $px->show(); } else @@ -405,7 +407,7 @@ if ($result || empty($id)) // Label print ''; print $graphfiles[$key]['label']; - print ''; + print ' ('.$graphfiles[$key]['total'].')'; print ''.$linktoregenerate.''; print ''; // Image