Update index.php

if nb of categories > 10 we add "other" on the pie charts
This commit is contained in:
BENKE Charles 2014-05-04 17:50:31 +02:00
parent f05643116a
commit a090333dbd

View File

@ -2,6 +2,7 @@
/* Copyright (C) 2001-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2001-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com> * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2014 Charles-Fr Benke <charles.fr@benke.fr>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -181,13 +182,21 @@ if (! empty($conf->categorie->enabled))
if (! empty($conf->use_javascript_ajax) ) if (! empty($conf->use_javascript_ajax) )
{ {
$dataseries=array(); $dataseries=array();
$rest=0;
$nbmax=10;
while ($i < $num) while ($i < $num)
{ {
$obj = $db->fetch_object($result); $obj = $db->fetch_object($result);
if ($i < $nbmax)
$dataseries[]=array('label'=>$obj->label,'data'=>round($obj->nb)); $dataseries[]=array('label'=>$obj->label,'data'=>round($obj->nb));
else
$rest+=$obj->nb;
$total+=$obj->nb; $total+=$obj->nb;
$i++; $i++;
} }
if ($i > $nbmax)
$dataseries[]=array('label'=>$langs->trans("Other"),'data'=>round($rest));
$data=array('series'=>$dataseries); $data=array('series'=>$dataseries);
dol_print_graph('statscategclient',300,180,$data,1,'pie',0); dol_print_graph('statscategclient',300,180,$data,1,'pie',0);
} }