New: When there is no data on pie chart, can set color to an empty
value.
This commit is contained in:
parent
d4499c6eea
commit
e460aa335c
@ -112,12 +112,13 @@ class box_graph_product_distribution extends ModeleBoxes
|
||||
{
|
||||
include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facturestats.class.php';
|
||||
|
||||
$showpointvalue = 1;
|
||||
$showpointvalue = 1; $nocolor = 0;
|
||||
$stats_invoice = new FactureStats($this->db, 0, $mode, ($userid>0?$userid:0));
|
||||
$data1 = $stats_invoice->getAllByProductEntry($year,(GETPOST('action')==$refreshaction?-1:(3600*24)));
|
||||
if (empty($data1))
|
||||
{
|
||||
$showpointvalue=0;
|
||||
$nocolor=1;
|
||||
$data1=array(array(0=>$langs->trans("None"),1=>1));
|
||||
}
|
||||
$filenamenb = $dir."/prodserforinvoice-".$year.".png";
|
||||
@ -129,6 +130,8 @@ class box_graph_product_distribution extends ModeleBoxes
|
||||
{
|
||||
$px1->SetData($data1);
|
||||
unset($data1);
|
||||
|
||||
if ($nocolor) $px1->SetDataColor(array(array(220,220,220)));
|
||||
$px1->SetPrecisionY(0);
|
||||
$i=0;$tot=count($data1);$legend=array();
|
||||
while ($i <= $tot)
|
||||
@ -164,12 +167,13 @@ class box_graph_product_distribution extends ModeleBoxes
|
||||
{
|
||||
include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propalestats.class.php';
|
||||
|
||||
$showpointvalue = 1;
|
||||
$showpointvalue = 1; $nocolor = 0;
|
||||
$stats_proposal = new PropaleStats($this->db, 0, $mode, ($userid>0?$userid:0));
|
||||
$data2 = $stats_proposal->getAllByProductEntry($year,(GETPOST('action')==$refreshaction?-1:(3600*24)));
|
||||
if (empty($data2))
|
||||
{
|
||||
$showpointvalue = 0;
|
||||
$nocolor = 1;
|
||||
$data2=array(array(0=>$langs->trans("None"),1=>1));
|
||||
}
|
||||
|
||||
@ -182,6 +186,8 @@ class box_graph_product_distribution extends ModeleBoxes
|
||||
{
|
||||
$px2->SetData($data2);
|
||||
unset($data2);
|
||||
|
||||
if ($nocolor) $px2->SetDataColor(array(array(220,220,220)));
|
||||
$px2->SetPrecisionY(0);
|
||||
$i=0;$tot=count($data2);$legend=array();
|
||||
while ($i <= $tot)
|
||||
@ -217,12 +223,13 @@ class box_graph_product_distribution extends ModeleBoxes
|
||||
{
|
||||
include_once DOL_DOCUMENT_ROOT.'/commande/class/commandestats.class.php';
|
||||
|
||||
$showpointvalue = 1;
|
||||
$showpointvalue = 1; $nocolor = 0;
|
||||
$stats_order = new CommandeStats($this->db, 0, $mode, ($userid>0?$userid:0));
|
||||
$data3 = $stats_order->getAllByProductEntry($year,(GETPOST('action')==$refreshaction?-1:(3600*24)));
|
||||
if (empty($data3))
|
||||
{
|
||||
$showpointvalue = 0;
|
||||
$nocolor = 1;
|
||||
$data3=array(array(0=>$langs->trans("None"),1=>1));
|
||||
}
|
||||
|
||||
@ -235,6 +242,8 @@ class box_graph_product_distribution extends ModeleBoxes
|
||||
{
|
||||
$px3->SetData($data3);
|
||||
unset($data3);
|
||||
|
||||
if ($nocolor) $px3->SetDataColor(array(array(220,220,220)));
|
||||
$px3->SetPrecisionY(0);
|
||||
$i=0;$tot=count($data3);$legend=array();
|
||||
while ($i <= $tot)
|
||||
|
||||
@ -242,9 +242,19 @@ class DolGraph
|
||||
function SetData($data)
|
||||
{
|
||||
$this->data = $data;
|
||||
//var_dump($this->data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set data
|
||||
*
|
||||
* @param array $datacolor Data color array(array(R,G,B),array(R,G,B)...)
|
||||
* @return void
|
||||
*/
|
||||
function SetDataColor($datacolor)
|
||||
{
|
||||
$this->datacolor = $datacolor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set type
|
||||
*
|
||||
@ -779,7 +789,7 @@ class DolGraph
|
||||
/**
|
||||
* Build a graph onto disk using JFlot library. Input when calling this method should be:
|
||||
* $this->data = array(array( 0=>'labelxA', 1=>yA), array('labelxB',yB)); or
|
||||
* $this->data = array(array('label'=>'labelxA','data'=>yA), array('labelxB',yB));
|
||||
* $this->data = array(array('label'=>'labelxA','data'=>yA), array('labelxB',yB)); // TODO Syntax not supported. Removed when dol_print_graph_removed
|
||||
* $this->data = array(array(0=>'labelxA',1=>yA1,...,n=>yAn), array('labelxB',yB1,...yBn)); // when there is n series to show for each x
|
||||
* $this->legend= array("Val1",...,"Valn"); // list of n series name
|
||||
* $this->type = array('bars',...'lines'); or array('pie')
|
||||
@ -820,7 +830,7 @@ class DolGraph
|
||||
$x++;
|
||||
}
|
||||
|
||||
// TODO Avoid push by adding generating a long array...
|
||||
// TODO Avoid push by adding generated long array...
|
||||
if (isset($this->type[$firstlot]) && $this->type[$firstlot] == 'pie')
|
||||
{
|
||||
foreach($values as $x => $y) { if (isset($y)) $serie[$i].='d'.$i.'.push({"label":"'.dol_escape_js($legends[$x]).'", "data":'.$y.'});'."\n"; }
|
||||
|
||||
@ -1356,6 +1356,7 @@ tr.box_pair {
|
||||
|
||||
.formboxfilter {
|
||||
vertical-align: middle;
|
||||
margin-bottom: 6px;
|
||||
}
|
||||
.formboxfilter input[type=image]
|
||||
{
|
||||
|
||||
@ -1523,6 +1523,7 @@ tr.box_pair td, tr.box_impair td, td.box_pair, td.box_impair
|
||||
|
||||
.formboxfilter {
|
||||
vertical-align: middle;
|
||||
margin-bottom: 6px;
|
||||
}
|
||||
.formboxfilter input[type=image]
|
||||
{
|
||||
|
||||
@ -1650,6 +1650,7 @@ font-family: <?php print $fontlist ?>;
|
||||
|
||||
.formboxfilter {
|
||||
vertical-align: middle;
|
||||
margin-bottom: 6px;
|
||||
}
|
||||
.formboxfilter input[type=image]
|
||||
{
|
||||
|
||||
@ -1656,6 +1656,7 @@ border: 0px;
|
||||
|
||||
.formboxfilter {
|
||||
vertical-align: middle;
|
||||
margin-bottom: 6px;
|
||||
}
|
||||
.formboxfilter input[type=image]
|
||||
{
|
||||
|
||||
@ -1947,6 +1947,7 @@ tr.box_pair {
|
||||
|
||||
.formboxfilter {
|
||||
vertical-align: middle;
|
||||
margin-bottom: 6px;
|
||||
}
|
||||
.formboxfilter input[type=image]
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user