Support stack bars for flot graphs

This commit is contained in:
Laurent Destailleur
2011-05-21 14:24:43 +00:00
parent 106a956889
commit 29dc82f97f
3 changed files with 26 additions and 6 deletions

View File

@@ -147,6 +147,7 @@ $SommeC=0;
$SommeD=0;
$dataval=array();
$datalabels=array();
$dataseries=array();
foreach ($AdherentType as $key => $adhtype)
{
$datalabels[]=$adhtype->getNomUrl(0,dol_size(16));
@@ -165,7 +166,8 @@ $dataseries[]=array('label'=>$langs->trans("MenuMembersNotUpToDate"),'values'=>
$dataseries[]=array('label'=>$langs->trans("MenuMembersUpToDate"),'values'=> $dataval['uptodate']);
$dataseries[]=array('label'=>$langs->trans("MembersStatusResiliated"),'values'=> $dataval['resiliated']);
$data=array('series'=>$dataseries,'xlabel'=>$datalabels);
dol_print_graph('stats',300,180,$data,1,'bar');
dol_print_graph('stats2',300,180,$data,1,'bar');
$dataseries=array();
*/
$dataseries[]=array('label'=>$langs->trans("MenuMembersNotUpToDate"),'values'=>array(round($SommeB)));
$dataseries[]=array('label'=>$langs->trans("MenuMembersUpToDate"),'values'=>array(round($SommeC)));
@@ -174,6 +176,9 @@ $dataseries[]=array('label'=>$langs->trans("MembersStatusToValid"),'values'=>arr
$data=array('series'=>$dataseries);
dol_print_graph('stats',300,180,$data,1,'pie');
print '</td></tr>';
print '<tr class="liste_total"><td>'.$langs->trans("Total").'</td><td align="right">';
print $SommeA+$SommeB+$SommeC+$SommeD;
print '</td></tr>';
print '</table>';
print '</td><td class="notopnoleftnoright" valign="top">';

View File

@@ -1240,6 +1240,7 @@ function dolibarr_trunc($string,$size=40,$trunc='right',$stringencoding='')
function dol_print_graph($htmlid,$width,$height,$data,$showlegend=0,$type='pie')
{
global $conf,$langs;
global $theme_datacolor; // To have var kept when function is called several times
if (empty($conf->use_javascript_ajax)) return;
$jsgraphlib='flot';
$datacolor=array();
@@ -1285,7 +1286,8 @@ function dol_print_graph($htmlid,$width,$height,$data,$showlegend=0,$type='pie')
function plotWithOptions() {
jQuery.plot(jQuery("#'.$htmlid.'"), data,
{
series: {pie: {
series: {
pie: {
show: true,
radius: 3/4,
label: {
@@ -1300,10 +1302,16 @@ function dol_print_graph($htmlid,$width,$height,$data,$showlegend=0,$type='pie')
},
background: {
opacity: 0.5,
color: \'#000\'
color: \'#000000\'
}
}
} },
zoom: {
interactive: true
},
pan: {
interactive: true
},
';
if (sizeof($datacolor))
{
@@ -1317,7 +1325,7 @@ function dol_print_graph($htmlid,$width,$height,$data,$showlegend=0,$type='pie')
}
print '], ';
}
print 'legend: {show: '.($showlegend?'true':'false').'}
print 'legend: {show: '.($showlegend?'true':'false').', position: \'ne\' }
});
}
plotWithOptions();
@@ -1366,7 +1374,14 @@ function dol_print_graph($htmlid,$width,$height,$data,$showlegend=0,$type='pie')
series: {
stack: stack,
lines: { show: lines, fill: true, steps: steps },
bars: { show: bars, barWidth: 0.9, align: \'center\' }
bars: { show: bars, barWidth: 0.9, align: \'center\' },
shadowSize: 5
},
zoom: {
interactive: true
},
pan: {
interactive: true
},
';
if (sizeof($datacolor))

View File

@@ -108,7 +108,7 @@ if ($conf->use_javascript_ajax && ((round($third['prospect'])?1:0)+(round($third
if ($conf->societe->enabled && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) $dataseries[]=array('label'=>$langs->trans("Customers"),'values'=>array(round($third['customer'])));
if ($conf->fournisseur->enabled) $dataseries[]=array('label'=>$langs->trans("Suppliers"),'values'=>array(round($third['supplier'])));
$data=array('series'=>$dataseries);
dol_print_graph('stats',300,180,$data,0,'pie');
dol_print_graph('stats',300,180,$data,1,'pie');
print '</td></tr>';
}
else